修改树形结构
parent
3df7205054
commit
c18f376e2a
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.domain.rep.TableInfoRep;
|
import com.muyu.domain.rep.TableInfoRep;
|
||||||
|
import com.muyu.domain.rep.TableInfoResp;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -64,4 +65,15 @@ public class TableInfo extends BaseEntity {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TableInfoResp toTableInfoResp(TableInfo tableInfo) {
|
||||||
|
return TableInfoResp.builder()
|
||||||
|
.id(tableInfo.id)
|
||||||
|
.tableName(tableInfo.tableName)
|
||||||
|
.tableRemark(tableInfo.tableRemark)
|
||||||
|
.isCenter(tableInfo.center)
|
||||||
|
.dataNum(tableInfo.dataNum)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.domain.rep;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class TableInfoResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名称/数据库
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表备注
|
||||||
|
*/
|
||||||
|
private String tableRemark;
|
||||||
|
|
||||||
|
/** 数据量 */
|
||||||
|
private Long dataNum;
|
||||||
|
|
||||||
|
/** 是否核心 'Y'是 'N'不是 */
|
||||||
|
private String isCenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子内容
|
||||||
|
*/
|
||||||
|
private List<TableInfoResp> children;
|
||||||
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package com.muyu.cloud.etl.controller;
|
package com.muyu.cloud.etl.controller;
|
||||||
|
|
||||||
|
import com.dtflys.forest.annotation.NotNull;
|
||||||
import com.muyu.cloud.etl.service.StructureService;
|
import com.muyu.cloud.etl.service.StructureService;
|
||||||
import com.muyu.cloud.etl.service.TableInfoService;
|
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.TableInfoRep;
|
||||||
|
import com.muyu.domain.rep.TableInfoResp;
|
||||||
import com.muyu.domain.rep.TableInfoTreeRep;
|
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;
|
||||||
|
@ -44,4 +46,25 @@ public class TableInfoController {
|
||||||
return Result.success(tableInfoTreeReps);
|
return Result.success(tableInfoTreeReps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/findTableInfoList")
|
||||||
|
public Result findByTableName() {
|
||||||
|
List<TableInfo> list = tableInfoService.list();
|
||||||
|
List<TableInfoResp> respList = list.stream().filter(tableInfo -> tableInfo.getParentId()==0).map(tableInfo -> {
|
||||||
|
TableInfoResp tableInfoResp = TableInfo.toTableInfoResp(tableInfo);
|
||||||
|
tableInfoResp.setChildren(getChildren(tableInfo, list));
|
||||||
|
return tableInfoResp;
|
||||||
|
}).toList();
|
||||||
|
return Result.success(respList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static List<TableInfoResp> getChildren(TableInfo tableInfo, List<TableInfo> list) {
|
||||||
|
return list.stream().filter(tableInfo1 -> tableInfo1.getParentId().equals(tableInfo.getId())).map(
|
||||||
|
tableInfo2 -> TableInfo.toTableInfoResp(tableInfo2)
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue