ImplementSqlService.java 840 B

12345678910111213141516171819202122232425262728
  1. package com.database2.server;
  2. import com.database2.dao.DataColumnMapper;
  3. import com.model.po.ColumnData;
  4. import com.model.pojo.RepCode;
  5. import com.model.pojo.RepEntity;
  6. import com.util.SqlMatch;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import java.util.List;
  10. @Service
  11. public class ImplementSqlService {
  12. @Autowired
  13. DataColumnMapper dataColumnMapper;
  14. /*
  15. 执行数据源
  16. */
  17. public RepEntity implementSql(String sqlStr){
  18. String tableName = SqlMatch.matchSql(sqlStr).toUpperCase();
  19. if ("".equals(tableName) || tableName == null){
  20. return new RepEntity(RepCode.Null);
  21. }
  22. List<ColumnData> columnData = dataColumnMapper.getColumn(tableName);
  23. return new RepEntity(RepCode.success, columnData);
  24. }
  25. }