增加列表查询 字段

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

View File

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