后台资产展示代码

master
冷调 2024-08-27 19:45:44 +08:00
parent e194d73c1d
commit 80d6cf92ee
3 changed files with 36 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package com.muyu.source.controller; package com.muyu.source.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dtflys.forest.springboot.annotation.ForestScannerRegister; import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil; import com.muyu.common.core.utils.poi.ExcelUtil;
@ -8,11 +9,13 @@ import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.source.domain.AssetDataSource;
import com.muyu.source.domain.Children; import com.muyu.source.domain.Children;
import com.muyu.source.domain.TableData; import com.muyu.source.domain.TableData;
import com.muyu.source.domain.rep.TableInfoRep; import com.muyu.source.domain.rep.TableInfoRep;
import com.muyu.source.domain.rep.TableInfoResp; import com.muyu.source.domain.rep.TableInfoResp;
import com.muyu.source.domain.rep.TableInfoTreeRep; import com.muyu.source.domain.rep.TableInfoTreeRep;
import com.muyu.source.service.AssetDataSourceService;
import com.muyu.source.service.ChildrenService; import com.muyu.source.service.ChildrenService;
import com.muyu.source.service.TableDataService; import com.muyu.source.service.TableDataService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -49,6 +52,8 @@ public class TableDataController extends BaseController {
private TableDataService tableDataService; private TableDataService tableDataService;
@Autowired @Autowired
private ChildrenService childrenService; private ChildrenService childrenService;
@Autowired
private AssetDataSourceService assetDataSourceService;
/** /**
* childrenId * childrenId
* *
@ -155,18 +160,27 @@ public class TableDataController extends BaseController {
@GetMapping("/findTableInfo") @GetMapping("/findTableInfo")
@Operation(summary = "查询表结构树", description = "查询表结构树") @Operation(summary = "查询表结构树", description = "查询表结构树")
public Result<List<TableInfoTreeRep>> findTableInfo() { public Result<List<TableInfoTreeRep>> findTableInfo() {
List<Children> childrenList =childrenService.findSourceList(); // AssetDataSource dataSource = assetDataSourceService.getOne(new LambdaQueryWrapper<>() {{
// eq(AssetDataSource::getType, "dataSource");
// }});
ArrayList<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<>(); ArrayList<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<>();
for (Children children : childrenList) { List<AssetDataSource> dataSource = assetDataSourceService.list(new LambdaQueryWrapper<>() {{
TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep(); eq(AssetDataSource::getType, "dataSource");
tableInfoTreeRep.setChildren(children); }});
List<TableInfoRep> tableInfoRepList =childrenService.findTablesList(children.getId()); for (AssetDataSource assetDataSource : dataSource) {
tableInfoTreeRep.setTableInfoRepList(tableInfoRepList); List<Children> childrenList =childrenService.findSourceList(assetDataSource.getId());
for(TableInfoRep tableInfoRep:tableInfoRepList){
List<TableData> tableDataList =tableDataService.findTableDataList(tableInfoRep.getId()); for (Children children : childrenList) {
tableInfoRep.setTableDataList(tableDataList); TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep();
tableInfoTreeRep.setChildren(children);
List<TableInfoRep> tableInfoRepList =childrenService.findTablesList(children.getAssetId());
tableInfoTreeRep.setTableInfoRepList(tableInfoRepList);
for(TableInfoRep tableInfoRep:tableInfoRepList){
List<TableData> tableDataList =tableDataService.findTableDataList(tableInfoRep.getId());
tableInfoRep.setTableDataList(tableDataList);
}
tableInfoTreeReps.add(tableInfoTreeRep);
} }
tableInfoTreeReps.add(tableInfoTreeRep);
} }
return Result.success(tableInfoTreeReps); return Result.success(tableInfoTreeReps);
} }

View File

@ -17,7 +17,8 @@ import java.util.List;
public interface ChildrenService extends IService<Children> { public interface ChildrenService extends IService<Children> {
List<Children> findSourceList();
List<TableInfoRep> findTablesList(Long id); List<TableInfoRep> findTablesList(Long id);
List<Children> findSourceList(Long id);
} }

View File

@ -25,13 +25,14 @@ public class ChildrenServiceImpl extends ServiceImpl<ChildrenMapper, Children> i
@Autowired @Autowired
private ChildrenMapper childrenMapper; private ChildrenMapper childrenMapper;
@Override @Override
public List<Children> findSourceList() { public List<Children> findSourceList(Long id) {
return childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class) return childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class){{
.eq(Children::getAssetId, 0)); eq(Children::getAssetId,id);
}});
} }
@Override @Override
public List<TableInfoRep> findTablesList(Long id) { public List<TableInfoRep> findTablesList(Long id) {
List<Children> childrenList = childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class) List<Children> childrenList = childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class)
@ -43,4 +44,8 @@ public class ChildrenServiceImpl extends ServiceImpl<ChildrenMapper, Children> i
} }
return tableInfoRepList; return tableInfoRepList;
} }
} }