后台资产展示代码
parent
4be2e3beda
commit
9e3a867117
|
@ -13,6 +13,8 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -66,24 +68,26 @@ public class Children extends BaseEntity {
|
|||
private Long 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();
|
||||
}
|
||||
// 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();
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package com.muyu.source.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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 lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 结构对象 structure
|
||||
*
|
||||
* @author Saisai
|
||||
* @date 2024-04-22
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value ="structure",autoResultMap = true) //数据库表相关
|
||||
public class Structure extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 表id */
|
||||
@Excel(name = "表id")
|
||||
private Long tableId;
|
||||
|
||||
/** 字段名称 */
|
||||
@Excel(name = "字段名称")
|
||||
private String columnName;
|
||||
|
||||
/** 字段注释 */
|
||||
@Excel(name = "字段注释")
|
||||
private String columnRemark;
|
||||
|
||||
/** 是否主键 'Y'是主键 'N'不是主键 */
|
||||
@Excel(name = "是否主键 'Y'是主键 'N'不是主键")
|
||||
private String isPrimary;
|
||||
|
||||
/** 数据类型 */
|
||||
@Excel(name = "数据类型")
|
||||
private String columnType;
|
||||
|
||||
/** 映射类型 */
|
||||
@Excel(name = "映射类型")
|
||||
private String javaType;
|
||||
|
||||
/** 字段长度 */
|
||||
@Excel(name = "字段长度")
|
||||
private String columnLength;
|
||||
|
||||
/** 小数位数 */
|
||||
@Excel(name = "小数位数")
|
||||
private String columnDecimals;
|
||||
|
||||
/** 是否为空 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否为空 'Y'是 'N'不是")
|
||||
private String isNull;
|
||||
|
||||
/** 默认值 */
|
||||
@Excel(name = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
/** 是否字典 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否字典 'Y'是 'N'不是")
|
||||
private String isDictionary;
|
||||
|
||||
/** 映射字典 */
|
||||
@Excel(name = "映射字典")
|
||||
private String dictionaryTable;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.muyu.source.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value ="table_info") //数据库表相关
|
||||
public class TableInfo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long basicId;
|
||||
|
||||
/** 表名称/数据库 */
|
||||
@Excel(name = "表名称/数据库")
|
||||
private String tableName;
|
||||
|
||||
/** 表备注 */
|
||||
@Excel(name = "表备注")
|
||||
private String tableRemark;
|
||||
|
||||
/** 表备注 */
|
||||
@Excel(name = "数据来源类型")
|
||||
private String type;
|
||||
|
||||
/** 数据量 */
|
||||
@Excel(name = "数据量")
|
||||
private Long dataNum;
|
||||
|
||||
/** 是否核心 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否核心 'Y'是 'N'不是")
|
||||
private String center;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
|
||||
public static TableInfoRep tableInfoRep(TableInfo tableInfo){
|
||||
return TableInfoRep.builder()
|
||||
.id(tableInfo.getId())
|
||||
.basicId(tableInfo.getBasicId())
|
||||
.tableName(tableInfo.getTableName())
|
||||
.tableRemark(tableInfo.getTableRemark())
|
||||
.type(tableInfo.getType())
|
||||
.center(tableInfo.getCenter())
|
||||
.parentId(tableInfo.getParentId())
|
||||
.dataNum(tableInfo.getDataNum())
|
||||
.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();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package com.muyu.source.domain.rep;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.source.domain.TableData;
|
||||
import com.muyu.source.domain.Structure;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -11,9 +11,6 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
@ -28,26 +25,26 @@ public class TableInfoRep {
|
|||
|
||||
/** 表名称/数据库 */
|
||||
@Excel(name = "表名称/数据库")
|
||||
private String name;
|
||||
private String tableName;
|
||||
|
||||
/** 表备注 */
|
||||
@Excel(name = "表备注")
|
||||
private String annotation;
|
||||
private String tableRemark;
|
||||
|
||||
/** 数据来源类型 */
|
||||
/** 表备注 */
|
||||
@Excel(name = "数据来源类型")
|
||||
private String type;
|
||||
|
||||
/** 数据量 */
|
||||
@Excel(name = "数据量")
|
||||
private Integer dataTotal;
|
||||
private Long dataNum;
|
||||
|
||||
/** 是否核心 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否核心 'Y'是 'N'不是")
|
||||
private String isCenter;
|
||||
private String center;
|
||||
|
||||
private Long assetId;
|
||||
private Long parentId;
|
||||
|
||||
private List<TableData> tableDataList;
|
||||
private List<Structure> structureList;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.muyu.source.domain.rep;
|
||||
|
||||
import com.muyu.source.domain.Children;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -8,9 +7,6 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
@ -25,17 +21,19 @@ public class TableInfoResp {
|
|||
/**
|
||||
* 表名称/数据库
|
||||
*/
|
||||
private String name;
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表备注
|
||||
*/
|
||||
private String annotation;
|
||||
private String tableRemark;
|
||||
|
||||
/** 数据量 */
|
||||
private Integer dataTotal;
|
||||
private Long dataNum;
|
||||
|
||||
/** 是否核心 'Y'是 'N'不是 */
|
||||
private String isCenter;
|
||||
|
||||
/**
|
||||
* 子内容
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.muyu.source.domain.rep;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -10,9 +10,6 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
@ -20,9 +17,9 @@ import java.util.List;
|
|||
public class TableInfoTreeRep {
|
||||
//主键
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Integer id;
|
||||
|
||||
private Children children;
|
||||
private TableInfo tableInfo;
|
||||
|
||||
private List<TableInfoRep> tableInfoRepList;
|
||||
private List<TableInfoRep> children;
|
||||
}
|
||||
|
|
|
@ -173,12 +173,12 @@ public class DataSourceController extends BaseController {
|
|||
* @param dataSource 数据源
|
||||
* @return 是否同步成功
|
||||
*/
|
||||
@PostMapping("/synchronous")
|
||||
@Operation(summary = "同步数据源", description = "同步数据源")
|
||||
public Result synchronous(@RequestBody DataSource dataSource){
|
||||
dataSourceService.synchronous(dataSource);
|
||||
return Result.success();
|
||||
}
|
||||
// @PostMapping("/synchronous")
|
||||
// @Operation(summary = "同步数据源", description = "同步数据源")
|
||||
// public Result synchronous(@RequestBody DataSource dataSource){
|
||||
// dataSourceService.synchronous(dataSource);
|
||||
// return Result.success();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -157,57 +157,60 @@ public class TableDataController extends BaseController {
|
|||
* 查询表结构树
|
||||
* @return tableInfoTreeReps
|
||||
*/
|
||||
@GetMapping("/findTableInfo")
|
||||
@Operation(summary = "查询表结构树", description = "查询表结构树")
|
||||
public Result<List<TableInfoTreeRep>> findTableInfo() {
|
||||
// AssetDataSource dataSource = assetDataSourceService.getOne(new LambdaQueryWrapper<>() {{
|
||||
// @GetMapping("/findTableInfo")
|
||||
// @Operation(summary = "查询表结构树", description = "查询表结构树")
|
||||
// public Result<List<TableInfoTreeRep>> findTableInfo() {
|
||||
//// AssetDataSource dataSource = assetDataSourceService.getOne(new LambdaQueryWrapper<>() {{
|
||||
//// eq(AssetDataSource::getType, "dataSource");
|
||||
//// }});
|
||||
// List<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<TableInfoTreeRep>();
|
||||
// List<AssetDataSource> dataSource = assetDataSourceService.list(new LambdaQueryWrapper<>() {{
|
||||
// eq(AssetDataSource::getType, "dataSource");
|
||||
// }});
|
||||
ArrayList<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<>();
|
||||
List<AssetDataSource> dataSource = assetDataSourceService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(AssetDataSource::getType, "dataSource");
|
||||
}});
|
||||
for (AssetDataSource assetDataSource : dataSource) {
|
||||
List<Children> childrenList =childrenService.findSourceList(assetDataSource.getId());
|
||||
|
||||
for (Children children : childrenList) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
return Result.success(tableInfoTreeReps);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名查询表结构
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findTableInfoList")
|
||||
@Operation(summary = "根据表名查询表结构", description = "根据表名查询表结构")
|
||||
public Result findByTableName(){
|
||||
List<Children> childrenList = childrenService.list();
|
||||
|
||||
List<TableInfoResp> list = childrenList.stream().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();
|
||||
|
||||
}
|
||||
// for (AssetDataSource assetDataSource : dataSource) {
|
||||
// List<Children> childrenList =childrenService.findSourceList(assetDataSource.getId());
|
||||
// for (Children children : childrenList) {
|
||||
// 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);
|
||||
// }
|
||||
// return Result.success(tableInfoTreeReps);
|
||||
// }
|
||||
// return Result.success(tableInfoTreeReps);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据表名查询表结构
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping("/findTableInfoList")
|
||||
// @Operation(summary = "根据表名查询表结构", description = "根据表名查询表结构")
|
||||
// public Result findByTableName(){
|
||||
// assetDataSourceService.list(new LambdaQueryWrapper<>(){{
|
||||
// eq(AssetDataSource::getType,"dataSource");
|
||||
// }});
|
||||
// //
|
||||
// List<Children> childrenList = childrenService.list();
|
||||
// List<TableInfoResp> list = childrenList.stream().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();
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package com.muyu.source.controller;
|
||||
|
||||
import com.dtflys.forest.annotation.NotNull;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.domain.Structure;
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
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.StructureService;
|
||||
import com.muyu.source.service.TableInfoService;
|
||||
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
|
||||
@RequestMapping("/tableInfo")
|
||||
public class TableInfoController {
|
||||
@Autowired
|
||||
private TableInfoService tableInfoService;
|
||||
@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("/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();
|
||||
}
|
||||
|
||||
@GetMapping("/findStruceure/{id}")
|
||||
public Result<List<Structure>> findStruceure(@PathVariable("id") Integer id) {
|
||||
List<Structure> structureList= structureService.findStructurelistS(id);
|
||||
return Result.success(structureList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.source.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.muyu.source.domain.Structure;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface StructureMapper extends BaseMapper<Structure> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.source.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface TableInfoMapper extends BaseMapper<TableInfo> {
|
||||
}
|
|
@ -17,8 +17,8 @@ import java.util.List;
|
|||
public interface ChildrenService extends IService<Children> {
|
||||
|
||||
|
||||
List<TableInfoRep> findTablesList(Long id);
|
||||
|
||||
|
||||
List<Children> findSourceList(Long id);
|
||||
// List<TableInfoRep> findTablesList(Long id);
|
||||
//
|
||||
//
|
||||
// List<Children> findSourceList(Long id);
|
||||
}
|
||||
|
|
|
@ -41,5 +41,5 @@ public interface DataSourceService extends IService<DataSource> {
|
|||
|
||||
Boolean testConnection(DataSource dataSource);
|
||||
|
||||
void synchronous(DataSource dataSource);
|
||||
// void synchronous(DataSource dataSource);
|
||||
}
|
||||
|
|
|
@ -23,27 +23,27 @@ import java.util.List;
|
|||
@Service
|
||||
public class ChildrenServiceImpl extends ServiceImpl<ChildrenMapper, Children> implements ChildrenService {
|
||||
|
||||
@Autowired
|
||||
private ChildrenMapper childrenMapper;
|
||||
@Override
|
||||
public List<Children> findSourceList(Long id) {
|
||||
return childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class){{
|
||||
eq(Children::getAssetId,id);
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
@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 tableInfoRepList;
|
||||
}
|
||||
// @Autowired
|
||||
// private ChildrenMapper childrenMapper;
|
||||
// @Override
|
||||
// public List<Children> findSourceList(Long id) {
|
||||
// return childrenMapper.selectList(new LambdaQueryWrapper<>(Children.class){{
|
||||
// eq(Children::getAssetId,id);
|
||||
// }});
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @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 tableInfoRepList;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -135,214 +135,214 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
*
|
||||
* @param dataSource 数据源
|
||||
*/
|
||||
@Override
|
||||
public void synchronous(DataSource dataSource) {
|
||||
// 获取指定ID的资产数据源对象
|
||||
AssetDataSource dataSourceServiceOne = assetDataSourceService.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(AssetDataSource::getId, dataSource.getId());
|
||||
}});
|
||||
//如果存在则进行删除
|
||||
if (StringUtils.isNotNull(dataSourceServiceOne)) {
|
||||
// 根据资产数据源ID查询所有的表
|
||||
List<Children> childrenList = childrenService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(Children::getAssetId, dataSourceServiceOne.getId());
|
||||
}});
|
||||
|
||||
childrenList.forEach(children -> {
|
||||
//删除表结构中表的所有数据
|
||||
tableDataService.remove(new LambdaQueryWrapper<>() {{
|
||||
eq(TableData::getChildrenId, children.getId());
|
||||
}});
|
||||
});
|
||||
// 删除数据库结构中所有的数据
|
||||
childrenService.remove(new LambdaQueryWrapper<>() {{
|
||||
eq(Children::getAssetId, dataSourceServiceOne.getId());
|
||||
}});
|
||||
assetDataSourceService.remove(new LambdaQueryWrapper<>() {{
|
||||
eq(AssetDataSource::getId, dataSourceServiceOne.getId());
|
||||
}});
|
||||
}
|
||||
AssetDataSource build = AssetDataSource.builder()
|
||||
.id(dataSource.getId())
|
||||
.name(dataSource.getName())
|
||||
.systemName(dataSource.getSystemName())
|
||||
.databaseName(dataSource.getDatabaseName())
|
||||
.type("dataSource")
|
||||
.build();
|
||||
//添加资产数据源结构 库
|
||||
assetDataSourceService.save(build);
|
||||
//添加资产数据源下的所有表结构 表
|
||||
List<Children> childrenList = addChildren(build);
|
||||
//循环遍历添加表结构的数据 字段
|
||||
childrenList.forEach(children -> {
|
||||
addTable(build, children.getName());
|
||||
});
|
||||
}
|
||||
|
||||
//同步数据库结构
|
||||
private List<Children> addChildren(AssetDataSource build) {
|
||||
//获取数据源
|
||||
DataSource dataSource = this.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(DataSource::getName, build.getName());
|
||||
eq(DataSource::getDatabaseName, build.getDatabaseName());
|
||||
}});
|
||||
//获取数据源类型
|
||||
DataType dataType = dataTypeService.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(DataType::getType, dataSource.getDataType());
|
||||
}});
|
||||
//用于拼接jdbc连接数据库的路径
|
||||
String jdbcUrl = "";
|
||||
//用于拼接sql语句
|
||||
String sql = "";
|
||||
//判断数据库类型
|
||||
if ("MySql".equals(dataType.getType())) {
|
||||
//获取表名称以及表注释
|
||||
sql = "select TABLE_NAME,TABLE_COMMENT from INFORMATION_SCHEMA.Tables where table_schema =" + "'" + dataSource.getDatabaseName() + "'";
|
||||
}
|
||||
//拼接jdbc连接数据库的路径
|
||||
jdbcUrl = dataType.getPrefix() + dataSource.getIp() + ":" + dataSource.getPort() + "/" +
|
||||
dataSource.getDatabaseName() + "?" + dataSource.getConnectionParam();
|
||||
try {
|
||||
//加载驱动
|
||||
Class.forName(dataType.getDriverManager());
|
||||
//获取连接
|
||||
Connection connection = DriverManager.getConnection(jdbcUrl, dataSource.getUserName(), dataSource.getPassword());
|
||||
//执行sql语句
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
||||
//返回一个结果集 包含查询生成的数据
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
//遍历结果集
|
||||
while (resultSet.next()) {
|
||||
Children children = Children.builder()
|
||||
.name(resultSet.getString("TABLE_NAME"))
|
||||
.remark(resultSet.getString("TABLE_COMMENT"))
|
||||
.type("dataType")
|
||||
.isCenter("Y")
|
||||
.assetId(build.getId())
|
||||
.build();
|
||||
//添加到数据库中
|
||||
childrenService.save(children);
|
||||
}
|
||||
//关闭连接
|
||||
connection.close();
|
||||
resultSet.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//获取数据库结构
|
||||
List<Children> childrenList = childrenService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(Children::getAssetId, build.getId());
|
||||
}});
|
||||
try {
|
||||
//加载驱动
|
||||
Class.forName(dataType.getDriverManager());
|
||||
//获取连接
|
||||
Connection connection = DriverManager.getConnection(jdbcUrl, dataSource.getUserName(), dataSource.getPassword());
|
||||
//创建一个Statement对象
|
||||
Statement statement = connection.createStatement();
|
||||
//遍历获取到的表结构集合
|
||||
childrenList.forEach(children -> {
|
||||
//查询指定数据库中指定表的记录数
|
||||
String sql1 = "SELECT COUNT(*) AS tableNum FROM " + "`" + dataSource.getDatabaseName() + "`" + "." + "`" + children.getName() + "`";
|
||||
try {
|
||||
//执行给定的sql语句
|
||||
ResultSet resultSet = statement.executeQuery(sql1);
|
||||
while (resultSet.next()) {
|
||||
//检索resultSet对象当前行中的指定列的值
|
||||
int anInt = resultSet.getInt("tableNum");
|
||||
children.setDataTotal(anInt);
|
||||
childrenService.updateById(children);
|
||||
}
|
||||
resultSet.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return childrenList;
|
||||
}
|
||||
|
||||
//同步表结构
|
||||
private void addTable(AssetDataSource build, String name) {
|
||||
// 查询数据源对象
|
||||
DataSource dataSource = this.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(DataSource::getName, build.getName());
|
||||
eq(DataSource::getDatabaseName, build.getDatabaseName());
|
||||
}});
|
||||
//获取表结构对象
|
||||
Children serviceOne = childrenService.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(Children::getName, name);
|
||||
}});
|
||||
// 获取数据类型对象
|
||||
DataType dataType = dataTypeService.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(DataType::getType, dataSource.getDataType());
|
||||
}});
|
||||
// 用于拼接jdbc连接数据库的路径
|
||||
String jdbcUrl = "";
|
||||
jdbcUrl = dataType.getPrefix() + dataSource.getIp() + ":" + dataSource.getPort() + "/" +
|
||||
dataSource.getDatabaseName() + "?" + dataSource.getConnectionParam();
|
||||
try {
|
||||
//加载驱动
|
||||
Class.forName(dataType.getDriverManager());
|
||||
//获取连接
|
||||
Connection connection = DriverManager.getConnection(jdbcUrl, dataSource.getUserName(), dataSource.getPassword());
|
||||
//获取数据库元数据
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
//获取指定数据库中指定表的字段信息
|
||||
ResultSet columns = metaData.getColumns(dataSource.getDatabaseName(), dataSource.getDatabaseName(), name, "%");
|
||||
//获取指定数据库中指定表的主键信息
|
||||
ResultSet primaryKeys = metaData.getPrimaryKeys(dataSource.getDatabaseName(), dataSource.getDatabaseName(), name);
|
||||
//获取指定数据库中指定表的主键名称
|
||||
String primaryKey = "";
|
||||
//遍历主键信息
|
||||
while (primaryKeys.next()) {
|
||||
primaryKey = primaryKeys.getString("COLUMN_NAME");
|
||||
}
|
||||
//遍历字段信息
|
||||
while (columns.next()) {
|
||||
//获取字段名称
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
//获取字段备注
|
||||
String columnComment = columns.getString("REMARKS");
|
||||
//获取字段类型
|
||||
String columnType = columns.getString("TYPE_NAME");
|
||||
//获取字段长度
|
||||
int columnSize = columns.getInt("COLUMN_SIZE");
|
||||
//获取字段小数位数
|
||||
int decimalDigits = columns.getInt("DECIMAL_DIGITS");
|
||||
//判断字段是否为空
|
||||
String isNullable = columns.getString("IS_NULLABLE");
|
||||
//判断字段是否为默认值
|
||||
String columnDefault = columns.getString("COLUMN_DEF");
|
||||
// 添加字段
|
||||
TableData tableData = TableData.builder()
|
||||
.name(columnName)
|
||||
.comment(columnComment)
|
||||
.isPrimaryKey(columnName.equals(primaryKey) ? "Y" : "N")
|
||||
.type(columnType)
|
||||
.length(columnSize)
|
||||
.decimalPlaces(decimalDigits)
|
||||
.isNull(isNullable.equals("YES") ? "Y" : "N")
|
||||
.defaultValue(columnDefault)
|
||||
.isDict("N")
|
||||
.dictKey("")
|
||||
.childrenId(serviceOne.getId())
|
||||
.build();
|
||||
//添加字段信息到数据库中
|
||||
tableDataService.save(tableData);
|
||||
}
|
||||
//关闭资源
|
||||
columns.close();
|
||||
primaryKeys.close();
|
||||
connection.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// @Override
|
||||
// public void synchronous(DataSource dataSource) {
|
||||
// // 获取指定ID的资产数据源对象
|
||||
// AssetDataSource dataSourceServiceOne = assetDataSourceService.getOne(new LambdaQueryWrapper<>() {{
|
||||
// eq(AssetDataSource::getId, dataSource.getId());
|
||||
// }});
|
||||
// //如果存在则进行删除
|
||||
// if (StringUtils.isNotNull(dataSourceServiceOne)) {
|
||||
// // 根据资产数据源ID查询所有的表
|
||||
// List<Children> childrenList = childrenService.list(new LambdaQueryWrapper<>() {{
|
||||
// eq(Children::getAssetId, dataSourceServiceOne.getId());
|
||||
// }});
|
||||
//
|
||||
// childrenList.forEach(children -> {
|
||||
// //删除表结构中表的所有数据
|
||||
// tableDataService.remove(new LambdaQueryWrapper<>() {{
|
||||
// eq(TableData::getChildrenId, children.getId());
|
||||
// }});
|
||||
// });
|
||||
// // 删除数据库结构中所有的数据
|
||||
// childrenService.remove(new LambdaQueryWrapper<>() {{
|
||||
// eq(Children::getAssetId, dataSourceServiceOne.getId());
|
||||
// }});
|
||||
// assetDataSourceService.remove(new LambdaQueryWrapper<>() {{
|
||||
// eq(AssetDataSource::getId, dataSourceServiceOne.getId());
|
||||
// }});
|
||||
// }
|
||||
// AssetDataSource build = AssetDataSource.builder()
|
||||
// .id(dataSource.getId())
|
||||
// .name(dataSource.getName())
|
||||
// .systemName(dataSource.getSystemName())
|
||||
// .databaseName(dataSource.getDatabaseName())
|
||||
// .type("dataSource")
|
||||
// .build();
|
||||
// //添加资产数据源结构 库
|
||||
// assetDataSourceService.save(build);
|
||||
// //添加资产数据源下的所有表结构 表
|
||||
// List<Children> childrenList = addChildren(build);
|
||||
// //循环遍历添加表结构的数据 字段
|
||||
// childrenList.forEach(children -> {
|
||||
// addTable(build, children.getName());
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// //同步数据库结构
|
||||
// private List<Children> addChildren(AssetDataSource build) {
|
||||
// //获取数据源
|
||||
// DataSource dataSource = this.getOne(new LambdaQueryWrapper<>() {{
|
||||
// eq(DataSource::getName, build.getName());
|
||||
// eq(DataSource::getDatabaseName, build.getDatabaseName());
|
||||
// }});
|
||||
// //获取数据源类型
|
||||
// DataType dataType = dataTypeService.getOne(new LambdaQueryWrapper<>() {{
|
||||
// eq(DataType::getType, dataSource.getDataType());
|
||||
// }});
|
||||
// //用于拼接jdbc连接数据库的路径
|
||||
// String jdbcUrl = "";
|
||||
// //用于拼接sql语句
|
||||
// String sql = "";
|
||||
// //判断数据库类型
|
||||
// if ("MySql".equals(dataType.getType())) {
|
||||
// //获取表名称以及表注释
|
||||
// sql = "select TABLE_NAME,TABLE_COMMENT from INFORMATION_SCHEMA.Tables where table_schema =" + "'" + dataSource.getDatabaseName() + "'";
|
||||
// }
|
||||
// //拼接jdbc连接数据库的路径
|
||||
// jdbcUrl = dataType.getPrefix() + dataSource.getIp() + ":" + dataSource.getPort() + "/" +
|
||||
// dataSource.getDatabaseName() + "?" + dataSource.getConnectionParam();
|
||||
// try {
|
||||
// //加载驱动
|
||||
// Class.forName(dataType.getDriverManager());
|
||||
// //获取连接
|
||||
// Connection connection = DriverManager.getConnection(jdbcUrl, dataSource.getUserName(), dataSource.getPassword());
|
||||
// //执行sql语句
|
||||
// PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
||||
// //返回一个结果集 包含查询生成的数据
|
||||
// ResultSet resultSet = preparedStatement.executeQuery();
|
||||
// //遍历结果集
|
||||
// while (resultSet.next()) {
|
||||
// Children children = Children.builder()
|
||||
// .name(resultSet.getString("TABLE_NAME"))
|
||||
// .remark(resultSet.getString("TABLE_COMMENT"))
|
||||
// .type("dataType")
|
||||
// .isCenter("Y")
|
||||
// .assetId(build.getId())
|
||||
// .build();
|
||||
// //添加到数据库中
|
||||
// childrenService.save(children);
|
||||
// }
|
||||
// //关闭连接
|
||||
// connection.close();
|
||||
// resultSet.close();
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// //获取数据库结构
|
||||
// List<Children> childrenList = childrenService.list(new LambdaQueryWrapper<>() {{
|
||||
// eq(Children::getAssetId, build.getId());
|
||||
// }});
|
||||
// try {
|
||||
// //加载驱动
|
||||
// Class.forName(dataType.getDriverManager());
|
||||
// //获取连接
|
||||
// Connection connection = DriverManager.getConnection(jdbcUrl, dataSource.getUserName(), dataSource.getPassword());
|
||||
// //创建一个Statement对象
|
||||
// Statement statement = connection.createStatement();
|
||||
// //遍历获取到的表结构集合
|
||||
// childrenList.forEach(children -> {
|
||||
// //查询指定数据库中指定表的记录数
|
||||
// String sql1 = "SELECT COUNT(*) AS tableNum FROM " + "`" + dataSource.getDatabaseName() + "`" + "." + "`" + children.getName() + "`";
|
||||
// try {
|
||||
// //执行给定的sql语句
|
||||
// ResultSet resultSet = statement.executeQuery(sql1);
|
||||
// while (resultSet.next()) {
|
||||
// //检索resultSet对象当前行中的指定列的值
|
||||
// int anInt = resultSet.getInt("tableNum");
|
||||
// children.setDataTotal(anInt);
|
||||
// childrenService.updateById(children);
|
||||
// }
|
||||
// resultSet.close();
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return childrenList;
|
||||
// }
|
||||
//
|
||||
// //同步表结构
|
||||
// private void addTable(AssetDataSource build, String name) {
|
||||
// // 查询数据源对象
|
||||
// DataSource dataSource = this.getOne(new LambdaQueryWrapper<>() {{
|
||||
// eq(DataSource::getName, build.getName());
|
||||
// eq(DataSource::getDatabaseName, build.getDatabaseName());
|
||||
// }});
|
||||
// //获取表结构对象
|
||||
// Children serviceOne = childrenService.getOne(new LambdaQueryWrapper<>() {{
|
||||
// eq(Children::getName, name);
|
||||
// }});
|
||||
// // 获取数据类型对象
|
||||
// DataType dataType = dataTypeService.getOne(new LambdaQueryWrapper<>() {{
|
||||
// eq(DataType::getType, dataSource.getDataType());
|
||||
// }});
|
||||
// // 用于拼接jdbc连接数据库的路径
|
||||
// String jdbcUrl = "";
|
||||
// jdbcUrl = dataType.getPrefix() + dataSource.getIp() + ":" + dataSource.getPort() + "/" +
|
||||
// dataSource.getDatabaseName() + "?" + dataSource.getConnectionParam();
|
||||
// try {
|
||||
// //加载驱动
|
||||
// Class.forName(dataType.getDriverManager());
|
||||
// //获取连接
|
||||
// Connection connection = DriverManager.getConnection(jdbcUrl, dataSource.getUserName(), dataSource.getPassword());
|
||||
// //获取数据库元数据
|
||||
// DatabaseMetaData metaData = connection.getMetaData();
|
||||
// //获取指定数据库中指定表的字段信息
|
||||
// ResultSet columns = metaData.getColumns(dataSource.getDatabaseName(), dataSource.getDatabaseName(), name, "%");
|
||||
// //获取指定数据库中指定表的主键信息
|
||||
// ResultSet primaryKeys = metaData.getPrimaryKeys(dataSource.getDatabaseName(), dataSource.getDatabaseName(), name);
|
||||
// //获取指定数据库中指定表的主键名称
|
||||
// String primaryKey = "";
|
||||
// //遍历主键信息
|
||||
// while (primaryKeys.next()) {
|
||||
// primaryKey = primaryKeys.getString("COLUMN_NAME");
|
||||
// }
|
||||
// //遍历字段信息
|
||||
// while (columns.next()) {
|
||||
// //获取字段名称
|
||||
// String columnName = columns.getString("COLUMN_NAME");
|
||||
// //获取字段备注
|
||||
// String columnComment = columns.getString("REMARKS");
|
||||
// //获取字段类型
|
||||
// String columnType = columns.getString("TYPE_NAME");
|
||||
// //获取字段长度
|
||||
// int columnSize = columns.getInt("COLUMN_SIZE");
|
||||
// //获取字段小数位数
|
||||
// int decimalDigits = columns.getInt("DECIMAL_DIGITS");
|
||||
// //判断字段是否为空
|
||||
// String isNullable = columns.getString("IS_NULLABLE");
|
||||
// //判断字段是否为默认值
|
||||
// String columnDefault = columns.getString("COLUMN_DEF");
|
||||
// // 添加字段
|
||||
// TableData tableData = TableData.builder()
|
||||
// .name(columnName)
|
||||
// .comment(columnComment)
|
||||
// .isPrimaryKey(columnName.equals(primaryKey) ? "Y" : "N")
|
||||
// .type(columnType)
|
||||
// .length(columnSize)
|
||||
// .decimalPlaces(decimalDigits)
|
||||
// .isNull(isNullable.equals("YES") ? "Y" : "N")
|
||||
// .defaultValue(columnDefault)
|
||||
// .isDict("N")
|
||||
// .dictKey("")
|
||||
// .childrenId(serviceOne.getId())
|
||||
// .build();
|
||||
// //添加字段信息到数据库中
|
||||
// tableDataService.save(tableData);
|
||||
// }
|
||||
// //关闭资源
|
||||
// columns.close();
|
||||
// primaryKeys.close();
|
||||
// connection.close();
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
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.Structure;
|
||||
import com.muyu.source.mapper.StructureMapper;
|
||||
import com.muyu.source.service.StructureService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure> implements StructureService {
|
||||
|
||||
@Override
|
||||
public List<Structure> findStructureList(Long id) {
|
||||
LambdaQueryWrapper<Structure> structureLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
structureLambdaQueryWrapper.eq(Structure::getTableId, id);
|
||||
List<Structure> list = this.list(structureLambdaQueryWrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Structure> findStructurelistS(Integer id) {
|
||||
LambdaQueryWrapper<Structure> structureLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
structureLambdaQueryWrapper.eq(Structure::getTableId, id);
|
||||
List<Structure> list = this.list(structureLambdaQueryWrapper);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
@ -73,11 +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);
|
||||
}
|
||||
// @Override
|
||||
// public List<TableData> findTableDataList(Long id) {
|
||||
// LambdaQueryWrapper<TableData> lambdaQueryWrapper = new LambdaQueryWrapper<TableData>().eq(TableData::getChildrenId, id);
|
||||
// return this.list(lambdaQueryWrapper);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
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.TableInfo;
|
||||
import com.muyu.source.domain.rep.TableInfoRep;
|
||||
import com.muyu.source.mapper.TableInfoMapper;
|
||||
import com.muyu.source.service.TableInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> implements TableInfoService {
|
||||
@Autowired
|
||||
private TableInfoMapper tableInfoMapper;
|
||||
|
||||
@Override
|
||||
public TableInfo selectTableInfoByName(TableInfo tableInfoInsert) {
|
||||
LambdaQueryWrapper<TableInfo> tableInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// tableInfoLambdaQueryWrapper.eq(TableInfo::getId, tableInfoInsert.getId());
|
||||
//
|
||||
|
||||
tableInfoLambdaQueryWrapper.eq(TableInfo::getBasicId, tableInfoInsert.getBasicId());
|
||||
tableInfoLambdaQueryWrapper.eq(TableInfo::getTableName, tableInfoInsert.getTableName())
|
||||
.eq(TableInfo::getParentId, tableInfoInsert.getParentId());
|
||||
|
||||
return this.tableInfoMapper.selectOne(tableInfoLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableInfo> findSourceList() {
|
||||
List<TableInfo> tableInfoList = tableInfoMapper.selectList(new LambdaQueryWrapper<TableInfo>(TableInfo.class)
|
||||
.eq(TableInfo::getParentId, 0));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.source.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.domain.Structure;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StructureService extends IService<Structure> {
|
||||
List<Structure> findStructureList(Long id);
|
||||
|
||||
List<Structure> findStructurelistS(Integer id);
|
||||
|
||||
}
|
|
@ -39,5 +39,5 @@ public interface TableDataService extends IService<TableData> {
|
|||
Boolean checkIdUnique(TableData tableData);
|
||||
|
||||
|
||||
List<TableData> findTableDataList(Long id);
|
||||
// List<TableData> findTableDataList(Long id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.source.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
import com.muyu.source.domain.rep.TableInfoRep;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TableInfoService extends IService<TableInfo> {
|
||||
|
||||
TableInfo selectTableInfoByName(TableInfo tableInfoInsert);
|
||||
|
||||
List<TableInfo> findSourceList();
|
||||
|
||||
List<TableInfoRep> findTablesList(Long id);
|
||||
}
|
Loading…
Reference in New Issue