Compare commits

...

8 Commits

47 changed files with 2967 additions and 16 deletions

View File

@ -14,12 +14,13 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: etl

View File

@ -14,26 +14,27 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: etl
sentinel:
# 取消控制台懒加载
eager: true
transport:
# 控制台地址
dashboard: 139.224.67.14:8718
dashboard: 175.24.138.82:8718
# nacos配置持久化
datasource:
ds1:
nacos:
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
dataId: sentinel-muyu-gateway
groupId: DEFAULT_GROUP
data-type: json

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-etl-common</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,42 @@
package com.muyu.etl.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* asset_data_dict
*
* @author xiaohuang
* @date 2024-04-28
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class AssetDataDict extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/** 数据接入id */
@Excel(name = "数据接入id")
private Long basicId;
/** 字典名称 */
@Excel(name = "字典名称")
private String dictName;
/** 字典类型 */
@Excel(name = "字典类型")
private String dictType;
}

View File

@ -0,0 +1,89 @@
package com.muyu.etl.domain;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* AssetImpower
*
* @author xiaohuang
* on 2024/4/28
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class AssetImpower {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
/**
* Id
*/
@Excel(name = "表id")
private Long tableId;
/**
* id
*/
@Excel(name = "用户id")
private Long userId;
public void setId(Long id){
this.id = id;
}
public Long getId(){
return id;
}
public void setTableId(Long tableId){
this.tableId = tableId;
}
public Long getTableId(){
return tableId;
}
public Long getTypeId(){
return typeId;
}
public void setTypeId(Long typeId){
this.typeId = typeId;
}
public void setUserId(Long userId){
this.userId = userId;
}
public Long getUserId(){
return userId;
}
@Override
public String toString(){
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id",getId())
.append("tableId",getTableId())
.append("typeId",getTypeId())
.append("userId",getUserId())
.append("remark",getRemark())
.append("creeteTime",getCreateTime())
.append("updateBy",getUpdateBy())
.append("updateTime",getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,125 @@
package com.muyu.etl.domain;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.etl.domain.req.BasicConfigQueryReq;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
import java.util.function.Supplier;
/**
* basic_config_info
*
* @author xiaohuang
* @date 2024-04-21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class BasicConfigInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 接入源名称 */
@Excel(name = "接入源名称")
private String dataResourceName;
/** 数据来源系统名称 */
@Excel(name = "数据来源系统名称")
private String dataSourcesSystemName;
/** 主机ip地址 */
@Excel(name = "主机ip地址")
private String host;
/** 端口 */
@Excel(name = "端口")
private String port;
/** 数据接入类型 */
@Excel(name = "数据接入类型")
private String databaseType;
/** 数据库名称 */
@Excel(name = "数据库名称")
private String databaseName;
/** 初始化连接数量 */
@Excel(name = "初始化连接数量")
private Long initLinkNum;
/** 最大连接数量 */
@Excel(name = "最大连接数量")
private Long maxLinkNum;
/** 最大等待时间 */
@Excel(name = "最大等待时间")
private Long maxWaitTime;
/** 最大等待次数 */
@Excel(name = "最大等待次数")
private Long maxWaitTimes;
@Excel(name = "连接参数")
private String connectionParams;
@Excel(name = "用户名")
private String username;
@Excel(name = "密码")
private String password;
private String createBy;
private String updateBy;
private Date createTime;
private Date updateTime;
/**
*
*/
public static BasicConfigInfo saveBuilder(BasicConfigQueryReq configQueryReq, Supplier<String> username) {
return BasicConfigInfo.builder()
.id(configQueryReq.getId())
.databaseName(configQueryReq.getDatabaseName())
.databaseType(configQueryReq.getDatabaseType())
.dataResourceName(configQueryReq.getDataResourceName())
.dataSourcesSystemName(configQueryReq.getDataSourcesSystemName())
.host(configQueryReq.getHost())
.port(configQueryReq.getPort())
.initLinkNum(configQueryReq.getInitLinkNum())
.maxLinkNum(configQueryReq.getMaxLinkNum())
.maxWaitTime(configQueryReq.getMaxWaitTime())
.createBy(username.get())
.createTime(new Date())
.build();
}
/**
*
*/
public static BasicConfigInfo editBuilder(BasicConfigQueryReq configQueryReq, Supplier<String> username) {
return BasicConfigInfo.builder()
.id(configQueryReq.getId())
.databaseName(configQueryReq.getDatabaseName())
.databaseType(configQueryReq.getDatabaseType())
.dataResourceName(configQueryReq.getDataResourceName())
.dataSourcesSystemName(configQueryReq.getDataSourcesSystemName())
.host(configQueryReq.getHost())
.port(configQueryReq.getPort())
.initLinkNum(configQueryReq.getInitLinkNum())
.maxLinkNum(configQueryReq.getMaxLinkNum())
.maxWaitTime(configQueryReq.getMaxWaitTime())
.updateBy(username.get())
.updateTime(new Date())
.build();
}
}

View File

@ -0,0 +1,60 @@
package com.muyu.etl.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.math.BigInteger;
/**
* DictInfo
*
* @author xiaohuang
* on 2024/4/26
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@SuperBuilder
public class DictInfo extends BaseEntity {
private static final long serialVersiom = 1L;
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private BigInteger id;
@Excel(name = "字典id")
private BigInteger dictId;
/**
*
*/
@Excel(name = "字典名称")
private String infoName;
/**
*
*/
@Excel(name = "字典类型")
private String infoValue;
/**
*
*/
@JsonProperty("isEdit")
private String isEdit;
}

View File

@ -0,0 +1,79 @@
package com.muyu.etl.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Structure
*
* @author xiaohuang
* on 2024/4/22
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
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;
}

View File

@ -0,0 +1,55 @@
package com.muyu.etl.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.TreeEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* TableInfo
*
* @author xiaohuang
* on 2024/4/22
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class TableInfo extends TreeEntity {
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 Long dataNum;
/** 是否核心 'Y'是 'N'不是 */
@Excel(name = "是否核心 'Y'是 'N'不是")
private String center;
private Long parentId;
}

View File

@ -0,0 +1,75 @@
package com.muyu.etl.domain.req;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
/**
* BasicConfigQueryReq
*
* @author xiaohuang
* on 2024/4/21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class BasicConfigQueryReq {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 接入源名称 */
@Excel(name = "接入源名称")
private String dataResourceName;
/** 数据来源系统名称 */
@Excel(name = "数据来源系统名称")
private String dataSourcesSystemName;
/** 主机ip地址 */
@Excel(name = "主机ip地址")
private String host;
/** 端口 */
@Excel(name = "端口")
private String port;
/** 数据接入类型 */
@Excel(name = "数据接入类型")
private String databaseType;
/** 数据库名称 */
@Excel(name = "数据库名称")
private String databaseName;
/** 初始化连接数量 */
@Excel(name = "初始化连接数量")
private Long initLinkNum;
/** 最大连接数量 */
@Excel(name = "最大连接数量")
private Long maxLinkNum;
/** 最大等待时间 */
@Excel(name = "最大等待时间")
private Long maxWaitTime;
/** 最大等待次数 */
@Excel(name = "最大等待次数")
private Long maxWaitTimes;
private String connectionParams;
private String createBy;
private String updateBy;
private Date createTime;
private Date updateTime;
}

