数据接入
parent
d10fb1c27d
commit
aeb3e52a36
|
@ -224,5 +224,4 @@ public class EngIneController extends BaseController {
|
|||
public Result findVersionById(@PathVariable("id") Long id) {
|
||||
return Result.success(engineVersionService.getById(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.muyu.controller;
|
||||
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.domain.TableInfo;
|
||||
import com.muyu.domain.TableInfoResp;
|
||||
import com.muyu.domain.constants.Result;
|
||||
import com.muyu.service.TableInfoService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:qdm
|
||||
* @Package:com.muyu.controller
|
||||
* @Project:engine
|
||||
* @name:SourceDataController
|
||||
* @Date:2024/9/6 14:58
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/source")
|
||||
public class SourceDataController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
TableInfoService tableInfoService;
|
||||
|
||||
//查询所有的数据进行
|
||||
@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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.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;
|
||||
|
||||
@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 TableInfoResp toTableInfoResp(TableInfo tableInfo) {
|
||||
return TableInfoResp.builder()
|
||||
.id(tableInfo.id)
|
||||
.parentId(tableInfo.parentId)
|
||||
.basicId(tableInfo.basicId)
|
||||
.tableName(tableInfo.tableName)
|
||||
.tableRemark(tableInfo.tableRemark)
|
||||
.isCenter(tableInfo.center)
|
||||
.dataNum(tableInfo.dataNum)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
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 Long basicId;
|
||||
|
||||
/**
|
||||
* 表备注
|
||||
*/
|
||||
private String tableRemark;
|
||||
|
||||
/** 数据量 */
|
||||
private Long dataNum;
|
||||
|
||||
/** 是否核心 'Y'是 'N'不是 */
|
||||
private String isCenter;
|
||||
|
||||
//父级ID
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 子内容
|
||||
*/
|
||||
private List<TableInfoResp> children;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.TableInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author:qdm
|
||||
* @Package:com.muyu.mapper
|
||||
* @Project:engine
|
||||
* @name:SourceMapper
|
||||
* @Date:2024/9/6 15:02
|
||||
*/
|
||||
@Mapper
|
||||
public interface SourceMapper extends BaseMapper<TableInfo> {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.domain.TableInfo;
|
||||
|
||||
/**
|
||||
* @Author:qdm
|
||||
* @Package:com.muyu.service
|
||||
* @Project:engine
|
||||
* @name:TableInfoService
|
||||
* @Date:2024/9/6 15:01
|
||||
*/
|
||||
public interface TableInfoService extends IService<TableInfo> {
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.domain.TableInfo;
|
||||
import com.muyu.mapper.SourceMapper;
|
||||
import com.muyu.service.TableInfoService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author:qdm
|
||||
* @Package:com.muyu.service.serviceImpl
|
||||
* @Project:engine
|
||||
* @name:TableInfoServiceImpl
|
||||
* @Date:2024/9/6 15:01
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class TableInfoServiceImpl extends ServiceImpl<SourceMapper, TableInfo> implements TableInfoService {
|
||||
|
||||
}
|
Loading…
Reference in New Issue