feat:同步数据后调用结果同步到树级结构
parent
5da4983e6d
commit
ed38fe8109
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.etl.domain.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
import com.muyu.etl.domain.TableInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName TableTreeResp
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/4/23 8:59
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TableTreeResp {
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long Id;
|
||||
/**
|
||||
* 父级信息
|
||||
*/
|
||||
private TableInfo tableInfo;
|
||||
/**
|
||||
* 链接信息
|
||||
*/
|
||||
private BasicConfigInfo basicConfigInfo;
|
||||
/**
|
||||
* 子级信息
|
||||
*/
|
||||
private List<TableInfo> Children;
|
||||
}
|
|
@ -8,6 +8,7 @@ import com.muyu.common.log.annotation.Log;
|
|||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
import com.muyu.etl.domain.resp.TableTreeResp;
|
||||
import com.muyu.etl.service.BasicConfigInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -113,4 +114,11 @@ public class BasicConfigInfoController extends BaseController
|
|||
public Result<TableDataInfo<List>> getData(){
|
||||
return getDataTable(basicConfigInfoService.getDataByEtl());
|
||||
}
|
||||
|
||||
@RequiresPermissions("etl:table:list")
|
||||
@Log(title = "获取已成功链接的树级结构")
|
||||
@GetMapping("/getTableTree")
|
||||
public Result<List<TableTreeResp>> getTableTree(){
|
||||
return Result.success(basicConfigInfoService.getTableTree());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.muyu.etl.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
import com.muyu.etl.domain.resp.TableTreeResp;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.util.List;
|
||||
|
@ -66,4 +68,6 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo>
|
|||
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
|
||||
|
||||
List getDataByEtl();
|
||||
|
||||
List<TableTreeResp> getTableTree();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
import com.muyu.etl.domain.Structure;
|
||||
import com.muyu.etl.domain.TableInfo;
|
||||
import com.muyu.etl.domain.resp.TableTreeResp;
|
||||
import com.muyu.etl.mapper.BasicConfigInfoMapper;
|
||||
import com.muyu.etl.service.BasicConfigInfoService;
|
||||
import com.muyu.etl.service.StructureService;
|
||||
|
@ -21,6 +20,7 @@ import javax.servlet.ServletException;
|
|||
import java.sql.*;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Service业务层处理
|
||||
|
@ -219,16 +219,16 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
|||
// WHERE TABLE_SCHEMA = '数据库名' AND TABLE_NAME = '表名'"
|
||||
ResultSet resultSet = ps.executeQuery();
|
||||
while (resultSet.next()){
|
||||
String columnName = (String) resultSet.getString(1);
|
||||
String columnComment = (String) resultSet.getObject(2);
|
||||
String columnKey = (String) resultSet.getObject(3);
|
||||
String end = (String) resultSet.getObject(4);
|
||||
String dataType = (String) resultSet.getObject(5);
|
||||
String columnType = (String) resultSet.getObject(6);
|
||||
String columnName = String.valueOf( resultSet.getString(1));
|
||||
String columnComment = String.valueOf( resultSet.getObject(2));
|
||||
String columnKey = String.valueOf( resultSet.getObject(3));
|
||||
String end = String.valueOf( resultSet.getObject(4));
|
||||
String dataType = String.valueOf( resultSet.getObject(5));
|
||||
String columnType = String.valueOf( resultSet.getObject(6));
|
||||
String characterMaximumLength = String.valueOf(resultSet.getInt(7));
|
||||
String NumericScale = String.valueOf(resultSet.getInt(8));
|
||||
String isNullable = (String) resultSet.getObject(9);
|
||||
String columnDefault = (String) resultSet.getObject(10);
|
||||
String isNullable = String.valueOf( resultSet.getObject(9));
|
||||
String columnDefault = String.valueOf( resultSet.getObject(10));
|
||||
|
||||
Structure build = Structure.builder()
|
||||
.tableId(table.getId())
|
||||
|
@ -252,6 +252,10 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据接入接口数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List getDataByEtl() {
|
||||
List<BasicConfigInfo> list = this.list();
|
||||
|
@ -294,4 +298,32 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
|||
}
|
||||
return mapList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取响应体对象
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<TableTreeResp> getTableTree() {
|
||||
List<TableTreeResp> tableTreeRespList = tableInfoService.selectTableInfoList(new TableInfo(){{setParentId(0L);}}).stream().map(tableInfo ->{
|
||||
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
|
||||
List<TableInfo> tableInfoList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
||||
setParentId(tableInfo.getId());
|
||||
}});
|
||||
return TableTreeResp.builder()
|
||||
.tableInfo(tableInfo)
|
||||
.basicConfigInfo(basicConfigInfo)
|
||||
.Children(tableInfoList)
|
||||
.build();
|
||||
}).collect(Collectors.toList());
|
||||
return tableTreeRespList;
|
||||
}
|
||||
//{
|
||||
// label: '一级 1',
|
||||
// children: [{
|
||||
// label: '二级 1-1',
|
||||
// data
|
||||
// }]
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectTableInfoVo">
|
||||
select id, parent_id, table_name, table_remark, data_num, center, remark, create_by, create_time, update_by, update_time from table_info
|
||||
select id, parent_id, basic_id,table_name, table_remark, data_num, center, remark, create_by, create_time, update_by, update_time from table_info
|
||||
</sql>
|
||||
|
||||
<select id="selectTableInfoList" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
|
||||
|
|
Loading…
Reference in New Issue