View File

@ -0,0 +1,64 @@
package com.muyu.etl.domain.resp;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
/**
*
* @ClassName BasicConfigResp
* @Description
* @Author SaiSai.Liu
* @Date 2024/4/21 10:45
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class BasicConfigResp {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 接入源名称 */
private String dataResourceName;
/** 数据来源系统名称 */
private String dataSourcesSystemName;
/** 主机ip地址 */
private String host;
/** 端口 */
private String port;
/** 数据接入类型 */
private String databaseType;
/** 数据库名称 */
private String databaseName;
/** 初始化连接数量 */
private Long initLinkNum;
/** 最大连接数量 */
private Long maxLinkNum;
/** 最大等待时间 */
private Long maxWaitTime;
/** 最大等待次数 */
private Long maxWaitTimes;
/** 拼接链接 */
private String connectionParams;
private String remark;
private String createBy;
private String updateBy;
private Date createTime;
private Date updateTime;
}

View File

@ -0,0 +1,40 @@
package com.muyu.etl.domain.resp;
import com.muyu.etl.domain.DictInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
*
* @ClassName BasicDictResp
* @Description
* @Author SaiSai.Liu
* @Date 2024/4/24 21:23
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class BasicDictResp {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 数据接入id */
private Long basicId;
/** 字典名称 */
private String dictName;
/** 字典类型 */
private String dictType;
private List<DictInfo> dictInfoList;
}

View File

@ -0,0 +1,68 @@
package com.muyu.etl.domain.resp;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.etl.domain.Structure;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* TableInfoStructureResp
*
* @author xiaohuang
* on 2024/4/23
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class TableInfoStructureResp {
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;
private Long parentId;
/**
*
*/
@Excel(name = "数据量")
private Long dataNum;
/**
* 'Y' 'N'
*/
@Excel(name = "是否核心 'Y'是 'N'不是")
private String center;
private String databaseType;
private List<Structure> structureList;
}

View File

@ -0,0 +1,47 @@
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;
/**
* TableTreeResp
*
* @author xiaohuang
* on 2024/4/23
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class TableTreeResp {
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
*
*/
private TableInfo tableInfo;
/**
*
*/
private BasicConfigInfo basicConfigInfo;
/**
*
*/
private List<TableInfoStructureResp> Children;
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-etl-remote</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,7 @@
package com.muyu;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,7 @@
package muyu;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-etl-service</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-common</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-log</artifactId>
</dependency>
<!-- MuYu Common Swagger -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package com.muyu;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
public class MuYuEtlApplication {
public static void main(String[] args) {
SpringApplication.run(MuYuEtlApplication.class);
}
}

View File

