增加列表查询 字段

master
lwj 2024-08-27 11:00:14 +08:00
parent 65c7f2c144
commit 77d17b06e9
3 changed files with 36 additions and 41 deletions

View File

@ -6,16 +6,13 @@ import com.muyu.cloud.etl.service.TableInfoService;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.Structure;
import com.muyu.domain.TableInfo;
import com.muyu.domain.rep.TableInfoRep;
import com.muyu.domain.rep.TableInfoResp;
import com.muyu.domain.rep.TableInfoTreeRep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
@ -26,27 +23,27 @@ public class TableInfoController {
@Autowired
private StructureService structureService;
@GetMapping("/findTableInfo")
public Result<List<TableInfoTreeRep>> findTableInfo() {
List<TableInfo> tableInfoList= tableInfoService.findSourceList();
List<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<TableInfoTreeRep>();
for (TableInfo tableInfo : tableInfoList) {
TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep();
tableInfoTreeRep.setTableInfo(tableInfo);
List<TableInfoRep> tableInfoRepList= tableInfoService.findTablesList(tableInfo.getId());
tableInfoTreeRep.setChildren(tableInfoRepList);
for (TableInfoRep tableInfoRep : tableInfoRepList) {
List<Structure> structureList=structureService.findStructureList(tableInfoRep.getId());
tableInfoRep.setStructureList(structureList);
}
tableInfoTreeReps.add(tableInfoTreeRep);
}
return Result.success(tableInfoTreeReps);
}
// @GetMapping("/findTableInfo")
// public Result<List<TableInfoTreeRep>> findTableInfo() {
// List<TableInfo> tableInfoList= tableInfoService.findSourceList();
//
// List<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<TableInfoTreeRep>();
//
// for (TableInfo tableInfo : tableInfoList) {
// TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep();
// tableInfoTreeRep.setTableInfo(tableInfo);
// List<TableInfoRep> tableInfoRepList= tableInfoService.findTablesList(tableInfo.getId());
// tableInfoTreeRep.setChildren(tableInfoRepList);
// for (TableInfoRep tableInfoRep : tableInfoRepList) {
// List<Structure> structureList=structureService.findStructureList(tableInfoRep.getId());
// tableInfoRep.setStructureList(structureList);
// }
// tableInfoTreeReps.add(tableInfoTreeRep);
// }
//
// return Result.success(tableInfoTreeReps);
//
// }
@GetMapping("/findTableInfoList")
public Result findByTableName() {

View File

@ -12,5 +12,5 @@ public interface TableInfoService extends IService<TableInfo> {
List<TableInfo> findSourceList();
List<TableInfoRep> findTablesList(Long id);
// List<TableInfoRep> findTablesList(Long id);
}

View File

@ -5,11 +5,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.cloud.etl.mapper.TableInfoMapper;
import com.muyu.cloud.etl.service.TableInfoService;
import com.muyu.domain.TableInfo;
import com.muyu.domain.rep.TableInfoRep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
@ -38,18 +36,18 @@ public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> im
return tableInfoList;
}
@Override
public List<TableInfoRep> findTablesList(Long id) {
List<TableInfo> tableInfoList = tableInfoMapper.selectList(new LambdaQueryWrapper<TableInfo>(TableInfo.class).eq(
TableInfo::getParentId, id
));
List<TableInfoRep> tableInfoRepList = new ArrayList<>();
for (TableInfo tableInfo : tableInfoList) {
TableInfoRep tableInfoRep = TableInfo.tableInfoRep(tableInfo);
tableInfoRepList.add(tableInfoRep);
}
return tableInfoRepList;
}
// @Override
// public List<TableInfoRep> findTablesList(Long id) {
// List<TableInfo> tableInfoList = tableInfoMapper.selectList(new LambdaQueryWrapper<TableInfo>(TableInfo.class).eq(
// TableInfo::getParentId, id
// ));
//
// List<TableInfoRep> tableInfoRepList = new ArrayList<>();
// for (TableInfo tableInfo : tableInfoList) {
// TableInfoRep tableInfoRep = TableInfo.tableInfoRep(tableInfo);
// tableInfoRepList.add(tableInfoRep);
// }
//
// return tableInfoRepList;
// }
}