perf: 返回表名加中文

dev
huangfeng 1 year ago
parent 1e1dcec5ea
commit d72e74394b

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

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

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

Loading…
Cancel
Save