后台资产展示代码
parent
49a8a0c5a4
commit
6a6d939fa5
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.source.domain.rep.TableInfoRep;
|
||||
import com.muyu.source.domain.rep.TableInfoResp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -61,8 +63,27 @@ public class Children extends BaseEntity {
|
|||
* 数据源
|
||||
*/
|
||||
@Excel(name = "数据源id")
|
||||
private Long assetId;
|
||||
|
||||
private Integer assetId;
|
||||
|
||||
|
||||
public TableInfoRep tableInfoRep(Children children) {
|
||||
return TableInfoRep.builder()
|
||||
.id(children.getId())
|
||||
. name(children.getName())
|
||||
.annotation(children.getAnnotation())
|
||||
.dataTotal(children.getDataTotal())
|
||||
.type(children.getType())
|
||||
.isCenter(children.getIsCenter())
|
||||
.assetId(children.getAssetId())
|
||||
.build();
|
||||
}
|
||||
public static TableInfoResp toTableInfoResp(Children children) {
|
||||
return TableInfoResp.builder()
|
||||
.id(children.id)
|
||||
.name(children.name)
|
||||
.annotation(children.annotation)
|
||||
.isCenter(children.isCenter)
|
||||
.dataTotal(children.dataTotal)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TableInfoRep {
|
|||
@Excel(name = "是否核心 'Y'是 'N'不是")
|
||||
private String isCenter;
|
||||
|
||||
private Long assetId;
|
||||
private Integer assetId;
|
||||
|
||||
private List<TableData> tableDataList;
|
||||
|
||||
|
|
|
@ -40,5 +40,5 @@ public class TableInfoResp {
|
|||
/**
|
||||
* 子内容
|
||||
*/
|
||||
private List<Children> children;
|
||||
private List<TableInfoResp> children;
|
||||
}
|
||||
|
|
|
@ -8,17 +8,23 @@ import com.muyu.common.core.web.controller.BaseController;
|
|||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.domain.TableData;
|
||||
import com.muyu.source.domain.rep.TableInfoRep;
|
||||
import com.muyu.source.domain.rep.TableInfoResp;
|
||||
import com.muyu.source.domain.rep.TableInfoTreeRep;
|
||||
import com.muyu.source.service.ChildrenService;
|
||||
import com.muyu.source.service.TableDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.rabbit.listener.ListenerFailedRuleBasedTransactionAttribute;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -41,6 +47,8 @@ public class TableDataController extends BaseController {
|
|||
|
||||
@Autowired
|
||||
private TableDataService tableDataService;
|
||||
@Autowired
|
||||
private ChildrenService childrenService;
|
||||
/**
|
||||
* 根据childrenId查询表结构
|
||||
*
|
||||
|
@ -133,7 +141,41 @@ public class TableDataController extends BaseController {
|
|||
return toAjax(tableDataService.updateById(tableData));
|
||||
}
|
||||
|
||||
@GetMapping("/findTableInfo")
|
||||
public Result<List<TableInfoTreeRep>> findTableInfo() {
|
||||
List<Children> childrenList =childrenService.findSourceList();
|
||||
ArrayList<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<>();
|
||||
for (Children children : childrenList) {
|
||||
TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep();
|
||||
tableInfoTreeRep.setChildren(children);
|
||||
List<TableInfoRep> tableInfoRepList =childrenService.findTablesList(children.getId());
|
||||
tableInfoTreeRep.setTableInfoRepList(tableInfoRepList);
|
||||
for(TableInfoRep tableInfoRep:tableInfoRepList){
|
||||
List<TableData> tableDataList =tableDataService.findTableDataList(tableInfoRep.getId());
|
||||
tableInfoRep.setTableDataList(tableDataList);
|
||||
}
|
||||
tableInfoTreeReps.add(tableInfoTreeRep);
|
||||
}
|
||||
return success(tableInfoTreeReps);
|
||||
}
|
||||
|
||||
@GetMapping("/findTableInfoList")
|
||||
public Result findByTableName(){
|
||||
List<Children> childrenList = childrenService.list();
|
||||
List<TableInfoResp> list = childrenList.stream().filter(children -> children.getAssetId() == 0).map(children -> {
|
||||
TableInfoResp tableInfoResp = Children.toTableInfoResp(children);
|
||||
tableInfoResp.setChildren(getChildren(children, childrenList));
|
||||
return tableInfoResp;
|
||||
}).toList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
private List<TableInfoResp> getChildren(Children children, List<Children> childrenList) {
|
||||
return childrenList.stream().filter(children1 -> children1.getAssetId().equals(children.getId())).map(
|
||||
children2 -> Children.toTableInfoResp(children2)
|
||||
).toList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.muyu.source.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.domain.rep.TableInfoRep;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
|
@ -14,4 +17,7 @@ import com.muyu.source.domain.Children;
|
|||
public interface ChildrenService extends IService<Children> {
|
||||
|
||||
|
||||
List<Children> findSourceList();
|
||||
|
||||
List<TableInfoRep> findTablesList(Long id);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.muyu.source.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.domain.rep.TableInfoRep;
|
||||
import com.muyu.source.mapper.ChildrenMapper;
|
||||
import com.muyu.source.service.ChildrenService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -17,5 +23,24 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class ChildrenServiceImpl extends ServiceImpl<ChildrenMapper, Children> implements ChildrenService {
|
||||
|
||||
@Autowired
|
||||
private ChildrenMapper childrenMapper;
|
||||
|
||||
@Override
|
||||
public List<Children> findSourceList() {
|
||||
return childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class)
|
||||
.eq(Children::getAssetId, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableInfoRep> findTablesList(Long id) {
|
||||
List<Children> childrenList = childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class)
|
||||
.eq(Children::getAssetId, id));
|
||||
ArrayList<TableInfoRep> tableInfoRepList = new ArrayList<>();
|
||||
for (Children children : childrenList) {
|
||||
TableInfoRep tableInfoRep =children.tableInfoRep(children);
|
||||
tableInfoRepList.add(tableInfoRep);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,12 @@ import cn.hutool.core.lang.Assert;
|
|||
import com.alibaba.cloud.commons.lang.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.domain.TableData;
|
||||
import com.muyu.source.mapper.TableDataMapper;
|
||||
import com.muyu.source.service.TableDataService;
|
||||
import org.checkerframework.checker.units.qual.Acceleration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -21,6 +24,8 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class TableDataServiceImpl extends ServiceImpl<TableDataMapper, TableData> implements TableDataService {
|
||||
@Autowired
|
||||
private TableDataMapper tableDataMapper;
|
||||
/**
|
||||
* 精确查询结构
|
||||
*
|
||||
|
@ -68,6 +73,11 @@ public class TableDataServiceImpl extends ServiceImpl<TableDataMapper, TableData
|
|||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableData> findTableDataList(Long id) {
|
||||
LambdaQueryWrapper<TableData> lambdaQueryWrapper = new LambdaQueryWrapper<TableData>().eq(TableData::getChildrenId, id);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.source.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.domain.TableData;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -38,5 +39,5 @@ public interface TableDataService extends IService<TableData> {
|
|||
Boolean checkIdUnique(TableData tableData);
|
||||
|
||||
|
||||
|
||||
List<TableData> findTableDataList(Long id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue