perf: 返回表名加中文

dev
huangfeng 1 year ago
parent 1e1dcec5ea
commit d72e74394b

@ -86,8 +86,8 @@ public class IcdConfigController extends BasicController {
@GetMapping("tableList") @GetMapping("tableList")
@ApiOperation("查询data表名") @ApiOperation("查询data表名")
public Response<List<String>> tableList() throws Exception { public Response<List<ColumnModel>> tableList() throws Exception {
List<String> result = dataService.getDataTables(); List<ColumnModel> result = dataService.getDataTables();
return Response.success(result); return Response.success(result);
} }

@ -9,7 +9,7 @@ import java.util.Map;
public interface DataService { public interface DataService {
List<String> getDataTables() throws Exception; List<ColumnModel> getDataTables() throws Exception;
List<ColumnModel> getDataTableColumns(String tableName) throws Exception; List<ColumnModel> getDataTableColumns(String tableName) throws Exception;

@ -1,10 +1,12 @@
package com.xydl.cac.service.impl; package com.xydl.cac.service.impl;
import com.xydl.cac.entity.ModevType;
import com.xydl.cac.entity.NiecPoint; import com.xydl.cac.entity.NiecPoint;
import com.xydl.cac.entity.NiecSensor; import com.xydl.cac.entity.NiecSensor;
import com.xydl.cac.model.ColumnModel; import com.xydl.cac.model.ColumnModel;
import com.xydl.cac.model.ConditionModel; import com.xydl.cac.model.ConditionModel;
import com.xydl.cac.model.OnePage; import com.xydl.cac.model.OnePage;
import com.xydl.cac.repository.ModevTypeRepository;
import com.xydl.cac.service.DataService; import com.xydl.cac.service.DataService;
import com.xydl.cac.util.DateUtil; import com.xydl.cac.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -28,15 +30,26 @@ public class DataServiceImpl implements DataService {
@Resource @Resource
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Resource
ModevTypeRepository modevTypeRepository;
@Override @Override
public List<String> getDataTables() throws Exception { public List<ColumnModel> getDataTables() throws Exception {
List<String> tables = new ArrayList<>(); List<ModevType> typeList = modevTypeRepository.findAll();
List<ColumnModel> tables = new ArrayList<>();
String sql = "SHOW TABLES"; String sql = "SHOW TABLES";
List<String> list = jdbcTemplate.queryForList(sql, String.class); List<String> list = jdbcTemplate.queryForList(sql, String.class);
for (String table : list) { for (String name : list) {
if (table.startsWith("data_")) { if (name.startsWith("data_")) {
tables.add(table); ColumnModel item = new ColumnModel();
item.setName(name);
for (ModevType type : typeList) {
if (name.equals(type.getTablename())) {
item.setComment(type.getMc());
break;
}
}
tables.add(item);
} }
} }
return tables; return tables;

Loading…
Cancel
Save