@ -0,0 +1,185 @@
package com.muyu.etl.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
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.AssetDataDict;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.DictInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.resp.BasicDictResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import com.muyu.etl.service.AssetDataDictService;
import com.muyu.etl.service.BasicConfigInfoService;
import com.muyu.etl.service.DictInfoService;
import com.muyu.etl.service.StructureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author muyu
* @date 2024-04-21
*/
@RestController
@RequestMapping("/info")
public class BasicConfigInfoController extends BaseController {
@Autowired
private BasicConfigInfoService basicConfigInfoService;
@Autowired
private AssetDataDictService assetDataDictService;
@Autowired
private DictInfoService dictInfoService;
@Autowired
private StructureService structureService;
/**
*
*/
@RequiresPermissions("etl:info:list")
@GetMapping("/list")
public Result<TableDataInfo<BasicConfigInfo>> list(BasicConfigInfo basicConfigInfo) {
startPage();
List<BasicConfigInfo> list = basicConfigInfoService.selectBasicConfigInfoList(basicConfigInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("etl:info:export")
@Log(title = "基础信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BasicConfigInfo basicConfigInfo) {
List<BasicConfigInfo> list = basicConfigInfoService.selectBasicConfigInfoList(basicConfigInfo);
ExcelUtil<BasicConfigInfo> util = new ExcelUtil<>(BasicConfigInfo.class);
util.exportExcel(response, list, "基础信息数据");
}
/**
*
*/
@RequiresPermissions("etl:info:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) {
return success(basicConfigInfoService.selectBasicConfigInfoById(id));
}
/**
*
*/
@RequiresPermissions("etl:info:add")
@Log(title = "基础信息", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody BasicConfigInfo configQueryReq) {
return toAjax(basicConfigInfoService.insertBasicConfigInfo(configQueryReq));
}
/**
*
*/
@RequiresPermissions("etl:info:edit")
@Log(title = "基础信息", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody BasicConfigInfo basicConfigInfo) {
return toAjax(basicConfigInfoService.updateBasicConfigInfo(basicConfigInfo));
}
/**
*
*/
@RequiresPermissions("etl:info:remove")
@Log(title = "基础信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) {
return toAjax(basicConfigInfoService.deleteBasicConfigInfoByIds(ids));
}
/**
*
*/
@RequiresPermissions("etl:info:test")
@Log(title = "测试连接")
@PostMapping("/connectionTest")
public Result connectionTest(@RequestBody BasicConfigInfo basicConfigInfo) throws ServletException {
return toAjax(basicConfigInfoService.connectionTest(basicConfigInfo));
}
/**
*
* @return
*/
@RequiresPermissions("etl:info:test")
@Log(title = "获取成功链接中的")
@GetMapping("/dataConstruct")
public Result<TableDataInfo<List>> getData() {
return getDataTable(basicConfigInfoService.getDataByEtl());
}
/**
*
*
* @return
*/
@RequiresPermissions("etl:table:list")
@Log(title = "获取已成功链接的树级结构")
@GetMapping("/getTableTree")
public Result<List<TableTreeResp>> getTableTree() {
return Result.success(basicConfigInfoService.getTableTree());
}
/**
* id
*
* @return
*/
@RequiresPermissions("etl:table:dictList")
@Log(title = "描述")
@GetMapping("/getDict/{basicId}")
public Result<List<BasicDictResp>> getDict(@PathVariable Long basicId) {
return Result.success(assetDataDictService.getDict(basicId));
}
/**
*
* @param assetDataDict
* @return
*/
@RequiresPermissions("etl:table:list")
@Log(title = "添加字典内容")
@PostMapping("/insertDict")
public Result insertDictInfo(@RequestBody AssetDataDict assetDataDict) throws ServletException {
return Result.success(assetDataDictService.insertAssetDataDict(assetDataDict));
}
/**
*
* @return
*/
@RequiresPermissions("etl:table:add")
@Log(title = "添加字典表")
@PostMapping("/insertDictInfo")
public Result insertDict(@RequestBody DictInfo dictInfo) throws ServletException {
return Result.success(dictInfoService.insertDictInfo(dictInfo));
}
/**
*
* @return
*/
@RequiresPermissions("etl:table:update")
@Log(title = "修改资产结构中字典信息")
@PutMapping("/updateStructureInfo")
public Result updateStructureInfo(@RequestBody Structure structure){
return Result.success(structureService.updateStructure(structure),"修改成功");
}
}

View File

@ -0,0 +1,63 @@
package com.muyu.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.etl.domain.AssetDataDict;
import java.util.List;
/**
* Mapper
*
* @author Saisai
* @date 2024-04-24
*/
public interface AssetDataDictMapper extends BaseMapper<AssetDataDict>
{
/**
*
*
* @param id
* @return
*/
public AssetDataDict selectAssetDataDictById(Long id);
/**
*
*
* @param assetDataDict
* @return
*/
public List<AssetDataDict> selectAssetDataDictList(AssetDataDict assetDataDict);
/**
*
*
* @param assetDataDict
* @return
*/
public int insertAssetDataDict(AssetDataDict assetDataDict);
/**
*
*
* @param assetDataDict
* @return
*/
public int updateAssetDataDict(AssetDataDict assetDataDict);
/**
*
*
* @param id
* @return
*/
public int deleteAssetDataDictById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteAssetDataDictByIds(Long[] ids);
}

View File

@ -0,0 +1,56 @@
package com.muyu.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.etl.domain.BasicConfigInfo;
import java.util.List;
/**
* BasicConfigInfoMapper
*
* @author xiaohuang
* on 2024/4/21
*/
public interface BasicConfigInfoMapper extends BaseMapper<BasicConfigInfo> {
/**
*
*/
public BasicConfigInfo selectBasicConfigInfoById(Long id);
/**
*
* @param basicConfigInfo
* @return
*/
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo);
/**
*
* @param basicConfigInfo
* @return
*/
public int insertBasicConfigInfo(BasicConfigInfo basicConfigInfo);
/**
*
* @param basicConfigInfo
* @return
*/
public int updateBasicConfigInfo(BasicConfigInfo basicConfigInfo);
/**
*
* @param id
* @return
*/
public int deleteBasicConfigInfoById(Long id);
/**
*
* @param ids
* @return
*/
public int deleteBasicConfigInfoByIds(Long[] ids);
}

View File

@ -0,0 +1,63 @@
package com.muyu.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.etl.domain.DictInfo;
import java.util.List;
/**
* Mapper
*
* @author Saisai
* @date 2024-04-24
*/
public interface DictInfoMapper extends BaseMapper<DictInfo>
{
/**
*
*
* @param id
* @return
*/
public DictInfo selectDictInfoById(Long id);
/**
*
*
* @param dictInfo
* @return
*/
public List<DictInfo> selectDictInfoList(DictInfo dictInfo);
/**
*
*
* @param dictInfo
* @return
*/
public int insertDictInfo(DictInfo dictInfo);
/**
*
*
* @param dictInfo
* @return
*/
public int updateDictInfo(DictInfo dictInfo);
/**
*
*
* @param id
* @return
*/
public int deleteDictInfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteDictInfoByIds(Long[] ids);
}

View File

@ -0,0 +1,52 @@
package com.muyu.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.etl.domain.Structure;
import java.util.List;
/**
* StructureMapper
*
* @author xiaohuang
* on 2024/4/22
*/
public interface StructureMapper extends BaseMapper<Structure> {
/**
*
*/
public Structure selectStructureById(Long id);
/**
*
*/
public List<Structure> selectStructureList(Structure structure);
/**
*
*/
public int insertStructure(Structure structure);
/**
*
* @param structure
* @return
*/
public int updateStructure(Structure structure);
/**
*
*/
public int deleteStructureById(Long id);
/**
*
*/
public int deleteStructureByIds(Long[] ids);
}

View File

@ -0,0 +1,66 @@
package com.muyu.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.etl.domain.TableInfo;
import java.util.List;
/**
* TableInfoMapper
*
* @author xiaohuang
* on 2024/4/22
*/
public interface TableInfoMapper extends BaseMapper<TableInfo> {
/**
*
*
* @param id
* @return
*/
public TableInfo selectTableInfoById(Long id);
/**
*
*
* @param tableInfo
* @return
*/
public List<TableInfo> selectTableInfoList(TableInfo tableInfo);
/**
*
*
* @param tableInfo
* @return
*/
public int insertTableInfo(TableInfo tableInfo);
/**
*
*
* @param tableInfo
* @return
*/
public int updateTableInfo(TableInfo tableInfo);
/**
*
*
* @param id
* @return
*/
public int deleteTableInfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteTableInfoByIds(Long[] ids);
TableInfo selectTableInfoByName(TableInfo table);
}

View File

@ -0,0 +1,68 @@
package com.muyu.etl.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.AssetDataDict;
import com.muyu.etl.domain.resp.BasicDictResp;
import javax.servlet.ServletException;
/**
* Service
*
* @author Saisai
* @date 2024-04-24
*/
public interface AssetDataDictService extends IService<AssetDataDict>
{
/**
*
*
* @param id
* @return
*/
public AssetDataDict selectAssetDataDictById(Long id);
/**
*
*
* @param assetDataDict
* @return
*/
public List<AssetDataDict> selectAssetDataDictList(AssetDataDict assetDataDict);
/**
*
*
* @param assetDataDict
* @return
*/
public boolean insertAssetDataDict(AssetDataDict assetDataDict) throws ServletException;
/**
*
*
* @param assetDataDict
* @return
*/
public int updateAssetDataDict(AssetDataDict assetDataDict);
/**
*
*
* @param ids
* @return
*/
public int deleteAssetDataDictByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteAssetDataDictById(Long id);
List<BasicDictResp> getDict(Long basicId);
}

View File

@ -0,0 +1,71 @@
package com.muyu.etl.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.resp.TableTreeResp;
import javax.servlet.ServletException;
import java.util.List;
/**
* Service
*
* @author muyu
* @date 2024-04-20
*/
public interface BasicConfigInfoService extends IService<BasicConfigInfo>
{
/**
*
*
* @param id
* @return
*/
public BasicConfigInfo selectBasicConfigInfoById(Long id);
/**
*
*
* @param basicConfigInfo
* @return
*/
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo);
/**
*
*
* @param configQueryReq
* @return
*/
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq);
/**
*
*
* @param basicConfigInfo
* @return
*/
public int updateBasicConfigInfo(BasicConfigInfo basicConfigInfo);
/**
*
*
* @param ids
* @return
*/
public int deleteBasicConfigInfoByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteBasicConfigInfoById(Long id);
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
List getDataByEtl();
List<TableTreeResp> getTableTree();
}

View File

@ -0,0 +1,65 @@
package com.muyu.etl.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.DictInfo;
import javax.servlet.ServletException;
import java.util.List;
/**
* Service
*
* @author xiaohuang
* @date 2024-04-28
*/
public interface DictInfoService extends IService<DictInfo>
{
/**
*
*
* @param id
* @return
*/
public DictInfo selectDictInfoById(Long id);
/**
*
*
* @param dictInfo
* @return
*/
public List<DictInfo> selectDictInfoList(DictInfo dictInfo);
/**
*
*
* @param dictInfo
* @return
*/
public boolean insertDictInfo(DictInfo dictInfo)
throws ServletException;
/**
*
*
* @param dictInfo
* @return
*/
public int updateDictInfo(DictInfo dictInfo);
/**
*
*
* @param ids
* @return
*/
public int deleteDictInfoByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteDictInfoById(Long id);
}

View File

@ -0,0 +1,63 @@
package com.muyu.etl.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.Structure;
import java.util.List;
/**
* StructureService
*
* @author xiaohuang
* on 2024/4/22
*/
public interface StructureService extends IService<Structure> {
/**
*
*
* @param id
* @return
*/
public Structure selectStructureById(Long id);
/**
*
*
* @param structure
* @return
*/
public List<Structure> selectStructureList(Structure structure);
/**
*
*
* @param structure
* @return
*/
public int insertStructure(Structure structure);
/**
*
*
* @param structure
* @return
*/
public int updateStructure(Structure structure);
/**
*
*
* @param ids
* @return
*/
public int deleteStructureByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteStructureById(Long id);
}

View File

@ -0,0 +1,67 @@
package com.muyu.etl.service;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.muyu.etl.domain.TableInfo;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* TableInfoService
*
* @author xiaohuang
* on 2024/4/22
*/
public interface TableInfoService extends IService<TableInfo> {
/**
*
*
* @param id
* @return
*/
public TableInfo selectTableInfoById(Long id);
/**
*
*
* @param tableInfo
* @return
*/
public List<TableInfo> selectTableInfoList(TableInfo tableInfo);
/**
*
*
* @param tableInfo
* @return
*/
public int insertTableInfo(TableInfo tableInfo);
/**
*
*
* @param tableInfo
* @return
*/
public int updateTableInfo(TableInfo tableInfo);
/**
*
*
* @param ids
* @return
*/
public int deleteTableInfoByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteTableInfoById(Long id);
TableInfo selectTableInfoByName(TableInfo build);
}

View File

@ -0,0 +1,136 @@
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.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.etl.domain.AssetDataDict;
import com.muyu.etl.domain.DictInfo;
import com.muyu.etl.domain.resp.BasicDictResp;
import com.muyu.etl.mapper.AssetDataDictMapper;
import com.muyu.etl.service.AssetDataDictService;
import com.muyu.etl.service.DictInfoService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.ServletException;
import java.util.List;
import java.util.stream.Collectors;
/**
* Service
*
* @author Saisai
* @date 2024-04-24
*/
@Service
@Log4j2
public class AssetDataDictServiceImpl extends ServiceImpl<AssetDataDictMapper, AssetDataDict> implements AssetDataDictService {
@Autowired
private AssetDataDictMapper assetDataDictMapper;
@Autowired
private DictInfoService dictInfoService;
/**
*
*
* @param id
* @return
*/
@Override
public AssetDataDict selectAssetDataDictById(Long id) {
return assetDataDictMapper.selectAssetDataDictById(id);
}
/**
*
*
* @param assetDataDict
* @return
*/
@Override
public List<AssetDataDict> selectAssetDataDictList(AssetDataDict assetDataDict) {
return assetDataDictMapper.selectAssetDataDictList(assetDataDict);
}
/**
*
*
* @param assetDataDict
* @return
*/
@Override
public boolean insertAssetDataDict(AssetDataDict assetDataDict) throws ServletException {
assetDataDict.setCreateTime(DateUtils.getNowDate());
AssetDataDict one = this.getOne(new LambdaQueryWrapper<AssetDataDict>(AssetDataDict.class) {{
eq(AssetDataDict::getDictType, assetDataDict.getDictType());
eq(AssetDataDict::getBasicId, assetDataDict.getBasicId());
}});
if (one!=null){
throw new ServletException("该字典已存在");
}
boolean b = this.saveOrUpdate(assetDataDict, new LambdaUpdateWrapper<AssetDataDict>(AssetDataDict.class) {{
eq(AssetDataDict::getDictType,assetDataDict.getDictType());
eq(AssetDataDict::getBasicId,assetDataDict.getBasicId());
}});
return b;
}
/**
*
*
* @param assetDataDict
* @return
*/
@Override
public int updateAssetDataDict(AssetDataDict assetDataDict) {
assetDataDict.setUpdateTime(DateUtils.getNowDate());
return assetDataDictMapper.updateAssetDataDict(assetDataDict);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteAssetDataDictByIds(Long[] ids) {
return assetDataDictMapper.deleteAssetDataDictByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteAssetDataDictById(Long id) {
return assetDataDictMapper.deleteAssetDataDictById(id);
}
@Override
public List<BasicDictResp> getDict(Long basicId) {
List<AssetDataDict> list = this.list(new LambdaQueryWrapper<AssetDataDict>() {{
eq(AssetDataDict::getBasicId, basicId);
or(assetDataDictLambdaQueryWrapper -> assetDataDictLambdaQueryWrapper.eq(AssetDataDict::getId, 1L));
}});
List<BasicDictResp> collect = list.stream().map(assetDataDict -> {
List<DictInfo> dictInfoList = dictInfoService.list(
new LambdaQueryWrapper<DictInfo>()
.eq(DictInfo::getDictId, assetDataDict.getId()
)
);
return BasicDictResp.builder()
.id(assetDataDict.getId())
.dictType(assetDataDict.getDictType())
.dictName(assetDataDict.getDictName())
.dictInfoList(dictInfoList)
.basicId(assetDataDict.getBasicId())
.build();
}).collect(Collectors.toList());
return collect;
}
}

View File

@ -0,0 +1,337 @@
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.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.TableInfoStructureResp;
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;
import com.muyu.etl.service.TableInfoService;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.ServletException;
import java.sql.*;
import java.util.Date;
import java.util.*;
import java.util.stream.Collectors;
/**
* Service
*
* @author muyu
* @date 2024-04-20
*/
@Service
@Log4j2
public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapper, BasicConfigInfo> implements BasicConfigInfoService
{
@Autowired
private BasicConfigInfoMapper basicConfigInfoMapper;
@Autowired
private StructureService structureService;
@Autowired
private TableInfoService tableInfoService;
/**
*
*
* @param id
* @return
*/
@Override
public BasicConfigInfo selectBasicConfigInfoById(Long id)
{
return basicConfigInfoMapper.selectBasicConfigInfoById(id);
}
/**
*
*
* @param basicConfigInfo
* @return
*/
@Override
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo)
{
return basicConfigInfoMapper.selectBasicConfigInfoList(basicConfigInfo);
}
/**
*
*
* @param configQueryReq
* @return
*/
@Override
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq)
{
return basicConfigInfoMapper.insertBasicConfigInfo(configQueryReq);
}
/**
*
*
* @param configQueryReq
* @return
*/
@Override
public int updateBasicConfigInfo(BasicConfigInfo configQueryReq)
{
return basicConfigInfoMapper.updateBasicConfigInfo(configQueryReq);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteBasicConfigInfoByIds(Long[] ids)
{
return basicConfigInfoMapper.deleteBasicConfigInfoByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteBasicConfigInfoById(Long id)
{
return basicConfigInfoMapper.deleteBasicConfigInfoById(id);
}
@Override
public boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException {
//定义下面需要的对象
String host = basicConfigInfo.getHost();
String port = basicConfigInfo.getPort();
String databaseName = basicConfigInfo.getDatabaseName();
String databaseType = basicConfigInfo.getDatabaseType();
String url = "jdbc:"+databaseType.toLowerCase()+"://"+host+":"+port+"/"+databaseName+"?"+basicConfigInfo.getConnectionParams();
String user = "root";
String password = "123456";
Connection conn= null;
try {
conn = DriverManager.getConnection(url, user, password);
System.out.println("Connected to the MySQL server successfully.");
//同步数据库信息
//树级结构,库,表
TableInfo tableInfo = TableInfo.builder()
.basicId(basicConfigInfo.getId())
.parentId(0L)
.tableRemark("")
.center("Y")
.tableName(basicConfigInfo.getDataSourcesSystemName() + "(" + databaseName + ")")
.createBy(SecurityUtils.getUsername())
.createTime(new Date())
.build();
tableInfoService.saveOrUpdate(tableInfo,new LambdaUpdateWrapper<TableInfo>(TableInfo.class){{
eq(TableInfo::getTableName,tableInfo.getTableName());
eq(TableInfo::getBasicId,basicConfigInfo.getId());
}});
DatabaseMetaData metaData = conn.getMetaData();
ResultSet rs = metaData.getTables(databaseName,
null, "%", new String[]{"TABLE", "VIEW"});
while (rs.next()) {
//表名
String tableName1 = rs.getString("TABLE_NAME");
String tableRemark = rs.getString("REMARKS");
Connection finalConn = conn;
PreparedStatement ps = conn.prepareStatement("select* from " + tableName1);
ResultSet rset = ps.executeQuery();
Long rowCount = 0L;
while(rset.next()) {rowCount++;}
TableInfo build = TableInfo.builder()
.basicId(basicConfigInfo.getId())
.tableName(tableName1)
.tableRemark(tableRemark==null? "null":tableRemark)
.parentId(tableInfo.getId())
.center("Y")
.updateBy(SecurityUtils.getUsername())
.dataNum(rowCount)
.updateTime(new Date())
.build();
tableInfoService.saveOrUpdate(build,new LambdaUpdateWrapper<TableInfo>(TableInfo.class){{
eq(TableInfo::getTableName,build.getTableName());
eq(TableInfo::getBasicId,basicConfigInfo.getId());
}});
TableInfo table = tableInfoService.selectTableInfoByName(build);
Runnable thread = new Runnable() {
@SneakyThrows
@Override
public void run() {
try {
syncData(finalConn, databaseName, table);
} catch (SQLException e) {
throw new ServletException("连接失败");
}
}
};
thread.run();
}
} catch (SQLException e) {
throw new ServletException("连接失败");
}
return true;
}
public void syncData (Connection conn, String databaseName, TableInfo table) throws SQLException {
PreparedStatement ps = conn.prepareStatement(
" SELECT " +
" COLUMN_NAME AS '字段', " +
" COLUMN_COMMENT AS '字段注释', " +
" CASE WHEN COLUMN_KEY = 'PRI' THEN '是' ELSE '否' END AS '是否主键'," +
" CASE \n" +
" WHEN DATA_TYPE = 'int' THEN 'Integer' " +
" WHEN DATA_TYPE = 'bigint' THEN 'Long' " +
" WHEN DATA_TYPE = 'varchar' THEN 'String' " +
" WHEN DATA_TYPE = 'decimal' THEN 'BigDecimal' " +
" WHEN DATA_TYPE = 'tinyint' AND COLUMN_TYPE = 'tinyint(1)' THEN 'Boolean'" +
" ELSE DATA_TYPE -- 如果无法映射,则返回原始数据库类型 \n" +
" END AS 'Java类型', " +
" DATA_TYPE AS '数据库类型', -- 原始的数据库类型 \n" +
" COLUMN_TYPE AS '详细的数据库类型', -- 更详细的数据库类型,可能包含长度、精度等 \n" +
" CHARACTER_MAXIMUM_LENGTH AS '长度', \n" +
" NUMERIC_SCALE AS '小数位', \n" +
" IS_NULLABLE AS '是否为空', \n" +
" COLUMN_DEFAULT AS '默认值' \n" +
"FROM INFORMATION_SCHEMA.COLUMNS WHERE \n" +
"TABLE_SCHEMA = '" + databaseName + "' -- 替换为你的数据库名称 \n" +
"AND TABLE_NAME = '" + table.getTableName() + "'");
// "SELECT COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_KEY,COLUMN_DEFAULT,
// COLUMN_COMMENT,CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION,
// NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS
// WHERE TABLE_SCHEMA = '数据库名' AND TABLE_NAME = '表名'"
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()){
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.valueOf( resultSet.getObject(9));
String columnDefault = String.valueOf( resultSet.getObject(10));
Structure build = Structure.builder()
.tableId(table.getId())
.columnName(String.valueOf(columnName))
.columnRemark(columnComment)
.isPrimary("是".equals(columnKey) ? "Y" : "N")
.javaType( end)
.columnType( dataType)
.columnType(columnType)
.columnLength(characterMaximumLength)
.columnDecimals( NumericScale)
.isNull("YES".equals(isNullable) ? "Y" : "N")
.defaultValue( columnDefault)
.build();
structureService.saveOrUpdate(build,new LambdaUpdateWrapper<Structure>(){{
eq(Structure::getTableId,build.getTableId());
eq(Structure::getColumnName,build.getColumnName());
eq(Structure::getColumnRemark,build.getColumnRemark());
}});
}
}
/**
*
* @return
*/
@Override
public List getDataByEtl() {
List<BasicConfigInfo> list = this.list();
List<Map<String,List<String>>> mapList = new ArrayList<>();
for (BasicConfigInfo info : list) {
//定义下面需要的对象
String url = "jdbc:" + info.getDatabaseType() + "://" + info.getHost() + ":" + info.getPort() + "/" + info.getDatabaseName() + "";
String user = info.getUsername();
String password = info.getPassword();
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
DatabaseMetaData metaData = conn.getMetaData();
ResultSet resultSet = metaData.getCatalogs();
while (resultSet.next()){
//库名
String catalogs = resultSet.getString("TABLE_CAT");
log.info(catalogs);
// 获取表名
ResultSet rs = metaData.getTables(info.getDatabaseName(),null, "%", new String[]{"TABLE", "VIEW"});
try {
ArrayList<String> tableName = new ArrayList<>();
while (rs.next()) {
//表名
String tableName1 = rs.getString("TABLE_NAME");
tableName.add( rs.getString("TABLE_NAME"));
}
mapList.add(new HashMap<>(){{
//库名,表名
put(catalogs,tableName);
}});
}catch (Exception exception){
continue;
}
}
} catch (Exception e){
log.error(e.getMessage());
continue;
}
}
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<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
setParentId(tableInfo.getId());
}}).stream().map(info -> {
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>().eq(Structure::getTableId,info.getId()));
return TableInfoStructureResp.builder()
.id(info.getId())
.tableName(info.getTableName())
.center(info.getCenter())
.tableRemark(info.getTableRemark())
.dataNum(info.getDataNum())
.parentId(info.getParentId())
.databaseType(basicConfigInfo.getDatabaseType())
.structureList(structureList)
.basicId(info.getBasicId())
.build();
}).collect(Collectors.toList());
return TableTreeResp.builder()
.tableInfo(tableInfo)
.basicConfigInfo(basicConfigInfo)
.Children(tableInfoStructureRespList)
.build();
}).collect(Collectors.toList());
return tableTreeRespList;
}
}

View File

@ -0,0 +1,109 @@
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.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.etl.domain.DictInfo;
import com.muyu.etl.mapper.DictInfoMapper;
import com.muyu.etl.service.DictInfoService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.ServletException;
import java.util.List;
/**
* Service
*
* @author Saisai
* @date 2024-04-24
*/
@Log4j2
@Service
public class DictInfoServiceImpl extends ServiceImpl<DictInfoMapper, DictInfo> implements DictInfoService {
@Autowired
private DictInfoMapper dictInfoMapper;
/**
*
*
* @param id
* @return
*/
@Override
public DictInfo selectDictInfoById(Long id) {
return dictInfoMapper.selectDictInfoById(id);
}
/**
*
*
* @param dictInfo
* @return
*/
@Override
public List<DictInfo> selectDictInfoList(DictInfo dictInfo) {
return dictInfoMapper.selectDictInfoList(dictInfo);
}
/**
*
*
* @param dictInfo
* @return
*/
@Override
public boolean insertDictInfo(DictInfo dictInfo) throws ServletException {
dictInfo.setCreateTime(DateUtils.getNowDate());
DictInfo one = this.getOne(new LambdaQueryWrapper<DictInfo>() {{
eq(DictInfo::getDictId, dictInfo.getDictId());
eq(DictInfo::getInfoName, dictInfo.getInfoName());
eq(DictInfo::getInfoValue, dictInfo.getInfoValue());
}});
if (one!=null){
throw new ServletException("该字典内容已存在");
}
boolean b = this.saveOrUpdate(dictInfo, new LambdaUpdateWrapper<DictInfo>(DictInfo.class) {{
eq(DictInfo::getDictId, dictInfo.getDictId());
eq(DictInfo::getInfoName, dictInfo.getInfoName());
eq(DictInfo::getInfoValue, dictInfo.getInfoValue());
}});
return b;
}
/**
*
*
* @param dictInfo
* @return
*/
@Override
public int updateDictInfo(DictInfo dictInfo) {
dictInfo.setUpdateTime(DateUtils.getNowDate());
return dictInfoMapper.updateDictInfo(dictInfo);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteDictInfoByIds(Long[] ids) {
return dictInfoMapper.deleteDictInfoByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteDictInfoById(Long id) {
return dictInfoMapper.deleteDictInfoById(id);
}
}

View File

@ -0,0 +1,80 @@
package com.muyu.etl.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.mapper.StructureMapper;
import com.muyu.etl.service.StructureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* StructureServiceImpl
*
* @author xiaohuang
* on 2024/4/22
*/
@Service
public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure> implements StructureService {
@Autowired
private StructureMapper structureMapper;
/**
*
*/
@Override
public Structure selectStructureById(Long id){
return structureMapper.selectStructureById(id);
}
/**
*
*/
@Override
public List<Structure> selectStructureList(Structure structure){
return structureMapper.selectStructureList(structure);
}
/**
*
*/
@Override
public int insertStructure(Structure structure){
structure.setCreateTime(DateUtils.getNowDate());
return structureMapper.insertStructure(structure);
}
/**
*
*/
@Override
public int updateStructure(Structure structure){
structure.setUpdateTime(DateUtils.getNowDate());
return structureMapper.updateStructure(structure);
}
/**
*
*/
@Override
public int deleteStructureByIds(Long[] ids){
return structureMapper.deleteStructureByIds(ids);
}
/**
*
*/
@Override
public int deleteStructureById(Long id){
return structureMapper.deleteStructureById(id);
}
}

View File

@ -0,0 +1,88 @@
package com.muyu.etl.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.mapper.TableInfoMapper;
import com.muyu.etl.service.TableInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* TableInfoServiceImpl
*
* @author xiaohuang
* on 2024/4/22
*/
@Service
public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> implements TableInfoService {
@Autowired
private TableInfoMapper tableInfoMapper;
/**
*
*/
@Override
public TableInfo selectTableInfoById(Long id)
{
return tableInfoMapper.selectTableInfoById(id);
}
/**
*
*/
@Override
public List<TableInfo> selectTableInfoList(TableInfo tableInfo)
{
return tableInfoMapper.selectTableInfoList(tableInfo);
}
/**
*
* @param tableInfo
* @return
*/
@Override
public int insertTableInfo(TableInfo tableInfo){
return tableInfoMapper.insertTableInfo(tableInfo);
}
/**
*
* @param tableInfo
* @return
*/
@Override
public int updateTableInfo(TableInfo tableInfo){
return tableInfoMapper.updateTableInfo(tableInfo);
}
/**
*
*/
@Override
public int deleteTableInfoByIds(Long[] ids){
return tableInfoMapper.deleteTableInfoByIds(ids);
}
/**
*
*/
@Override
public int deleteTableInfoById(Long id){
return tableInfoMapper.deleteTableInfoById(id);
}
@Override
public TableInfo selectTableInfoByName(TableInfo table){
return tableInfoMapper.selectTableInfoByName(table);
}
}

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 9205
# Spring
spring:
application:
# 应用名称
name: muyu-etl
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 175.24.138.82:8848
namespace: etl
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.system.mapper: DEBUG

View File

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.etl.mapper.BasicConfigInfoMapper">
<resultMap type="com.muyu.etl.domain.BasicConfigInfo" id="BasicConfigInfoResult">
<result property="id" column="id" />
<result property="dataResourceName" column="data_resource_name" />
<result property="dataSourcesSystemName" column="data_sources_system_name" />
<result property="host" column="host" />
<result property="port" column="port" />
<result property="databaseType" column="database_type" />
<result property="databaseName" column="database_name" />
<result property="initLinkNum" column="init_link_num" />
<result property="maxLinkNum" column="max_link_num" />
<result property="maxWaitTime" column="max_wait_time" />
<result property="maxWaitTimes" column="max_wait_times" />
<result property="connectionParams" column="connection_params" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectBasicConfigInfoVo">
select id, data_resource_name,username,password, data_sources_system_name, host, port, database_type, database_name, init_link_num, max_link_num, max_wait_time, max_wait_times,connection_params, remark from basic_config_info
</sql>
<select id="selectBasicConfigInfoList" parameterType="com.muyu.etl.domain.BasicConfigInfo" resultMap="BasicConfigInfoResult">
<include refid="selectBasicConfigInfoVo"/>
<where>
<if test="dataResourceName != null and dataResourceName != ''"> and data_resource_name like concat('%', #{dataResourceName}, '%')</if>
<if test="dataSourcesSystemName != null and dataSourcesSystemName != ''"> and data_sources_system_name like concat('%', #{dataSourcesSystemName}, '%')</if>
<if test="host != null and host != ''"> and host = #{host}</if>
<if test="port != null and port != ''"> and port = #{port}</if>
<if test="databaseType != null and databaseType != ''"> and database_type = #{databaseType}</if>
<if test="databaseName != null and databaseName != ''"> and database_name like concat('%', #{databaseName}, '%')</if>
<if test="username != null "> and username = #{username}</if>
<if test="password != null "> and password = #{password}</if>
<if test="initLinkNum != null "> and init_link_num = #{initLinkNum}</if>
<if test="maxLinkNum != null "> and max_link_num = #{maxLinkNum}</if>
<if test="maxWaitTime != null "> and max_wait_time = #{maxWaitTime}</if>
<if test="maxWaitTimes != null "> and max_wait_times = #{maxWaitTimes}</if>
</where>
</select>
<select id="selectBasicConfigInfoById" parameterType="Long" resultMap="BasicConfigInfoResult">
<include refid="selectBasicConfigInfoVo"/>
where id = #{id}
</select>
<insert id="insertBasicConfigInfo" parameterType="com.muyu.etl.domain.BasicConfigInfo">
insert into basic_config_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="dataResourceName != null">data_resource_name,</if>
<if test="dataSourcesSystemName != null">data_sources_system_name,</if>
<if test="host != null">host,</if>
<if test="port != null">port,</if>
<if test="databaseType != null">database_type,</if>
<if test="databaseName != null">database_name,</if>
<if test="username != null">username,</if>
<if test="password != null">password,</if>
<if test="initLinkNum != null">init_link_num,</if>
<if test="maxLinkNum != null">max_link_num,</if>
<if test="maxWaitTime != null">max_wait_time,</if>
<if test="maxWaitTimes != null">max_wait_times,</if>
<if test="connectionParams != null">connection_params,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="dataResourceName != null">#{dataResourceName},</if>
<if test="dataSourcesSystemName != null">#{dataSourcesSystemName},</if>
<if test="host != null">#{host},</if>
<if test="port != null">#{port},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="databaseType != null">#{databaseType},</if>
<if test="databaseName != null">#{databaseName},</if>
<if test="initLinkNum != null">#{initLinkNum},</if>
<if test="maxLinkNum != null">#{maxLinkNum},</if>
<if test="maxWaitTime != null">#{maxWaitTime},</if>
<if test="maxWaitTimes != null">#{maxWaitTimes},</if>
<if test="connectionParams != null">#{connectionParams},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateBasicConfigInfo" parameterType="com.muyu.etl.domain.BasicConfigInfo">
update basic_config_info
<trim prefix="SET" suffixOverrides=",">
<if test="dataResourceName != null">data_resource_name = #{dataResourceName},</if>
<if test="dataSourcesSystemName != null">data_sources_system_name = #{dataSourcesSystemName},</if>
<if test="host != null">host = #{host},</if>
<if test="port != null">port = #{port},</if>
<if test="databaseType != null">database_type = #{databaseType},</if>
<if test="databaseName != null">database_name = #{databaseName},</if>
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="initLinkNum != null">init_link_num = #{initLinkNum},</if>
<if test="maxLinkNum != null">max_link_num = #{maxLinkNum},</if>
<if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if>
<if test="maxWaitTimes != null">max_wait_times = #{maxWaitTimes},</if>
<if test="connectionParams != null">connection_params = #{connectionParams},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBasicConfigInfoById" parameterType="Long">
delete from basic_config_info where id = #{id}
</delete>
<delete id="deleteBasicConfigInfoByIds" parameterType="String">
delete from basic_config_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.etl.mapper.StructureMapper">
<resultMap type="com.muyu.etl.domain.Structure" id="StructureResult">
<result property="id" column="id" />
<result property="tableId" column="table_id" />
<result property="columnName" column="column_name" />
<result property="columnRemark" column="column_remark" />
<result property="isPrimary" column="is_primary" />
<result property="columnType" column="column_type" />
<result property="javaType" column="java_type" />
<result property="columnLength" column="column_length" />
<result property="columnDecimals" column="column_decimals" />
<result property="isNull" column="is_null" />
<result property="defaultValue" column="default_value" />
<result property="isDictionary" column="is_dictionary" />
<result property="dictionaryTable" column="dictionary_table" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectStructureVo">
select id, table_id, column_name, column_remark, is_primary, column_type, java_type, column_length, column_decimals, is_null, default_value, is_dictionary, dictionary_table, remark, create_by, create_time, update_by, update_time from structure
</sql>
<select id="selectStructureList" parameterType="com.muyu.etl.domain.Structure" resultMap="StructureResult">
<include refid="selectStructureVo"/>
<where>
<if test="tableId != null "> and table_id = #{tableId}</if>
<if test="columnName != null and columnName != ''"> and column_name like concat('%', #{columnName}, '%')</if>
<if test="columnRemark != null and columnRemark != ''"> and column_remark = #{columnRemark}</if>
<if test="isPrimary != null and isPrimary != ''"> and is_primary = #{isPrimary}</if>
<if test="columnType != null and columnType != ''"> and column_type = #{columnType}</if>
<if test="javaType != null and javaType != ''"> and java_type = #{javaType}</if>
<if test="columnLength != null and columnLength != ''"> and column_length = #{columnLength}</if>
<if test="columnDecimals != null and columnDecimals != ''"> and column_decimals = #{columnDecimals}</if>
<if test="isNull != null and isNull != ''"> and is_null = #{isNull}</if>
<if test="defaultValue != null and defaultValue != ''"> and default_value = #{defaultValue}</if>
<if test="isDictionary != null and isDictionary != ''"> and is_dictionary = #{isDictionary}</if>
<if test="dictionaryTable != null and dictionaryTable != ''"> and dictionary_table = #{dictionaryTable}</if>
</where>
</select>
<select id="selectStructureById" parameterType="Long" resultMap="StructureResult">
<include refid="selectStructureVo"/>
where id = #{id}
</select>
<insert id="insertStructure" parameterType="com.muyu.etl.domain.Structure" useGeneratedKeys="true" keyProperty="id">
insert into structure
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tableId != null">table_id,</if>
<if test="columnName != null">column_name,</if>
<if test="columnRemark != null">column_remark,</if>
<if test="isPrimary != null and isPrimary != ''">is_primary,</if>
<if test="columnType != null and columnType != ''">column_type,</if>
<if test="javaType != null and javaType != ''">java_type,</if>
<if test="columnLength != null and columnLength != ''">column_length,</if>
<if test="columnDecimals != null and columnDecimals != ''">column_decimals,</if>
<if test="isNull != null">is_null,</if>
<if test="defaultValue != null and defaultValue != ''">default_value,</if>
<if test="isDictionary != null">is_dictionary,</if>
<if test="dictionaryTable != null">dictionary_table,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tableId != null">#{tableId},</if>
<if test="columnName != null">#{columnName},</if>
<if test="columnRemark != null">#{columnRemark},</if>
<if test="isPrimary != null and isPrimary != ''">#{isPrimary},</if>
<if test="columnType != null and columnType != ''">#{columnType},</if>
<if test="javaType != null and javaType != ''">#{javaType},</if>
<if test="columnLength != null and columnLength != ''">#{columnLength},</if>
<if test="columnDecimals != null and columnDecimals != ''">#{columnDecimals},</if>
<if test="isNull != null">#{isNull},</if>
<if test="defaultValue != null and defaultValue != ''">#{defaultValue},</if>
<if test="isDictionary != null">#{isDictionary},</if>
<if test="dictionaryTable != null">#{dictionaryTable},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateStructure" parameterType="com.muyu.etl.domain.Structure">
update structure
<trim prefix="SET" suffixOverrides=",">
<if test="tableId != null">table_id = #{tableId},</if>
<if test="columnName != null">column_name = #{columnName},</if>
<if test="columnRemark != null">column_remark = #{columnRemark},</if>
<if test="isPrimary != null and isPrimary != ''">is_primary = #{isPrimary},</if>
<if test="columnType != null and columnType != ''">column_type = #{columnType},</if>
<if test="javaType != null and javaType != ''">java_type = #{javaType},</if>
<if test="columnLength != null and columnLength != ''">column_length = #{columnLength},</if>
<if test="columnDecimals != null and columnDecimals != ''">column_decimals = #{columnDecimals},</if>
<if test="isNull != null">is_null = #{isNull},</if>
<if test="defaultValue != null and defaultValue != ''">default_value = #{defaultValue},</if>
<if test="isDictionary != null">is_dictionary = #{isDictionary},</if>
<if test="dictionaryTable != null">dictionary_table = #{dictionaryTable},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteStructureById" parameterType="Long">
delete from structure where id = #{id}
</delete>
<delete id="deleteStructureByIds" parameterType="String">
delete from structure where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.etl.mapper.TableInfoMapper">
<resultMap type="com.muyu.etl.domain.TableInfo" id="TableInfoResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="basicId" column="basic_id" />
<result property="tableName" column="table_name" />
<result property="tableRemark" column="table_remark" />
<result property="dataNum" column="data_num" />
<result property="center" column="center" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTableInfoVo">
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">
<include refid="selectTableInfoVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="basicId != null "> and basic_id = #{basicId}</if>
<if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
<if test="tableRemark != null and tableRemark != ''"> and table_remark = #{tableRemark}</if>
<if test="dataNum != null "> and data_num = #{dataNum}</if>
<if test="center != null and center != ''"> and center = #{center}</if>
</where>
</select>
<select id="selectTableInfoById" parameterType="Long" resultMap="TableInfoResult">
<include refid="selectTableInfoVo"/>
where id = #{id}
</select>
<select id="selectTableInfoByName" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
select * from table_info
where basic_id = #{basicId} and table_name = #{tableName}
</select>
<insert id="insertTableInfo" parameterType="com.muyu.etl.domain.TableInfo" useGeneratedKeys="true" keyProperty="id">
insert into table_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="basicId != null">basic_id,</if>
<if test="tableName != null and tableName != ''">table_name,</if>
<if test="tableRemark != null and tableRemark != ''">table_remark,</if>
<if test="dataNum != null">data_num,</if>
<if test="center != null">center,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="basicId != null">#{basicId},</if>
<if test="tableName != null and tableName != ''">#{tableName},</if>
<if test="tableRemark != null and tableRemark != ''">#{tableRemark},</if>
<if test="dataNum != null">#{dataNum},</if>
<if test="center != null">#{center},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTableInfo" parameterType="com.muyu.etl.domain.TableInfo">
update table_info
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="basicId != null">basic_id = #{basicId},</if>
<if test="tableName != null and tableName != ''">table_name = #{tableName},</if>
<if test="tableRemark != null and tableRemark != ''">table_remark = #{tableRemark},</if>
<if test="dataNum != null">data_num = #{dataNum},</if>
<if test="center != null">center = #{center},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTableInfoById" parameterType="Long">
delete from table_info where id = #{id}
</delete>
<delete id="deleteTableInfoByIds" parameterType="String">
delete from table_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-modules</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-etl</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-etl-common</module>
<module>muyu-etl-remote</module>
<module>muyu-etl-service</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -14,12 +14,13 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: etl

View File

@ -14,12 +14,13 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: etl

View File

@ -14,12 +14,13 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: etl

View File

@ -14,15 +14,16 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: etl
logging:
level:
com.muyu.system.mapper: DEBUG

View File

@ -13,6 +13,8 @@
<module>muyu-gen</module>
<module>muyu-job</module>
<module>muyu-file</module>
<module>muyu-etl</module>
</modules>
<artifactId>muyu-modules</artifactId>

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
config:
# 配置中心地址
server-addr: 139.224.67.14:8848
server-addr: 175.24.138.82:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -206,6 +206,15 @@
<version>${muyu.version}</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-common</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</dependencyManagement>