From e6897710209459038177f064d7daef431e73ce4e Mon Sep 17 00:00:00 2001 From: Yunfei Du <278774021@qq.com> Date: Thu, 25 Apr 2024 16:55:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84(?= =?UTF-8?q?=E8=A1=A8=E7=BB=93=E6=9E=84=E5=88=86=E6=9E=90=E7=9A=84=E8=BF=87?= =?UTF-8?q?=E4=BA=8E=E5=A4=8D=E6=9D=82,=E4=BC=98=E5=8C=96=E4=BA=86?= =?UTF-8?q?=E8=A1=A8=E7=BB=93=E6=9E=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/aspect/InnerAuthAspect.java | 1 + .../java/com/etl/data/domain/AssetsModel.java | 84 ++++ .../data/{source => }/domain/DataSource.java | 78 ++-- .../DataTable.java} | 44 +- .../etl/data/{type => }/domain/DataType.java | 37 +- .../decoration/DataSourceDecoration.java | 32 ++ .../decoration/DataTableDecoration.java | 28 ++ .../etl/data/domain/model/DataSourceInfo.java | 25 ++ .../etl/data/domain/model/NameAndType.java | 22 + .../com/etl/data/domain/model/Structure.java | 20 + .../com/etl/data/domain/model/TableInfo.java | 36 ++ .../data/domain/req/DataSourceQueryReq.java | 22 + .../etl/data/domain/req/QueryTableReq.java | 27 ++ .../domain/req/TableStructureQueryReq.java | 37 ++ .../etl/data/domain/resp/AssetsModelResp.java | 31 ++ .../etl/data/domain/resp/DataSourceResp.java | 88 ++++ .../data/domain/resp/DataSourceTableResp.java | 34 ++ .../etl/data/domain/resp/DataSpliceParam.java | 21 + .../source/domain/resp/DataSourceResp.java | 147 ------ .../data/structure/domain/AssetStructure.java | 73 --- .../domain/resp/AssetStructureResp.java | 41 -- .../etl/data/ETLDataSourceApplication.java | 2 +- .../controller/AssetsModelController.java | 33 ++ .../data/controller/DataSourceController.java | 71 +++ .../data/controller/DataTypeController.java | 34 ++ .../etl/data/mapper/AssetsModelMapper.java | 13 + .../com/etl/data/mapper/DataSourceMapper.java | 13 + .../com/etl/data/mapper/DataTableMapper.java | 13 + .../com/etl/data/mapper/DataTypeMapper.java | 13 + .../etl/data/service/AssetsModelService.java | 20 + .../etl/data/service/DataSourceService.java | 31 ++ .../etl/data/service/DataTableService.java | 13 + .../com/etl/data/service/DataTypeService.java | 13 + .../service/impl/AssetsModelServiceImpl.java | 54 +++ .../service/impl/DataSourceServiceImpl.java | 407 +++++++++++++++++ .../service/impl/DataTableServiceImpl.java | 17 + .../service/impl/DataTypeServiceImpl.java | 18 + .../controller/DataSourceController.java | 115 ----- .../data/source/mapper/DataSourceMapper.java | 62 --- .../source/service/IDataSourceService.java | 76 ---- .../service/impl/DataSourceServiceImpl.java | 420 ------------------ .../controller/AssetStructureController.java | 36 -- .../AssetStructureTableController.java | 40 -- .../mapper/AssetStructureMapper.java | 14 - .../mapper/AssetStructureTableMapper.java | 14 - .../service/IAssetStructureService.java | 22 - .../service/IAssetStructureTableService.java | 23 - .../impl/AssetStructureServiceImpl.java | 55 --- .../impl/AssetStructureTableServiceImpl.java | 34 -- .../type/controller/DataTypeController.java | 91 ---- .../etl/data/type/mapper/DataTypeMapper.java | 62 --- .../data/type/service/IDataTypeService.java | 62 --- .../service/impl/DataTypeServiceImpl.java | 102 ----- .../src/main/resources/bootstrap.yml | 2 +- .../mapper/data/AssetsModelMqpper.xml | 7 + .../mapper/data/DataManagerMqpper.xml | 7 + .../mapper/data/DataSourceMapper.xml | 130 ------ .../resources/mapper/data/DataTableMqpper.xml | 7 + .../resources/mapper/data/DataTypeMapper.xml | 84 ---- .../resources/mapper/data/DataTypeMqpper.xml | 7 + .../mapper/data/DictionaryInfoMqpper.xml | 7 + .../mapper/data/DictionaryMqpper.xml | 7 + 62 files changed, 1369 insertions(+), 1810 deletions(-) create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/AssetsModel.java rename etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/{source => }/domain/DataSource.java (57%) rename etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/{structure/domain/AssetStructureTable.java => domain/DataTable.java} (50%) rename etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/{type => }/domain/DataType.java (55%) create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataSourceDecoration.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataTableDecoration.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/DataSourceInfo.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/NameAndType.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/Structure.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/TableInfo.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/DataSourceQueryReq.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/QueryTableReq.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/TableStructureQueryReq.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/AssetsModelResp.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceResp.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceTableResp.java create mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSpliceParam.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/resp/DataSourceResp.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructure.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/resp/AssetStructureResp.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/AssetsModelController.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataSourceController.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataTypeController.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/AssetsModelMapper.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataSourceMapper.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTableMapper.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTypeMapper.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/AssetsModelService.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataSourceService.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTableService.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTypeService.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/AssetsModelServiceImpl.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataSourceServiceImpl.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTableServiceImpl.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTypeServiceImpl.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/controller/DataSourceController.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/mapper/DataSourceMapper.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/IDataSourceService.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/impl/DataSourceServiceImpl.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureController.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureTableController.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureMapper.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureTableMapper.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureService.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureTableService.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureServiceImpl.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureTableServiceImpl.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/controller/DataTypeController.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/mapper/DataTypeMapper.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/IDataTypeService.java delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/impl/DataTypeServiceImpl.java create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/AssetsModelMqpper.xml create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataManagerMqpper.xml delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataSourceMapper.xml create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTableMqpper.xml delete mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMapper.xml create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMqpper.xml create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryInfoMqpper.xml create mode 100644 etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryMqpper.xml diff --git a/etl-common/etl-common-security/src/main/java/com/etl/common/security/aspect/InnerAuthAspect.java b/etl-common/etl-common-security/src/main/java/com/etl/common/security/aspect/InnerAuthAspect.java index cf239d2..5627703 100644 --- a/etl-common/etl-common-security/src/main/java/com/etl/common/security/aspect/InnerAuthAspect.java +++ b/etl-common/etl-common-security/src/main/java/com/etl/common/security/aspect/InnerAuthAspect.java @@ -27,6 +27,7 @@ public class InnerAuthAspect implements Ordered { throw new InnerAuthException("没有内部访问权限,不允许访问"); } + String userid = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID); String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME); // 用户信息验证 diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/AssetsModel.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/AssetsModel.java new file mode 100644 index 0000000..41e4050 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/AssetsModel.java @@ -0,0 +1,84 @@ +package com.etl.data.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.etl.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName AssetsModel + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 10:07 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName("assets_model") +public class AssetsModel extends BaseEntity { + private static final long serialVersionUID = 1L; + /** + * 资产模型主键id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 关联表id + */ + private Long dataTableId; + /** + * 字段名称 + */ + private String fieldsName; + /** + * 字段注释 + */ + private String fieldsAnnotation; + /** + * 是否主键 + */ + private Integer isPrimary; + /** + * 数据库类型 + */ + private String baseType; + /** + * java映射类型 + */ + private String javaType; + /** + * 字段长度 + */ + private Integer fieldsLength; + /** + * 小数位 + */ + private Integer decimalPlace; + /** + * 是否为空 + */ + private Integer isEmpty; + /** + * 默认值 + */ + private String defaultValue; + /** + * 是否字典 + */ + private Integer isDictionary; + /** + * 映射字典 + */ + private String reflectionDictionary; + /** + * 以防万一,在加一个表名 + */ + private String tableName; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/DataSource.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataSource.java similarity index 57% rename from etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/DataSource.java rename to etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataSource.java index b73907c..d23b039 100644 --- a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/DataSource.java +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataSource.java @@ -1,9 +1,8 @@ -package com.etl.data.source.domain; +package com.etl.data.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.etl.common.core.annotation.Excel; import com.etl.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; @@ -11,103 +10,82 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; + /** - * 数据源信息对象 data_source - * - * @author Chao - * @date 2024-04-21 + * @ClassName DataSource + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:36 */ @Data +@SuperBuilder @NoArgsConstructor @AllArgsConstructor -@SuperBuilder @EqualsAndHashCode(callSuper = true) @TableName("data_source") public class DataSource extends BaseEntity { private static final long serialVersionUID = 1L; - - /** - * 主键id - */ - @TableId(value = "id", type = IdType.AUTO) + @TableId( type = IdType.AUTO) private Long id; - /** - * 数据源名称 + * 数据类型 */ - @Excel(name = "数据源名称") - private String dataSourceName; - + private String name; /** - * 数据源系统名称 + * 数据来源系统 */ - @Excel(name = "数据源系统名称") - private String dataSourceSystemName; - - /** - * 数据源类型 - */ - @Excel(name = "数据源类型") + private String fromSystem; private Long typeId; - /** - * 数据源ip地址 + * 数据源连接ip */ - @Excel(name = "数据源ip地址") private String dataSourceIp; - /** - * 端口号 + * 数据源连接端口号 */ - @Excel(name = "端口号") private String dataSourcePort; - /** - * 连接数据库名称 + * 数据源连接库名称 */ - @Excel(name = "连接数据库名称") private String dataSourceDatabaseName; - /** - * 用户名 + * 数据连接用户名 */ private String dataSourceUsername; - /** - * 密码 + * 数据源连接密码 */ private String dataSourcePassword; - /** - * 额外配置 + * 数据源额外配置 */ private String additionalConfiguration; - /** * 状态 */ - @Excel(name = "状态") private String status; - /** * 初始化连接数量 */ - private Long initialNumberOfConnections; - + private Integer initialNumberOfConnections; /** * 最大连接数量 */ - private Long maximumNumberOfConnections; - + private Integer maximumNumberOfConnections; /** * 最大等待时间 */ - private Long maximumWaitingTime; - + private Integer maximumWaitingTime; /** * 最大等待次数 */ - private Long maximumWaitingTimes; + private Integer maximumWaitingTimes; + /** + * 是否同步 + */ + private Integer isSync; + private Integer tableCount; + private Integer dataModelCount; } diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructureTable.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataTable.java similarity index 50% rename from etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructureTable.java rename to etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataTable.java index 40743fd..e7395a8 100644 --- a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructureTable.java +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataTable.java @@ -1,9 +1,8 @@ -package com.etl.data.structure.domain; +package com.etl.data.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.etl.common.core.annotation.Excel; import com.etl.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; @@ -12,44 +11,39 @@ import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; /** - * 资产结构对象表 asset_structure_table - * - * @author Chao - * @date 2024-04-22 + * @ClassName DataTable + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 10:01 */ @Data +@SuperBuilder @NoArgsConstructor @AllArgsConstructor -@SuperBuilder @EqualsAndHashCode(callSuper = true) -@TableName("asset_structure_table") -public class AssetStructureTable extends BaseEntity { +@TableName("data_table") +public class DataTable extends BaseEntity { private static final long serialVersionUID = 1L; - /** - * id + * 逐渐id */ - @TableId(value = "id", type = IdType.AUTO) + @TableId(type = IdType.AUTO) private Long id; - /** - * 数据资产id + * 数据来源id */ - @Excel(name = "数据资产id") - private Long assetStructureId; - + private Long dataSourceId; /** - * 数据资产表 + * 表名 */ - @Excel(name = "数据资产表") private String tableName; - /** - * 数据库数据总数 + * 记录条数 */ - @Excel(name = "表数据总数") - private Long tableDataCount; + private Integer recordCount; + /** + * 表注释 + */ + private String tableAnnotation; - @Excel(name = "表注释") - private String tableNameAnnotation; } diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/type/domain/DataType.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataType.java similarity index 55% rename from etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/type/domain/DataType.java rename to etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataType.java index 22b50c1..a2fd281 100644 --- a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/type/domain/DataType.java +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/DataType.java @@ -1,9 +1,8 @@ -package com.etl.data.type.domain; +package com.etl.data.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.etl.common.core.annotation.Excel; import com.etl.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; @@ -12,42 +11,20 @@ import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; /** - * 数据源类型对象 data_type - * - * @author Chao - * @date 2024-04-21 + * @ClassName DataType + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:34 */ @Data +@SuperBuilder @NoArgsConstructor @AllArgsConstructor -@SuperBuilder @EqualsAndHashCode(callSuper = true) @TableName("data_type") public class DataType extends BaseEntity { private static final long serialVersionUID = 1L; - - /** - * 编号 - */ - @TableId(value = "id", type = IdType.AUTO) + @TableId( type = IdType.AUTO) private Long id; - - /** - * 数据源类型 - */ - @Excel(name = "数据源类型") private String dataType; - - /** - * 注册驱动 - */ - @Excel(name = "注册驱动") - private String driverManager; - - /** - * jdbc前缀 - */ - @Excel(name = "jdbc前缀") - private String jdbcPre; - } diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataSourceDecoration.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataSourceDecoration.java new file mode 100644 index 0000000..6e8bf05 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataSourceDecoration.java @@ -0,0 +1,32 @@ +package com.etl.data.domain.decoration; + +import com.etl.data.domain.DataSource; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName DataSourceDecoration + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/23 14:39 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataSourceDecoration { + private DataSource dataSource; + private List dataTableList; + private String type; + public static DataSourceDecoration dataSourceBuild(DataSource dataSource, List dataTables){ + return DataSourceDecoration.builder() + .dataSource(dataSource) + .type("dataSource") + .dataTableList(dataTables) + .build(); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataTableDecoration.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataTableDecoration.java new file mode 100644 index 0000000..a905ee5 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/decoration/DataTableDecoration.java @@ -0,0 +1,28 @@ +package com.etl.data.domain.decoration; + +import com.etl.data.domain.DataTable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName DataTypeDecoration + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/23 14:40 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataTableDecoration { + private DataTable dataTable; + private String type; + public static DataTableDecoration dataSourceBuild(DataTable dataTable){ + return DataTableDecoration.builder() + .dataTable(dataTable) + .type("dataTable") + .build(); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/DataSourceInfo.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/DataSourceInfo.java new file mode 100644 index 0000000..e874d5f --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/DataSourceInfo.java @@ -0,0 +1,25 @@ +package com.etl.data.domain.model; + +import com.etl.data.domain.DataSource; +import com.etl.data.domain.DataTable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName DataSourceInfo + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/23 14:30 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataSourceInfo { + private DataSource dataSource; + private List dataTableList; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/NameAndType.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/NameAndType.java new file mode 100644 index 0000000..c5ea946 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/NameAndType.java @@ -0,0 +1,22 @@ +package com.etl.data.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName DataTest + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/19 20:48 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class NameAndType { + private String name; + private String type; + +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/Structure.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/Structure.java new file mode 100644 index 0000000..a162a3c --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/Structure.java @@ -0,0 +1,20 @@ +package com.etl.data.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName Structure + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/21 19:28 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class Structure { + private Integer id; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/TableInfo.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/TableInfo.java new file mode 100644 index 0000000..9b07a37 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/model/TableInfo.java @@ -0,0 +1,36 @@ +package com.etl.data.domain.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName TableInfo + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/21 19:33 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class TableInfo { + /** + * + */ + private Long tableId; + /** + * 表名 + */ + private String tableName; + /** + * 数据条数 + */ + private Long dataCount; + /** + * 表注释 + */ + private String dataAnnotation; + private String type; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/DataSourceQueryReq.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/DataSourceQueryReq.java new file mode 100644 index 0000000..0563c90 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/DataSourceQueryReq.java @@ -0,0 +1,22 @@ +package com.etl.data.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName DataSourceQueryReq + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 13:20 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataSourceQueryReq { + private String fromSystem; + private String name; + private String dataSourceDatabaseName; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/QueryTableReq.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/QueryTableReq.java new file mode 100644 index 0000000..41af098 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/QueryTableReq.java @@ -0,0 +1,27 @@ +package com.etl.data.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName QueryTableReq + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/21 11:58 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class QueryTableReq { + private Long typeId; + private String dataSourceIp; + private String dataSourcePort; + private String dataSourceDatabaseName; + private String dataSourceUsername; + private String dataSourcePassword; + private String additionalConfiguration; + private String tableName; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/TableStructureQueryReq.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/TableStructureQueryReq.java new file mode 100644 index 0000000..d831254 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/req/TableStructureQueryReq.java @@ -0,0 +1,37 @@ +package com.etl.data.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName TableStructureQueryReq + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/21 22:22 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class TableStructureQueryReq { + private Long id; + private Long typeId; + private String dataType; + private String dataSourceIp; + private String dataSourcePort; + private String dataSourceDatabaseName; + private String dataSourceUsername; + private String dataSourcePassword; + private String additionalConfiguration; + private String status; + private Integer initialNumberOfConnections; + private Integer maximumNumberOfConnections; + private Integer maximumWaitingTime; + private Integer maximumWaitingTimes; + private String name; + private String fromSystem; + private String remark; + private String tableName; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/AssetsModelResp.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/AssetsModelResp.java new file mode 100644 index 0000000..a347586 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/AssetsModelResp.java @@ -0,0 +1,31 @@ +package com.etl.data.domain.resp; + +import com.etl.data.domain.AssetsModel; +import com.etl.data.domain.DataTable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName AssetsModelResp + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/23 20:38 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class AssetsModelResp { + private DataTable dataTable; + private List assetsModelList; + public static AssetsModelResp dataTableAndAssetsModelBuild(DataTable dTable,List assetsModels){ + return AssetsModelResp.builder() + .dataTable(dTable) + .assetsModelList(assetsModels) + .build(); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceResp.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceResp.java new file mode 100644 index 0000000..6bae8c9 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceResp.java @@ -0,0 +1,88 @@ +package com.etl.data.domain.resp; + +import com.etl.data.domain.DataSource; +import com.etl.data.domain.DataType; +import com.etl.data.domain.req.TableStructureQueryReq; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName DataSourceResp + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:42 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataSourceResp { + private Long id; + private Long typeId; + private String dataType; + private String dataSourceIp; + private String dataSourcePort; + private String dataSourceDatabaseName; + private String dataSourceUsername; + private String dataSourcePassword; + private String additionalConfiguration; + private String status; + private Integer initialNumberOfConnections; + private Integer maximumNumberOfConnections; + private Integer maximumWaitingTime; + private Integer maximumWaitingTimes; + private String name; + private String fromSystem; + private String remark; + private Integer isSync; + private List dataSpliceParamList; + public static DataSourceResp buildDataSourceResp(List dataSpliceParams, DataSource dataSource, DataType dataType){ + return DataSourceResp.builder() + .id(dataSource.getId()) + .typeId(dataType.getId()) + .dataType(dataType.getDataType()) + .dataSourceIp(dataSource.getDataSourceIp()) + .dataSourcePort(dataSource.getDataSourcePort()) + .dataSourceDatabaseName(dataSource.getDataSourceDatabaseName()) + .dataSourceUsername(dataSource.getDataSourceUsername()) + .dataSourcePassword(dataSource.getDataSourcePassword()) + .additionalConfiguration(dataSource.getAdditionalConfiguration()) + .status(dataSource.getStatus()) + .initialNumberOfConnections(dataSource.getInitialNumberOfConnections()) + .maximumNumberOfConnections(dataSource.getMaximumNumberOfConnections()) + .maximumWaitingTime(dataSource.getMaximumWaitingTime()) + .maximumWaitingTimes(dataSource.getMaximumWaitingTimes()) + .dataSpliceParamList(dataSpliceParams) + .name(dataSource.getName()) + .fromSystem(dataSource.getFromSystem()) + .remark(dataSource.getRemark()) + .isSync(dataSource.getIsSync()) + .build(); + } + public static DataSourceResp tableStructureQueryReqBuild(TableStructureQueryReq dataSource){ + return DataSourceResp.builder() + .id(dataSource.getId()) + .typeId(dataSource.getTypeId()) + .dataType(dataSource.getDataType()) + .dataSourceIp(dataSource.getDataSourceIp()) + .dataSourcePort(dataSource.getDataSourcePort()) + .dataSourceDatabaseName(dataSource.getDataSourceDatabaseName()) + .dataSourceUsername(dataSource.getDataSourceUsername()) + .dataSourcePassword(dataSource.getDataSourcePassword()) + .additionalConfiguration(dataSource.getAdditionalConfiguration()) + .status(dataSource.getStatus()) + .initialNumberOfConnections(dataSource.getInitialNumberOfConnections()) + .maximumNumberOfConnections(dataSource.getMaximumNumberOfConnections()) + .maximumWaitingTime(dataSource.getMaximumWaitingTime()) + .maximumWaitingTimes(dataSource.getMaximumWaitingTimes()) + .dataSpliceParamList(null) + .name(dataSource.getName()) + .fromSystem(dataSource.getFromSystem()) + .remark(dataSource.getRemark()) + .build(); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceTableResp.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceTableResp.java new file mode 100644 index 0000000..087402b --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSourceTableResp.java @@ -0,0 +1,34 @@ +package com.etl.data.domain.resp; + +import com.etl.data.domain.decoration.DataSourceDecoration; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.util.List; + +/** + * @ClassName DataSourceTableResp + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/21 19:39 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataSourceTableResp { + /** + * 数据源和表的层级结构 + */ + private List dataSourceDecorationList; + /** + * 系统中所有已经接入的表数量 + */ + private Integer allTableCount; + /** + * 系统中所有已经接入的数据模型(字段)数量 + */ + private Integer allDataModelCount; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSpliceParam.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSpliceParam.java new file mode 100644 index 0000000..8fdec65 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/domain/resp/DataSpliceParam.java @@ -0,0 +1,21 @@ +package com.etl.data.domain.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ClassName DataSpliceParam + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 12:28 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class DataSpliceParam { + private String paramName; + private String paramValue; +} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/resp/DataSourceResp.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/resp/DataSourceResp.java deleted file mode 100644 index bf6c2f8..0000000 --- a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/source/domain/resp/DataSourceResp.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.etl.data.source.domain.resp; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.etl.common.core.annotation.Excel; -import com.etl.common.core.web.domain.BaseEntity; -import com.etl.data.source.domain.DataSource; -import com.etl.data.type.domain.DataType; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -/** - * 数据源信息对象 data_source - * - * @author Chao - * @date 2024-04-21 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -@EqualsAndHashCode(callSuper = true) -@TableName("data_source") -public class DataSourceResp extends BaseEntity { - private static final long serialVersionUID = 1L; - - /** - * 主键id - */ - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - /** - * 数据源名称 - */ - @Excel(name = "数据源名称") - private String dataSourceName; - - /** - * 数据源系统名称 - */ - @Excel(name = "数据源系统名称") - private String dataSourceSystemName; - - /** - * 数据源类型 - */ - @Excel(name = "数据源类型") - private Long typeId; - - - @Excel(name = "数据源类型") - private String dataType; - - /** - * 数据源ip地址 - */ - @Excel(name = "数据源ip地址") - private String dataSourceIp; - - /** - * 端口号 - */ - @Excel(name = "端口号") - private String dataSourcePort; - - /** - * 连接数据库名称 - */ - @Excel(name = "连接数据库名称") - private String dataSourceDatabaseName; - - /** - * 用户名 - */ - @Excel(name = "用户名") - private String dataSourceUsername; - - /** - * 密码 - */ - @Excel(name = "密码") - private String dataSourcePassword; - - /** - * 额外配置 - */ - @Excel(name = "额外配置") - private String additionalConfiguration; - - /** - * 状态 - */ - @Excel(name = "状态") - private String status; - - /** - * 初始化连接数量 - */ - @Excel(name = "初始化连接数量") - private Long initialNumberOfConnections; - - /** - * 最大连接数量 - */ - @Excel(name = "最大连接数量") - private Long maximumNumberOfConnections; - - /** - * 最大等待时间 - */ - @Excel(name = "最大等待时间") - private Long maximumWaitingTime; - - /** - * 最大等待次数 - */ - @Excel(name = "最大等待次数") - private Long maximumWaitingTimes; - - - public static DataSourceResp dataSourceBuilder(DataSource source, DataType dataType) { - return DataSourceResp.builder() - .id(source.getId()) - .dataSourceName(source.getDataSourceName()) - .dataSourceSystemName(source.getDataSourceSystemName()) - .typeId(source.getTypeId()) - .dataType(dataType.getDataType()) - .dataSourceIp(source.getDataSourceIp()) - .dataSourcePort(source.getDataSourcePort()) - .dataSourceDatabaseName(source.getDataSourceDatabaseName()) - .dataSourceUsername(source.getDataSourceUsername()) - .dataSourcePassword(source.getDataSourcePassword()) - .additionalConfiguration(source.getAdditionalConfiguration()) - .status(source.getStatus()) - .initialNumberOfConnections(source.getInitialNumberOfConnections()) - .maximumNumberOfConnections(source.getMaximumNumberOfConnections()) - .maximumWaitingTime(source.getMaximumWaitingTime()) - .maximumWaitingTimes(source.getMaximumWaitingTimes()) - .remark(source.getRemark()) - .build(); - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructure.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructure.java deleted file mode 100644 index 756c1fc..0000000 --- a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/AssetStructure.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.etl.data.structure.domain; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.etl.common.core.web.domain.BaseEntity; -import com.etl.data.source.domain.DataSource; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -/** - * 资产结构对象 asset_structure - * - * @author Chao - * @date 2024-04-22 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -@EqualsAndHashCode(callSuper = true) -@TableName("asset_structure") -public class AssetStructure extends BaseEntity { - private static final long serialVersionUID = 1L; - - /** - * id - */ - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - /** - * 数据源id - */ - private Long dataSourceSystemId; - - /** - * 数据源名称 - */ - private String dataSourceName; - - /** - * 数据源系统名称 - */ - private String dataSourceSystemName; - - /** - * 连接数据库名称 - */ - private String dataSourceDatabaseName; - - public static AssetStructure dataSourceSaveBuilder(Long id, DataSource dataSource) { - return AssetStructure.builder() - .dataSourceSystemId(id) - .dataSourceName(dataSource.getDataSourceName()) - .dataSourceSystemName(dataSource.getDataSourceSystemName()) - .dataSourceDatabaseName(dataSource.getDataSourceDatabaseName()) - .build(); - } - - public static AssetStructure dataSourceUpdateBuilder(AssetStructure assetStructure, Long id, DataSource dataSource) { - return AssetStructure.builder() - .id(assetStructure.getId()) - .dataSourceSystemId(id) - .dataSourceName(dataSource.getDataSourceName()) - .dataSourceSystemName(dataSource.getDataSourceSystemName()) - .dataSourceDatabaseName(dataSource.getDataSourceDatabaseName()) - .build(); - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/resp/AssetStructureResp.java b/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/resp/AssetStructureResp.java deleted file mode 100644 index 84886a5..0000000 --- a/etl-modules/etl-data-source/etl-data-source-common/src/main/java/com/etl/data/structure/domain/resp/AssetStructureResp.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etl.data.structure.domain.resp; - -import com.etl.data.structure.domain.AssetStructure; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.util.List; - -/** - * 数据资产返回类 - * - * @author Chao - * @ClassName: AssetStructureResp 数据资产返回类 - * @CreateTime: 2024/4/22 下午7:23 - */ - -@Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -public class AssetStructureResp { - - /** - * 数据资产 - */ - private List assetStructureList; - - /** - * 数据资产表总数 - */ - private Long assetStructureTableCount; - - /** - * 数据资产表数据总数 - */ - private Long assetStructureTableDataCount; - - -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/ETLDataSourceApplication.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/ETLDataSourceApplication.java index 87199aa..dfca625 100644 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/ETLDataSourceApplication.java +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/ETLDataSourceApplication.java @@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; /** * 数据源模块 * - * @author Chao + * @author YunFei */ @EnableCustomConfig @EnableCustomSwagger2 diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/AssetsModelController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/AssetsModelController.java new file mode 100644 index 0000000..a04db7e --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/AssetsModelController.java @@ -0,0 +1,33 @@ +package com.etl.data.controller; + +import com.etl.common.core.domain.Result; +import com.etl.common.core.web.controller.BaseController; +import com.etl.data.domain.resp.AssetsModelResp; +import com.etl.data.service.AssetsModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @ClassName AssetsModelController + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/23 20:08 + */ +@RestController +@RequestMapping("/assets") +public class AssetsModelController extends BaseController { + @Autowired + private AssetsModelService assetsModelService; + + //查找所有的数据模型 + @PostMapping("/getAssetsModelList") + public Result> getAssetsModelListByTableIds(@RequestBody List tableIds){ + return assetsModelService.getAssetsModelListByTableIds(tableIds); + } + @GetMapping("/getAssetsModelByDataTableId") + public Result getAssetsModelByDataTableId(@RequestParam Integer id){ + return assetsModelService.getAssetsModelByDataTableId(id); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataSourceController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataSourceController.java new file mode 100644 index 0000000..84582a6 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataSourceController.java @@ -0,0 +1,71 @@ +package com.etl.data.controller; + +import com.etl.common.core.domain.Result; +import com.etl.common.core.web.controller.BaseController; +import com.etl.common.security.utils.SecurityUtils; +import com.etl.data.domain.DataSource; +import com.etl.data.domain.req.DataSourceQueryReq; +import com.etl.data.domain.req.TableStructureQueryReq; +import com.etl.data.domain.resp.DataSourceResp; +import com.etl.data.domain.resp.DataSourceTableResp; +import com.etl.data.service.DataSourceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; +import java.util.List; + +/** + * @ClassName DataSourceController + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:06 + */ +@RestController +@RequestMapping("/source") +public class DataSourceController extends BaseController { + @Autowired + private DataSourceService dataSourceService; + + @PostMapping("/list") + public Result getDataSourceList (@RequestBody DataSourceQueryReq dataSourceQueryReq) { + List list = dataSourceService.list(dataSourceQueryReq); + return success(list); + } + @PostMapping("/insertDataSource") + public Result insertDataSource(@RequestBody DataSource dataSource){ + if (dataSource.getId() != null){ + dataSource.setUpdateBy(SecurityUtils.getUsername()); + dataSource.setUpdateTime(new Date()); + dataSourceService.updateById(dataSource); + }else { + dataSource.setCreateBy(SecurityUtils.getUsername()); + dataSource.setCreateTime(new Date()); + dataSourceService.save(dataSource); + } + return success(); + } + @PostMapping("/testConnect") + public Result testConnect(@RequestBody DataSourceResp dataSourceResp){ + return dataSourceService.testConnect(dataSourceResp); + } + + @PostMapping("/queryBigStructure") + public Result queryStructure(){ + return dataSourceService.queryBigStructure(); + } + + @PostMapping("/queryTableStructure") + public Result queryTableStructure(@RequestBody TableStructureQueryReq tableStructureQueryReq){ + return dataSourceService.queryTableStructure(tableStructureQueryReq); + } + //数据同步 + @PostMapping("/dataSynchronization") + public Result dataSynchronization(@RequestBody DataSourceResp dataSourceResp){ + return dataSourceService.dataSynchronization(dataSourceResp); + } + +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataTypeController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataTypeController.java new file mode 100644 index 0000000..a0418c0 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/controller/DataTypeController.java @@ -0,0 +1,34 @@ +package com.etl.data.controller; + +import com.etl.common.core.domain.Result; +import com.etl.common.core.web.controller.BaseController; +import com.etl.data.domain.DataType; +import com.etl.data.service.DataTypeService; +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; + +/** + * @ClassName DataTypeController + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 12:55 + */ +@RestController +@RequestMapping("/dataType") +public class DataTypeController extends BaseController { + @Autowired + private DataTypeService dataTypeService; + + /** + * 查询所有类型 + */ + @GetMapping("/getAllDataType") + public Result> getAllDataList(){ + List list = dataTypeService.list(); + return Result.success(list); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/AssetsModelMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/AssetsModelMapper.java new file mode 100644 index 0000000..6691ca9 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/AssetsModelMapper.java @@ -0,0 +1,13 @@ +package com.etl.data.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.etl.data.domain.AssetsModel; + +/** + * @ClassName AssetsModelMapper + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 14:37 + */ +public interface AssetsModelMapper extends BaseMapper { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataSourceMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataSourceMapper.java new file mode 100644 index 0000000..cd889f3 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataSourceMapper.java @@ -0,0 +1,13 @@ +package com.etl.data.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.etl.data.domain.DataSource; + +/** + * @ClassName DataSourceMapper + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:46 + */ +public interface DataSourceMapper extends BaseMapper { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTableMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTableMapper.java new file mode 100644 index 0000000..f72c3c7 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTableMapper.java @@ -0,0 +1,13 @@ +package com.etl.data.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.etl.data.domain.DataTable; + +/** + * @ClassName DataTableMapper + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 14:35 + */ +public interface DataTableMapper extends BaseMapper { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTypeMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTypeMapper.java new file mode 100644 index 0000000..e65db68 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/mapper/DataTypeMapper.java @@ -0,0 +1,13 @@ +package com.etl.data.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.etl.data.domain.DataType; + +/** + * @ClassName DataSourceMapper + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:46 + */ +public interface DataTypeMapper extends BaseMapper { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/AssetsModelService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/AssetsModelService.java new file mode 100644 index 0000000..8d99f77 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/AssetsModelService.java @@ -0,0 +1,20 @@ +package com.etl.data.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.etl.common.core.domain.Result; +import com.etl.data.domain.AssetsModel; +import com.etl.data.domain.resp.AssetsModelResp; + +import java.util.List; + +/** + * @ClassName AssetsModelService + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 14:39 + */ +public interface AssetsModelService extends IService { + Result> getAssetsModelListByTableIds(List tableIds); + + Result getAssetsModelByDataTableId(Integer id); +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataSourceService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataSourceService.java new file mode 100644 index 0000000..60c02ab --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataSourceService.java @@ -0,0 +1,31 @@ +package com.etl.data.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.etl.common.core.domain.Result; +import com.etl.data.domain.DataSource; +import com.etl.data.domain.req.DataSourceQueryReq; +import com.etl.data.domain.req.TableStructureQueryReq; +import com.etl.data.domain.resp.DataSourceResp; +import com.etl.data.domain.resp.DataSourceTableResp; + +import java.util.List; + +/** + * @ClassName DataMansgerService + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:48 + */ +public interface DataSourceService extends IService { + List list(DataSourceQueryReq dataSourceQueryReq); + + Result testConnect(DataSourceResp dataSourceResp); + + + Result queryTableStructure(TableStructureQueryReq tableStructureQueryReq); + + Result queryBigStructure(); + + Result dataSynchronization(DataSourceResp dataSourceResp); + +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTableService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTableService.java new file mode 100644 index 0000000..18de2c4 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTableService.java @@ -0,0 +1,13 @@ +package com.etl.data.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.etl.data.domain.DataTable; + +/** + * @ClassName DataTableService + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 14:36 + */ +public interface DataTableService extends IService { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTypeService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTypeService.java new file mode 100644 index 0000000..12207ff --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/DataTypeService.java @@ -0,0 +1,13 @@ +package com.etl.data.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.etl.data.domain.DataType; + +/** + * @ClassName DataMansgerService + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:48 + */ +public interface DataTypeService extends IService { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/AssetsModelServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/AssetsModelServiceImpl.java new file mode 100644 index 0000000..d669f20 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/AssetsModelServiceImpl.java @@ -0,0 +1,54 @@ +package com.etl.data.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.etl.common.core.domain.Result; +import com.etl.data.domain.AssetsModel; +import com.etl.data.domain.DataTable; +import com.etl.data.domain.resp.AssetsModelResp; +import com.etl.data.mapper.AssetsModelMapper; +import com.etl.data.service.AssetsModelService; +import com.etl.data.service.DataTableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName AssetsModelServiceImpl + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 14:39 + */ +@Service +public class AssetsModelServiceImpl extends ServiceImpl implements AssetsModelService { + @Autowired + private DataTableService dataTableService; + @Override + public Result> getAssetsModelListByTableIds(List tableId) { + ArrayList assetsModelRespArrayList = new ArrayList<>(); + //查询数据表 + LambdaQueryWrapper dataTableLambdaQueryWrapper = new LambdaQueryWrapper<>(); + dataTableLambdaQueryWrapper.in(DataTable::getId,tableId); + List dataTableList = dataTableService.list(dataTableLambdaQueryWrapper); + //查询所有的数据模型 + for (DataTable dataTable : dataTableList) { + LambdaQueryWrapper assetsModelLambdaQueryWrapper = new LambdaQueryWrapper<>(); + assetsModelLambdaQueryWrapper.eq(AssetsModel::getDataTableId,dataTable.getId()); + List assetsModelList = this.list(assetsModelLambdaQueryWrapper); + assetsModelRespArrayList.add(AssetsModelResp.dataTableAndAssetsModelBuild(dataTable,assetsModelList)); + } + return Result.success(assetsModelRespArrayList); + } + + @Override + public Result getAssetsModelByDataTableId(Integer tableId) { + DataTable dataTable = dataTableService.getById(tableId); + LambdaQueryWrapper assetsModelLambdaQueryWrapper = new LambdaQueryWrapper<>(); + assetsModelLambdaQueryWrapper.eq(AssetsModel::getDataTableId,dataTable.getId()); + List assetsModelList = this.list(assetsModelLambdaQueryWrapper); + AssetsModelResp assetsModelResp = AssetsModelResp.dataTableAndAssetsModelBuild(dataTable, assetsModelList); + return Result.success(assetsModelResp); + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataSourceServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataSourceServiceImpl.java new file mode 100644 index 0000000..e3a4f6f --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataSourceServiceImpl.java @@ -0,0 +1,407 @@ +package com.etl.data.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.etl.common.core.domain.Result; +import com.etl.common.security.utils.SecurityUtils; +import com.etl.data.domain.AssetsModel; +import com.etl.data.domain.DataSource; +import com.etl.data.domain.DataTable; +import com.etl.data.domain.DataType; +import com.etl.data.domain.decoration.DataSourceDecoration; +import com.etl.data.domain.decoration.DataTableDecoration; +import com.etl.data.domain.req.DataSourceQueryReq; +import com.etl.data.domain.req.TableStructureQueryReq; +import com.etl.data.domain.resp.DataSourceResp; +import com.etl.data.domain.resp.DataSourceTableResp; +import com.etl.data.domain.resp.DataSpliceParam; +import com.etl.data.mapper.DataSourceMapper; +import com.etl.data.service.AssetsModelService; +import com.etl.data.service.DataSourceService; +import com.etl.data.service.DataTableService; +import com.etl.data.service.DataTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.sql.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + +/** + * @ClassName DataSourceServiceImpl + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:49 + */ +@Service +public class DataSourceServiceImpl extends ServiceImpl implements DataSourceService { + + @Autowired + private DataTypeService dataTypeService; + @Autowired + private DataTableService dataTableService; + @Autowired + private AssetsModelService assetsModelService; + + @Override + public List list(DataSourceQueryReq dataSourceQueryReq) { + + LambdaQueryWrapper dataSourceLambdaQueryWrapper = new LambdaQueryWrapper<>(); + if (dataSourceQueryReq.getFromSystem() != null && !"".equals(dataSourceQueryReq.getFromSystem())) { + dataSourceLambdaQueryWrapper.eq(DataSource::getFromSystem, dataSourceQueryReq.getFromSystem()); + } + if (dataSourceQueryReq.getDataSourceDatabaseName() != null && !"".equals(dataSourceQueryReq.getDataSourceDatabaseName())) { + dataSourceLambdaQueryWrapper.eq(DataSource::getDataSourceDatabaseName, dataSourceQueryReq.getDataSourceDatabaseName()); + } + if (dataSourceQueryReq.getName() != null && !"".equals(dataSourceQueryReq.getName())) { + dataSourceLambdaQueryWrapper.eq(DataSource::getName, dataSourceQueryReq.getName()); + } + List list = this.list(dataSourceLambdaQueryWrapper); + ArrayList dataSourceRespList = new ArrayList<>(); + //切割参数数据 + for (DataSource dataSource : list) { + //查询数据源类型表 + DataType byId = dataTypeService.getById(dataSource.getTypeId()); + String additionalConfiguration = dataSource.getAdditionalConfiguration(); + String[] split = additionalConfiguration.split("&"); + ArrayList dataSpliceParams = new ArrayList<>(); + for (String s : split) { + String[] strings = s.split("="); + DataSpliceParam dataSpliceParam = new DataSpliceParam(strings[0], strings[1]); + dataSpliceParams.add(dataSpliceParam); + } + DataSourceResp dataSourceResp = DataSourceResp.buildDataSourceResp(dataSpliceParams, dataSource, byId); + dataSourceRespList.add(dataSourceResp); + } + return dataSourceRespList; + } + + @Override + public Result testConnect(DataSourceResp dataSourceResp) { + String username = dataSourceResp.getDataSourceUsername(); //用户名 + String password = dataSourceResp.getDataSourcePassword();//密码 + String dbName = dataSourceResp.getDataSourceDatabaseName(); //数据库名 + System.out.println("数据库名:" + dbName); + Integer dbType = Math.toIntExact(dataSourceResp.getTypeId()); //数据库类型 1-mysql,2-oracle,3-postgressql + String dbIp = dataSourceResp.getDataSourceIp(); //数据库地址 + String dbPort = dataSourceResp.getDataSourcePort(); //端口 + String dbIpPort = dbIp + ":" + dbPort; + String driveClass; + String jdbcUrl; + try { + + switch (dbType) { + case 1: + // mysql数据库 + driveClass = "com.mysql.cj.jdbc.Driver"; + jdbcUrl = "jdbc:mysql://" + dbIpPort + "/" + dbName + + "?serverTimezone=Asia/Shanghai&serverTimezone=Asia/Shanghai" + + "&useSSL=false&useUnicode=true&characterEncoding=UTF-8"; + break; + case 2: + // oracle数据库 + driveClass = "oracle.jdbc.OracleDriver"; + jdbcUrl = "jdbc:oracle:thin:@" + dbIpPort + ":" + dbName; + break; + default: + // PostgreSQL数据库 + driveClass = "org.postgresql.Driver"; + jdbcUrl = "jdbc:postgresql://" + dbIpPort + "/" + dbName; + } + boolean b = testDatasource(driveClass, jdbcUrl, username, password); + System.out.println(b); + if (!b) { + return Result.error("连接失败"); + } + } catch (Exception e) { + return Result.error("连接失败"); + } + return Result.success("连接成功", "连接成功"); + } + + public Connection queryStructure(DataSourceResp dataSourceResp, String infoDataBaseName) { + try { + // + String username = dataSourceResp.getDataSourceUsername(); //用户名 + String password = dataSourceResp.getDataSourcePassword();//密码 + String dbName = infoDataBaseName == null ? dataSourceResp.getDataSourceDatabaseName() : infoDataBaseName; //数据库名 + System.out.println("数据库名:" + dbName); + Integer dbType = Math.toIntExact(dataSourceResp.getTypeId()); //数据库类型 1-mysql,2-oracle,3-postgressql + String dbIp = dataSourceResp.getDataSourceIp(); //数据库地址 + String dbPort = dataSourceResp.getDataSourcePort(); //端口 + String dbIpPort = dbIp + ":" + dbPort; + String driveClass; + String jdbcUrl; + // + driveClass = "com.mysql.cj.jdbc.Driver"; + jdbcUrl = "jdbc:mysql://" + dbIpPort + "/" + dbName + + "?serverTimezone=Asia/Shanghai&serverTimezone=Asia/Shanghai" + + "&useSSL=false&useUnicode=true&characterEncoding=UTF-8"; + + Class.forName(driveClass); + Connection connection = DriverManager.getConnection(jdbcUrl, username, password); + return connection; + } catch (Exception e) { + return null; + } + + } + + @Override + public Result queryTableStructure(TableStructureQueryReq tableStructureQueryReq) { + DataSourceResp dataSourceResp = DataSourceResp.tableStructureQueryReqBuild(tableStructureQueryReq); + Connection getAssetsConnection = queryStructure(dataSourceResp, null); + try { + DatabaseMetaData metaData = getAssetsConnection.getMetaData(); + System.out.println("要查询的表名:" + tableStructureQueryReq.getTableName()); + ResultSet pkInfo = metaData.getPrimaryKeys(tableStructureQueryReq.getDataSourceDatabaseName(), "%", tableStructureQueryReq.getTableName()); + System.out.println(pkInfo == null); + while (pkInfo.next()) { + System.out.print("数据库名称:" + pkInfo.getString("TABLE_CAT") + " "); + System.out.print("表名称:" + pkInfo.getString("TABLE_NAME") + " "); + System.out.print("主键列的名称:" + pkInfo.getString("COLUMN_NAME") + " "); + System.out.print("类型:" + pkInfo.getString("PK_NAME") + " "); + System.out.println(""); + } + System.out.println("------------------------------分隔符--------------------------------------------"); + // 获取表的相对应的列的名字 + ResultSet tableInfo = metaData.getColumns(tableStructureQueryReq.getDataSourceDatabaseName(), "%", tableStructureQueryReq.getTableName(), "%"); + while (tableInfo.next()) { + // 表的名字 + System.out.print("表名:" + tableInfo.getString("TABLE_NAME") + " "); + // 列的名称 + System.out.print("列名:" + tableInfo.getString("COLUMN_NAME") + " "); + // 默认值 + System.out.print("默认值 :" + tableInfo.getString("COLUMN_DEF") + " "); + // 字段的类型 + System.out.print("字段的类型:" + tableInfo.getString("TYPE_NAME") + " "); + // 是否可以为空 + System.out.print("是否可以为空:" + tableInfo.getString("IS_NULLABLE") + " "); + // 是否为自增 + System.out.print("是否为自增:" + tableInfo.getString("IS_AUTOINCREMENT") + " "); + // 字段说明 + System.out.print("字段说明:" + tableInfo.getString("REMARKS") + " "); + // 长度(有时候是错的) + System.out.print("长度:" + tableInfo.getString("COLUMN_SIZE") + " "); + System.out.println(); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } + return null; + } + + @Override + public Result queryBigStructure() { + Integer allTableCount = 0; + Integer allDataModelCount = 0; + //创建数据源装饰着对象结合 + ArrayList dataSourceDecorations = new ArrayList<>(); + //获取所有数据源 + List dataSourceList = this.list(); + for (DataSource dataSource : dataSourceList) { + LambdaQueryWrapper dataTableLambdaQueryWrapper = new LambdaQueryWrapper<>(); + dataTableLambdaQueryWrapper.eq(DataTable::getDataSourceId,dataSource.getId()); + //数据表装饰对象 + ArrayList dataTableDecorations = new ArrayList<>(); + List dataTableList = dataTableService.list(dataTableLambdaQueryWrapper); + for (DataTable dataTable : dataTableList) { + dataTableDecorations.add(DataTableDecoration.dataSourceBuild(dataTable)); + } + dataSourceDecorations.add(DataSourceDecoration.dataSourceBuild(dataSource, dataTableDecorations)); + allTableCount = dataSource.getTableCount() + allTableCount; + allDataModelCount = dataSource.getDataModelCount() + allDataModelCount; + + } + + return Result.success(DataSourceTableResp.builder() + .allDataModelCount(allDataModelCount) + .allTableCount(allTableCount) + .dataSourceDecorationList(dataSourceDecorations) + .build()); + } + + @Override + public Result dataSynchronization(DataSourceResp dataSourceResp) { + //获取所有表,根据数据源id' + LambdaQueryWrapper dataTableLambdaQueryWrapper = new LambdaQueryWrapper<>(); + dataTableLambdaQueryWrapper.eq(DataTable::getDataSourceId,dataSourceResp.getId()); + List dataTableList = dataTableService.list(dataTableLambdaQueryWrapper); + //获取所有的根据此数据源存储的表id + List dataTableIdList = dataTableList.stream().map(DataTable::getId).toList(); + //根据表id获取所有的模型记录 + if (dataTableIdList != null && dataTableIdList.size()!=0){ + LambdaQueryWrapper assetsModelLambdaQueryWrapper = new LambdaQueryWrapper<>(); + assetsModelLambdaQueryWrapper.in(AssetsModel::getDataTableId,dataTableIdList); + List OldAssetsModelList = assetsModelService.list(assetsModelLambdaQueryWrapper); + //获取所有的数据模型记录 + List assetsModelIdList = OldAssetsModelList.stream().map(AssetsModel::getId).toList(); + //删除所有源表 + dataTableService.removeBatchByIds(dataTableIdList); + if (assetsModelIdList != null && assetsModelIdList.size() !=0){ + //删除所有模型 + assetsModelService.removeBatchByIds(assetsModelIdList); + } + + } + + try { + //链接数据库对象 + Connection connectionGetCount = queryStructure(dataSourceResp, null); + ArrayList tableInfos = new ArrayList<>(); + Connection connection = queryStructure(dataSourceResp, "information_schema"); + String queryTableSql = "select TABLE_NAME as 'tableName',TABLE_COMMENT as 'dataAnnotation' from `TABLES` t where TABLE_SCHEMA = '" + dataSourceResp.getDataSourceDatabaseName() + "'"; + PreparedStatement preparedStatement = connection.prepareStatement(queryTableSql); + ResultSet resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + String tableName = resultSet.getString("tableName"); + String dataAnnotation = resultSet.getString("dataAnnotation"); + + String queryTableDataCount = "SELECT count(1) FROM " + tableName; + PreparedStatement preparedStatementCount = connectionGetCount.prepareStatement(queryTableDataCount); + ResultSet resultSetCount = preparedStatementCount.executeQuery(); + while (resultSetCount.next()) { + tableInfos.add(DataTable.builder() + .id(null) + .tableName(tableName) + .dataSourceId(dataSourceResp.getId()) + .createBy(SecurityUtils.getUsername()) + .createTime(new Date()) + .recordCount(resultSetCount.getInt(1)) + .tableAnnotation(dataAnnotation) + .build()); + } + } + dataTableService.saveBatch(tableInfos); + Connection getAssetsConnection = queryStructure(dataSourceResp, null); + ArrayList assetsModelList = new ArrayList<>(); + for (DataTable tableInfo : tableInfos) { + DatabaseMetaData metaData = getAssetsConnection.getMetaData(); + ResultSet pkInfo = metaData.getPrimaryKeys(dataSourceResp.getDataSourceDatabaseName(), "%", tableInfo.getTableName()); + + System.out.println(pkInfo == null); + String primaryString = ""; + + while (pkInfo.next()) { + primaryString = pkInfo.getString("COLUMN_NAME"); + } + System.out.println("------------------------------分隔符--------------------------------------------"); + // 获取表的相对应的列的名字 + ResultSet assetsInfo = metaData.getColumns(dataSourceResp.getDataSourceDatabaseName(), "%", tableInfo.getTableName(), "%"); + + String queryTableDataCount = "SELECT * FROM " + tableInfo.getTableName(); + PreparedStatement preparedStatementCount = connectionGetCount.prepareStatement(queryTableDataCount); + ResultSet resultSetCount = preparedStatementCount.executeQuery(); + + while (assetsInfo.next()) { + // 表的名字 + String tableName = assetsInfo.getString("TABLE_NAME"); + // 列的名称 + String fieldsName = assetsInfo.getString("COLUMN_NAME"); + String javaType = ""; + for (int i = 0; i < resultSetCount.getMetaData().getColumnCount(); i++) { + String columnName = resultSetCount.getMetaData().getColumnName(i + 1); + if (columnName.equals(fieldsName)){ + javaType = resultSetCount.getMetaData().getColumnClassName(i+1); + } + } + // 默认值 + String defaultValue = assetsInfo.getString("COLUMN_DEF"); + // 字段的类型 + String baseType = assetsInfo.getString("TYPE_NAME"); + + // 是否可以为空 + Integer isEmpty = null; + if ("YES".equals(assetsInfo.getString("IS_NULLABLE"))) { + isEmpty = 1; + } else { + isEmpty = 0; + } + // 字段注释 + String fieldsAnnotation = assetsInfo.getString("REMARKS"); + // 长度(有时候是错的) + Integer fieldsLength = Integer.valueOf(assetsInfo.getString("COLUMN_SIZE")); + //小数位 + Integer decimalPlace = assetsInfo.getInt("DECIMAL_DIGITS"); + //是否主键 + Integer isPrimary = null; + if (fieldsName.equals(primaryString)) { + isPrimary = 1; + } else { + isPrimary = 0; + } + AssetsModel assetsModel = AssetsModel.builder() + .decimalPlace(decimalPlace) + .dataTableId(tableInfo.getId()) + .baseType(baseType) + .defaultValue(defaultValue) + .fieldsAnnotation(fieldsAnnotation) + .fieldsLength(fieldsLength) + .fieldsName(fieldsName) + .tableName(tableName) + .isEmpty(isEmpty) + .isPrimary(isPrimary) + .javaType(javaType) + .createBy(SecurityUtils.getUsername()) + .createTime(new Date()) + .build(); + assetsModelList.add(assetsModel); + } + + } + assetsModelService.saveBatch(assetsModelList); + //查询本库中所有的表(资产模型)数量 + String queryTableCount = "SELECT COUNT(*) TABLES FROM information_schema.TABLES WHERE table_schema = "+"'"+dataSourceResp.getDataSourceDatabaseName()+"'"+" GROUP BY table_schema"; + PreparedStatement preparedStatementGetTableCount = connection.prepareStatement(queryTableCount); + ResultSet resultSetCount = preparedStatementGetTableCount.executeQuery(); + int tableCount = 0; + while (resultSetCount.next()){ + tableCount = resultSetCount.getInt(1); + } + //查询本库中所有的字段(数据模型)适量 + String queryFieldsCount = "SELECT COUNT(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = "+ "'"+dataSourceResp.getDataSourceDatabaseName()+"'"; + PreparedStatement preparedStatementGetFieldsCount = connection.prepareStatement(queryFieldsCount); + ResultSet resultSetFieldsCount = preparedStatementGetFieldsCount.executeQuery(); + int fieldsCount = 0; + while (resultSetFieldsCount.next()){ + fieldsCount = resultSetFieldsCount.getInt(1); + } + //修改数量 + UpdateWrapper dataSourceUpdateWrapper = new UpdateWrapper<>(); + dataSourceUpdateWrapper.eq("id",dataSourceResp.getId()); + dataSourceUpdateWrapper.set("table_count",tableCount); + dataSourceUpdateWrapper.set("data_model_count",fieldsCount); + this.update(dataSourceUpdateWrapper); + } catch (Exception e) { + return Result.success(null,"数据同步失败,失败原因"+e.getMessage()); + } + return Result.success(null,"数据同步成功"); + } + + public static void close(ResultSet rs, PreparedStatement ps, Connection conn) throws Exception { + if (rs != null) { + rs.close(); + } + if (ps != null) { + ps.close(); + } + if (conn != null) { + conn.close(); + } + } + + //测试数据源连接是否有效 + public static boolean testDatasource(String driveClass, String url, String username, String password) { + //Result>> + try { + Class.forName(driveClass); + Connection connection = DriverManager.getConnection(url, username, password); + return true; + } catch (Exception e) { + return false; + } + } +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTableServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTableServiceImpl.java new file mode 100644 index 0000000..7f49a26 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTableServiceImpl.java @@ -0,0 +1,17 @@ +package com.etl.data.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.etl.data.domain.DataTable; +import com.etl.data.mapper.DataTableMapper; +import com.etl.data.service.DataTableService; +import org.springframework.stereotype.Service; + +/** + * @ClassName DataTableServiceImpl + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/22 14:36 + */ +@Service +public class DataTableServiceImpl extends ServiceImpl implements DataTableService { +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTypeServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTypeServiceImpl.java new file mode 100644 index 0000000..5b4f5ee --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/service/impl/DataTypeServiceImpl.java @@ -0,0 +1,18 @@ +package com.etl.data.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.etl.data.domain.DataType; +import com.etl.data.mapper.DataTypeMapper; +import com.etl.data.service.DataTypeService; +import org.springframework.stereotype.Service; + +/** + * @ClassName DataSourceServiceImpl + * @Description 描述 + * @Author YunFei.Du + * @Date 2024/4/20 11:49 + */ +@Service +public class DataTypeServiceImpl extends ServiceImpl implements DataTypeService { + +} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/controller/DataSourceController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/controller/DataSourceController.java deleted file mode 100644 index d418974..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/controller/DataSourceController.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.etl.data.source.controller; - -import com.etl.common.core.domain.Result; -import com.etl.common.core.utils.poi.ExcelUtil; -import com.etl.common.core.web.controller.BaseController; -import com.etl.common.core.web.page.TableDataInfo; -import com.etl.common.log.annotation.Log; -import com.etl.common.log.enums.BusinessType; -import com.etl.common.security.annotation.RequiresPermissions; -import com.etl.data.source.domain.DataSource; -import com.etl.data.source.domain.resp.DataSourceResp; -import com.etl.data.source.service.IDataSourceService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; - -/** - * 数据源信息Controller - * - * @author Chao - * @date 2024-04-21 - */ -@RestController -@RequestMapping("/source") -public class DataSourceController extends BaseController { - @Autowired - private IDataSourceService dataSourceService; - - /** - * 查询数据源信息列表 - */ - @RequiresPermissions("data:source:list") - @GetMapping("/list") - public Result> list(DataSource dataSource) { - startPage(); - List list = dataSourceService.selectDataSourceList(dataSource); - return getDataTable(list); - } - - /** - * 导出数据源信息列表 - */ - @RequiresPermissions("data:source:export") - @Log(title = "数据源信息", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, DataSource dataSource) { - List list = dataSourceService.selectDataSourceList(dataSource); - ExcelUtil util = new ExcelUtil(DataSourceResp.class); - util.exportExcel(response, list, "数据源信息数据"); - } - - /** - * 获取数据源信息详细信息 - */ - @RequiresPermissions("data:source:query") - @GetMapping(value = "/{id}") - public Result getInfo(@PathVariable("id") Long id) { - return success(dataSourceService.selectDataSourceById(id)); - } - - /** - * 新增数据源信息 - */ - @RequiresPermissions("data:source:add") - @Log(title = "数据源信息", businessType = BusinessType.INSERT) - @PostMapping - public Result add(@RequestBody DataSource dataSource) { - return toAjax(dataSourceService.insertDataSource(dataSource)); - } - - /** - * 修改数据源信息 - */ - @RequiresPermissions("data:source:edit") - @Log(title = "数据源信息", businessType = BusinessType.UPDATE) - @PutMapping - public Result edit(@RequestBody DataSource dataSource) { - return toAjax(dataSourceService.updateDataSource(dataSource)); - } - - /** - * 删除数据源信息 - */ - @RequiresPermissions("data:source:remove") - @Log(title = "数据源信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public Result remove(@PathVariable Long[] ids) { - return toAjax(dataSourceService.deleteDataSourceByIds(ids)); - } - - /** - * 测试链接 - * @param id 数据源id - * @return - */ - @RequiresPermissions("data:source:testConnection") - @PostMapping(value = "testConnection/{id}") - public Result testConnection(@PathVariable("id") Long id) { - return Result.success(dataSourceService.testConnection(id)); - } - - /** - * 资产同步 - * @param id 数据源id - * @return - */ - @RequiresPermissions("data:source:assetSynchronization") - @PostMapping(value = "assetSynchronization/{id}") - public Result assetSynchronization(@PathVariable("id") Long id) { - return Result.success(dataSourceService.assetSynchronization(id)); - } - -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/mapper/DataSourceMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/mapper/DataSourceMapper.java deleted file mode 100644 index 252dac0..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/mapper/DataSourceMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etl.data.source.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.etl.data.source.domain.DataSource; - -import java.util.List; - -/** - * 数据源信息Mapper接口 - * - * @author Chao - * @date 2024-04-21 - */ -public interface DataSourceMapper extends BaseMapper { - /** - * 查询数据源信息 - * - * @param id 数据源信息主键 - * @return 数据源信息 - */ - public DataSource selectDataSourceById(Long id); - - /** - * 查询数据源信息列表 - * - * @param dataSource 数据源信息 - * @return 数据源信息集合 - */ - public List selectDataSourceList(DataSource dataSource); - - /** - * 新增数据源信息 - * - * @param dataSource 数据源信息 - * @return 结果 - */ - public int insertDataSource(DataSource dataSource); - - /** - * 修改数据源信息 - * - * @param dataSource 数据源信息 - * @return 结果 - */ - public int updateDataSource(DataSource dataSource); - - /** - * 删除数据源信息 - * - * @param id 数据源信息主键 - * @return 结果 - */ - public int deleteDataSourceById(Long id); - - /** - * 批量删除数据源信息 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteDataSourceByIds(Long[] ids); -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/IDataSourceService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/IDataSourceService.java deleted file mode 100644 index b9b94d5..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/IDataSourceService.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.etl.data.source.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.etl.data.source.domain.DataSource; -import com.etl.data.source.domain.resp.DataSourceResp; - -import java.util.List; - -/** - * 数据源信息Service接口 - * - * @author Chao - * @date 2024-04-21 - */ -public interface IDataSourceService extends IService { - /** - * 查询数据源信息 - * - * @param id 数据源信息主键 - * @return 数据源信息 - */ - public DataSource selectDataSourceById(Long id); - - /** - * 查询数据源信息列表 - * - * @param dataSource 数据源信息 - * @return 数据源信息集合 - */ - public List selectDataSourceList(DataSource dataSource); - - /** - * 新增数据源信息 - * - * @param dataSource 数据源信息 - * @return 结果 - */ - public int insertDataSource(DataSource dataSource); - - /** - * 修改数据源信息 - * - * @param dataSource 数据源信息 - * @return 结果 - */ - public int updateDataSource(DataSource dataSource); - - /** - * 批量删除数据源信息 - * - * @param ids 需要删除的数据源信息主键集合 - * @return 结果 - */ - public int deleteDataSourceByIds(Long[] ids); - - /** - * 删除数据源信息信息 - * - * @param id 数据源信息主键 - * @return 结果 - */ - public int deleteDataSourceById(Long id); - - /** - * 测试连接 - * @param id 数据源id - */ - boolean testConnection(Long id); - - /** - * 资产同步 - * @param id 数据源id - * @return - */ - boolean assetSynchronization(Long id); -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/impl/DataSourceServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/impl/DataSourceServiceImpl.java deleted file mode 100644 index 9c6698d..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/source/service/impl/DataSourceServiceImpl.java +++ /dev/null @@ -1,420 +0,0 @@ -package com.etl.data.source.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.etl.common.core.utils.DateUtils; -import com.etl.data.source.domain.DataSource; -import com.etl.data.source.domain.resp.DataSourceResp; -import com.etl.data.source.mapper.DataSourceMapper; -import com.etl.data.source.service.IDataSourceService; -import com.etl.data.structure.domain.AssetStructure; -import com.etl.data.structure.domain.AssetStructureTable; -import com.etl.data.structure.service.IAssetStructureService; -import com.etl.data.structure.service.IAssetStructureTableService; -import com.etl.data.type.domain.DataType; -import com.etl.data.type.service.IDataTypeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import redis.clients.jedis.Jedis; - -import java.sql.*; -import java.util.ArrayList; -import java.util.List; - -/** - * 数据源信息Service业务层处理 - * - * @author Chao - * @date 2024-04-21 - */ -@Service -public class DataSourceServiceImpl extends ServiceImpl implements IDataSourceService { - @Autowired - private DataSourceMapper dataSourceMapper; - - @Autowired - private IDataTypeService dataTypeService; - - @Autowired - private IAssetStructureService assetStructureService; - - @Autowired - private IAssetStructureTableService assetStructureTableService; - - /** - * 查询数据源信息 - * - * @param id 数据源信息主键 - * @return 数据源信息 - */ - @Override - public DataSource selectDataSourceById(Long id) { - return dataSourceMapper.selectDataSourceById(id); - } - - /** - * 查询数据源信息列表 - * - * @param dataSource 数据源信息 - * @return 数据源信息 - */ - @Override - public List selectDataSourceList(DataSource dataSource) { - List dataSources = dataSourceMapper.selectDataSourceList(dataSource); - List dataTypeList = dataTypeService.list(); - List dataSourceResps = new ArrayList<>(); - dataSources.stream() - .flatMap(source -> - dataTypeList.stream() - .filter(dataType -> dataType.getId().equals(source.getTypeId())) - .map(dataType -> DataSourceResp.dataSourceBuilder(source, dataType)) - ).forEach(dataSourceResps::add); - return dataSourceResps; - } - - /** - * 新增数据源信息 - * - * @param dataSource 数据源信息 - * @return 结果 - */ - @Override - public int insertDataSource(DataSource dataSource) { - dataSource.setCreateTime(DateUtils.getNowDate()); - return dataSourceMapper.insertDataSource(dataSource); - } - - /** - * 修改数据源信息 - * - * @param dataSource 数据源信息 - * @return 结果 - */ - @Override - public int updateDataSource(DataSource dataSource) { - dataSource.setUpdateTime(DateUtils.getNowDate()); - return dataSourceMapper.updateDataSource(dataSource); - } - - /** - * 批量删除数据源信息 - * - * @param ids 需要删除的数据源信息主键 - * @return 结果 - */ - @Override - public int deleteDataSourceByIds(Long[] ids) { - return dataSourceMapper.deleteDataSourceByIds(ids); - } - - /** - * 删除数据源信息信息 - * - * @param id 数据源信息主键 - * @return 结果 - */ - @Override - public int deleteDataSourceById(Long id) { - return dataSourceMapper.deleteDataSourceById(id); - } - - /** - * 测试连接 - * - * @param id 数据源id - */ - @Override - public boolean testConnection(Long id) { - DataSource dataSource = this.getOne( - new LambdaQueryWrapper() - .eq(DataSource::getId, id) - ); - String jdbcUrl = ""; - String driveClass = ""; - boolean flag = false; - DataType dataType = dataTypeService.getOne( - new LambdaQueryWrapper() - .eq(DataType::getId, dataSource.getTypeId()) - ); - try { - if (dataType.getDriverManager() != null && dataType.getJdbcPre() != null) { - if ("mysql".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + "/" + dataSource.getDataSourceDatabaseName() + "?" + dataSource.getAdditionalConfiguration(); - } - if ("oracle".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ":" + dataSource.getDataSourceDatabaseName(); - } - if ("sqlserver".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ";databaseName=" + dataSource.getDataSourceDatabaseName(); - } - flag = testDatasource(driveClass, jdbcUrl, dataSource.getDataSourceUsername(), dataSource.getDataSourcePassword()); - } else { - // redis - //连接指定的redis - Jedis jedis = new Jedis(dataSource.getDataSourceIp(), Integer.valueOf(dataSource.getDataSourcePort())); - //如果有密码则需要下面这一行 - if (dataSource.getDataSourcePassword() != null && !dataSource.getDataSourcePassword().equals("")) { - jedis.auth(dataSource.getDataSourcePassword()); - } - //查看服务是否运行,运行正常的话返回一个PONG,否则返回一个连接错误 - try { - jedis.ping(); - flag = true; - } catch (Exception e) { - flag = false; - } - } - if (flag) { - this.update( - new UpdateWrapper() - .set("status", "S") - .eq("id", id) - ); - } else { - this.update( - new UpdateWrapper() - .set("status", "E") - .eq("id", id) - ); - } - return flag; - } catch (Exception e) { - return flag; - } - } - - /** - * 资产同步 - * - * @param id 数据源id - * @return - */ - @Override - @Transactional - public boolean assetSynchronization(Long id) { - DataSource dataSource = this.getOne( - new LambdaQueryWrapper() - .eq(DataSource::getId, id) - ); - // 查询是否存在当前 - AssetStructure assetStructure = assetStructureService.getOne( - new LambdaQueryWrapper() - .eq(AssetStructure::getDataSourceSystemId, id) - ); - boolean b = this.testConnection(id); - if (b) { - // 如果不存在就给他添加资产结构表 - if (assetStructure == null) { - // 构建实体 - AssetStructure entity = AssetStructure.dataSourceSaveBuilder(id, dataSource); - assetStructureService.save(entity); - String jdbcUrl = ""; - String driveClass = ""; - DataType dataType = dataTypeService.getOne( - new LambdaQueryWrapper() - .eq(DataType::getId, dataSource.getTypeId()) - ); - try { - List assetStructureTableList = new ArrayList<>(); - if (dataType.getDriverManager() != null && dataType.getJdbcPre() != null) { - if ("mysql".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + "/" + dataSource.getDataSourceDatabaseName() + "?" + dataSource.getAdditionalConfiguration(); - // 加载数据库驱动 - Class.forName(driveClass); - // 连接数据库 - Connection conn = DriverManager.getConnection(jdbcUrl, dataSource.getDataSourceUsername(), dataSource.getDataSourcePassword()); - Statement st = conn.createStatement(); - ResultSet rs = st.executeQuery("select * from information_schema.tables where TABLE_SCHEMA = " + "'" + dataSource.getDataSourceDatabaseName() + "'"); - while (rs.next()) { - // 获取表名 - String tableName = rs.getString("TABLE_NAME"); - // 表注释 - String tableNameAnnotation = rs.getString("TABLE_COMMENT"); - // 添加数据 - // 表数据数量 - assetStructureTableList.add( - new AssetStructureTable() {{ - setAssetStructureId(entity.getId()); - setTableName(tableName); - setTableNameAnnotation(tableNameAnnotation); - }} - ); - } - assetStructureTableList.stream().forEach(assetStructureTable -> { - try { - ResultSet rs2 = st.executeQuery("select count(*) as countNum from " + assetStructureTable.getTableName()); - while (rs2.next()) { - assetStructureTable.setTableDataCount(rs2.getLong("countNum")); - } - rs2.close(); - } catch (SQLException e) { - - } - }); - conn.close(); - st.close(); - rs.close(); - // 批量插入 - assetStructureTableService.saveBatch(assetStructureTableList); - } - if ("oracle".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ":" + dataSource.getDataSourceDatabaseName(); - } - if ("sqlserver".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ";databaseName=" + dataSource.getDataSourceDatabaseName(); - } - - } else { - // redis - //连接指定的redis - Jedis jedis = new Jedis(dataSource.getDataSourceIp(), Integer.valueOf(dataSource.getDataSourcePort())); - //如果有密码则需要下面这一行 - if (dataSource.getDataSourcePassword() != null && !dataSource.getDataSourcePassword().equals("")) { - jedis.auth(dataSource.getDataSourcePassword()); - } - //查看服务是否运行,运行正常的话返回一个PONG,否则返回一个连接错误 - try { - jedis.ping(); - - } catch (Exception e) { - - } - } - } catch (Exception e) { - System.out.println(e); - return false; - } - } else { // 如果他存在就给他修改 - AssetStructure entity = AssetStructure.dataSourceUpdateBuilder(assetStructure, id, dataSource); - - // 修改资产结构 - assetStructureService.update( - entity, new LambdaUpdateWrapper() - .eq(AssetStructure::getId, entity.getId()) - ); - - // 删除资产结构表信息 - assetStructureTableService.remove( - new LambdaQueryWrapper() - .eq(AssetStructureTable::getAssetStructureId, entity.getId()) - ); - - String jdbcUrl = ""; - String driveClass = ""; - DataType dataType = dataTypeService.getOne( - new LambdaQueryWrapper() - .eq(DataType::getId, dataSource.getTypeId()) - ); - try { - List assetStructureTableList = new ArrayList<>(); - if (dataType.getDriverManager() != null && dataType.getJdbcPre() != null) { - if ("mysql".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + "/" + dataSource.getDataSourceDatabaseName() + "?" + dataSource.getAdditionalConfiguration(); - // 加载数据库驱动 - Class.forName(driveClass); - // 连接数据库 - Connection conn = DriverManager.getConnection(jdbcUrl, dataSource.getDataSourceUsername(), dataSource.getDataSourcePassword()); - Statement st = conn.createStatement(); - ResultSet rs = st.executeQuery("select * from information_schema.tables where TABLE_SCHEMA = " + "'" + dataSource.getDataSourceDatabaseName() + "'"); - while (rs.next()) { - // 获取表名 - String tableName = rs.getString("TABLE_NAME"); - // 表注释 - String tableNameAnnotation = rs.getString("TABLE_COMMENT"); - // 添加数据 - // 表数据数量 - assetStructureTableList.add( - new AssetStructureTable() {{ - setAssetStructureId(entity.getId()); - setTableName(tableName); - setTableNameAnnotation(tableNameAnnotation); - }} - ); - } - assetStructureTableList.stream().forEach(assetStructureTable -> { - try { - ResultSet rs2 = st.executeQuery("select count(*) as countNum from " + assetStructureTable.getTableName()); - while (rs2.next()) { - assetStructureTable.setTableDataCount(rs2.getLong("countNum")); - } - rs2.close(); - } catch (SQLException e) { - - } - }); - conn.close(); - st.close(); - rs.close(); - // 批量插入 - assetStructureTableService.saveBatch(assetStructureTableList); - } - if ("oracle".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ":" + dataSource.getDataSourceDatabaseName(); - } - if ("sqlserver".equals(dataType.getDataType())) { - driveClass = dataType.getDriverManager(); - jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ";databaseName=" + dataSource.getDataSourceDatabaseName(); - } - - } else { - // redis - //连接指定的redis - Jedis jedis = new Jedis(dataSource.getDataSourceIp(), Integer.valueOf(dataSource.getDataSourcePort())); - //如果有密码则需要下面这一行 - if (dataSource.getDataSourcePassword() != null && !dataSource.getDataSourcePassword().equals("")) { - jedis.auth(dataSource.getDataSourcePassword()); - } - //查看服务是否运行,运行正常的话返回一个PONG,否则返回一个连接错误 - try { - jedis.ping(); - - } catch (Exception e) { - - } - } - } catch (Exception e) { - System.out.println(e); - return false; - } - } - } else { - // 如果连接失败并存在就给他删除 - if (assetStructure != null) { - // 删除 - assetStructureService.removeById(assetStructure.getId()); - } - return false; - } - return true; - } - - /** - * 测试数据源连接是否有效 - * - * @param driveClass 驱动类 - * @param url 连接 - * @param username 用户名 - * @param password 密码 - * @return 布尔 - */ - public static boolean testDatasource(String driveClass, String url, String username, String password) { - try { - Class.forName(driveClass); - DriverManager.getConnection(url, username, password); - return true; - } catch (Exception e) { - return false; - } - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureController.java deleted file mode 100644 index 8938788..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureController.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.etl.data.structure.controller; - -import com.etl.common.core.domain.Result; -import com.etl.common.security.annotation.RequiresPermissions; -import com.etl.data.structure.domain.resp.AssetStructureResp; -import com.etl.data.structure.service.IAssetStructureService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 数据资产 Controller 层 - * - * @author Chao - * @ClassName: AssetStructureController 数据资产 Controller 层 - * @CreateTime: 2024/4/22 上午10:09 - */ -@RestController -@RequestMapping("/structure") -public class AssetStructureController { - - @Autowired - private IAssetStructureService assetStructureService; - - /** - * 查询数据源信息列表 - */ - @RequiresPermissions("data:structure:list") - @PostMapping("/list") - public Result list() { - return Result.success(assetStructureService.selectAssetSouructureList()); - } - - -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureTableController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureTableController.java deleted file mode 100644 index 227ff9d..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/controller/AssetStructureTableController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etl.data.structure.controller; - -import com.etl.common.core.domain.Result; -import com.etl.common.security.annotation.RequiresPermissions; -import com.etl.data.structure.domain.AssetStructureTable; -import com.etl.data.structure.service.IAssetStructureTableService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * 数据资产表 Controller 层 - * - * @author Chao - * @ClassName: AssetStructureTableController 数据资产表 Controller 层 - * @CreateTime: 2024/4/22 下午7:28 - */ -@RestController -@RequestMapping("/structureTable") -public class AssetStructureTableController { - - @Autowired - private IAssetStructureTableService assetStructureTableService; - - /** - * 查询所有的表 - * @param assetStructureId - * @return - */ - @RequiresPermissions("data:structureTable:list") - @PostMapping("list/{assetStructureId}") - public Result> list(@PathVariable("assetStructureId") Long assetStructureId) { - return Result.success(assetStructureTableService.selectAssetSouructureTableList(assetStructureId)); - } - -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureMapper.java deleted file mode 100644 index de8f141..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etl.data.structure.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.etl.data.structure.domain.AssetStructure; - -/** - * 数据资产Mapper接口 - * - * @author Chao - * @ClassName: AssetStructureMapper 数据资产Mapper - * @CreateTime: 2024/4/22 下午2:12 - */ -public interface AssetStructureMapper extends BaseMapper { -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureTableMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureTableMapper.java deleted file mode 100644 index 465137d..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/mapper/AssetStructureTableMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etl.data.structure.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.etl.data.structure.domain.AssetStructureTable; - -/** - * 资产结构Mapper接口 - * - * @author Chao - * @ClassName: AssetStructureTableMapper 资产结构Mapper接口 - * @CreateTime: 2024/4/22 下午5:23 - */ -public interface AssetStructureTableMapper extends BaseMapper { -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureService.java deleted file mode 100644 index 0c221ef..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etl.data.structure.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.etl.data.structure.domain.AssetStructure; -import com.etl.data.structure.domain.resp.AssetStructureResp; - -/** - * 数据资产Service 接口 - * - * @author Chao - * @ClassName: IAssetStructureService 数据资产Service 接口 - * @CreateTime: 2024/4/22 下午2:08 - */ -public interface IAssetStructureService extends IService { - /** - * 查询数据资产列表 - * - * @return 数据资产集合 - */ - AssetStructureResp selectAssetSouructureList(); - -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureTableService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureTableService.java deleted file mode 100644 index be1a4fb..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/IAssetStructureTableService.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etl.data.structure.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.etl.data.structure.domain.AssetStructureTable; - -import java.util.List; - -/** - * 资产结构表表Service接口 - * - * @author Chao - * @ClassName: IAssetStructureTableService 资产结构表表Service接口 - * @CreateTime: 2024/4/22 下午5:21 - */ -public interface IAssetStructureTableService extends IService { - /** - * 查询该数据资产表 - * @param assetStructureId 数据资产id - * @return - */ - List selectAssetSouructureTableList(Long assetStructureId ); - -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureServiceImpl.java deleted file mode 100644 index f3f20a5..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.etl.data.structure.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.etl.data.structure.domain.AssetStructure; -import com.etl.data.structure.domain.AssetStructureTable; -import com.etl.data.structure.domain.resp.AssetStructureResp; -import com.etl.data.structure.mapper.AssetStructureMapper; -import com.etl.data.structure.service.IAssetStructureService; -import com.etl.data.structure.service.IAssetStructureTableService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 数据资产Service 业务实现层 - * - * @author Chao - * @ClassName: AssetStructureServiceImpl 数据资产Service 业务实现层 - * @CreateTime: 2024/4/22 下午2:10 - */ -@Service -public class AssetStructureServiceImpl extends ServiceImpl implements IAssetStructureService { - - @Autowired - private IAssetStructureTableService assetStructureTableService; - - - /** - * 查询数据资产列表 - * - * @return 数据资产列表 - */ - @Override - public AssetStructureResp selectAssetSouructureList() { - // 创建一个列表 - List assetStructureList = this.list(); - - List assetStructureTableList = assetStructureTableService.list(); - - // 统计数据 - long assetStructureTableCount = assetStructureTableList.size(); - // 统计数据总数 - long assetStructureTableDataCount; - - - assetStructureTableDataCount = assetStructureTableList.stream().mapToLong(AssetStructureTable::getTableDataCount).sum(); - - return new AssetStructureResp(){{ - setAssetStructureList(assetStructureList); - setAssetStructureTableCount(assetStructureTableCount); - setAssetStructureTableDataCount(assetStructureTableDataCount); - }}; - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureTableServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureTableServiceImpl.java deleted file mode 100644 index a6cb49d..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/structure/service/impl/AssetStructureTableServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etl.data.structure.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.etl.data.structure.domain.AssetStructureTable; -import com.etl.data.structure.mapper.AssetStructureTableMapper; -import com.etl.data.structure.service.IAssetStructureTableService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 资产结构表表Service业务实现层 - * - * @author Chao - * @ClassName: AssetStructureTableServiceImpl 资产结构表表Service业务实现层 - * @CreateTime: 2024/4/22 下午5:22 - */ -@Service -public class AssetStructureTableServiceImpl extends ServiceImpl implements IAssetStructureTableService { - /** - * 查询该数据资产表 - * @param assetStructureId 数据资产id - * @return - */ - @Override - public List selectAssetSouructureTableList(Long assetStructureId) { - List list = this.list( - new LambdaQueryWrapper() - .eq(AssetStructureTable::getAssetStructureId, assetStructureId) - ); - return list; - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/controller/DataTypeController.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/controller/DataTypeController.java deleted file mode 100644 index 198babc..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/controller/DataTypeController.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.etl.data.type.controller; - -import com.etl.common.core.domain.Result; -import com.etl.common.core.utils.poi.ExcelUtil; -import com.etl.common.core.web.controller.BaseController; -import com.etl.common.core.web.page.TableDataInfo; -import com.etl.common.log.annotation.Log; -import com.etl.common.log.enums.BusinessType; -import com.etl.common.security.annotation.RequiresPermissions; -import com.etl.data.type.domain.DataType; -import com.etl.data.type.service.IDataTypeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; - -/** - * 数据源类型Controller - * - * @author Chao - * @date 2024-04-21 - */ -@RestController -@RequestMapping("/type") -public class DataTypeController extends BaseController { - @Autowired - private IDataTypeService dataTypeService; - - /** - * 查询数据源类型列表 - */ - @RequiresPermissions("data:type:list") - @GetMapping("/list") - public Result> list(DataType dataType) { - startPage(); - List list = dataTypeService.selectDataTypeList(dataType); - return getDataTable(list); - } - - /** - * 导出数据源类型列表 - */ - @RequiresPermissions("data:type:export") - @Log(title = "数据源类型", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, DataType dataType) { - List list = dataTypeService.selectDataTypeList(dataType); - ExcelUtil util = new ExcelUtil(DataType.class); - util.exportExcel(response, list, "数据源类型数据"); - } - - /** - * 获取数据源类型详细信息 - */ - @RequiresPermissions("data:type:query") - @GetMapping(value = "/{id}") - public Result getInfo(@PathVariable("id") Long id) { - return success(dataTypeService.selectDataTypeById(id)); - } - - /** - * 新增数据源类型 - */ - @RequiresPermissions("data:type:add") - @Log(title = "数据源类型", businessType = BusinessType.INSERT) - @PostMapping - public Result add(@RequestBody DataType dataType) { - return toAjax(dataTypeService.insertDataType(dataType)); - } - - /** - * 修改数据源类型 - */ - @RequiresPermissions("data:type:edit") - @Log(title = "数据源类型", businessType = BusinessType.UPDATE) - @PutMapping - public Result edit(@RequestBody DataType dataType) { - return toAjax(dataTypeService.updateDataType(dataType)); - } - - /** - * 删除数据源类型 - */ - @RequiresPermissions("data:type:remove") - @Log(title = "数据源类型", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public Result remove(@PathVariable Long[] ids) { - return toAjax(dataTypeService.deleteDataTypeByIds(ids)); - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/mapper/DataTypeMapper.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/mapper/DataTypeMapper.java deleted file mode 100644 index 57d9f25..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/mapper/DataTypeMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etl.data.type.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.etl.data.type.domain.DataType; - -import java.util.List; - -/** - * 数据源类型Mapper接口 - * - * @author Chao - * @date 2024-04-21 - */ -public interface DataTypeMapper extends BaseMapper { - /** - * 查询数据源类型 - * - * @param id 数据源类型主键 - * @return 数据源类型 - */ - public DataType selectDataTypeById(Long id); - - /** - * 查询数据源类型列表 - * - * @param dataType 数据源类型 - * @return 数据源类型集合 - */ - public List selectDataTypeList(DataType dataType); - - /** - * 新增数据源类型 - * - * @param dataType 数据源类型 - * @return 结果 - */ - public int insertDataType(DataType dataType); - - /** - * 修改数据源类型 - * - * @param dataType 数据源类型 - * @return 结果 - */ - public int updateDataType(DataType dataType); - - /** - * 删除数据源类型 - * - * @param id 数据源类型主键 - * @return 结果 - */ - public int deleteDataTypeById(Long id); - - /** - * 批量删除数据源类型 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteDataTypeByIds(Long[] ids); -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/IDataTypeService.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/IDataTypeService.java deleted file mode 100644 index 497d092..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/IDataTypeService.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etl.data.type.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.etl.data.type.domain.DataType; - -import java.util.List; - -/** - * 数据源类型Service接口 - * - * @author Chao - * @date 2024-04-21 - */ -public interface IDataTypeService extends IService { - /** - * 查询数据源类型 - * - * @param id 数据源类型主键 - * @return 数据源类型 - */ - public DataType selectDataTypeById(Long id); - - /** - * 查询数据源类型列表 - * - * @param dataType 数据源类型 - * @return 数据源类型集合 - */ - public List selectDataTypeList(DataType dataType); - - /** - * 新增数据源类型 - * - * @param dataType 数据源类型 - * @return 结果 - */ - public int insertDataType(DataType dataType); - - /** - * 修改数据源类型 - * - * @param dataType 数据源类型 - * @return 结果 - */ - public int updateDataType(DataType dataType); - - /** - * 批量删除数据源类型 - * - * @param ids 需要删除的数据源类型主键集合 - * @return 结果 - */ - public int deleteDataTypeByIds(Long[] ids); - - /** - * 删除数据源类型信息 - * - * @param id 数据源类型主键 - * @return 结果 - */ - public int deleteDataTypeById(Long id); -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/impl/DataTypeServiceImpl.java b/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/impl/DataTypeServiceImpl.java deleted file mode 100644 index 5f076d2..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/java/com/etl/data/type/service/impl/DataTypeServiceImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.etl.data.type.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.etl.common.core.utils.DateUtils; -import com.etl.data.type.domain.DataType; -import com.etl.data.type.mapper.DataTypeMapper; -import com.etl.data.type.service.IDataTypeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 数据源类型Service业务层处理 - * - * @author Chao - * @date 2024-04-21 - */ -@Service -public class DataTypeServiceImpl extends ServiceImpl implements IDataTypeService { - @Autowired - private DataTypeMapper dataTypeMapper; - - /** - * 查询数据源类型 - * - * @param id 数据源类型主键 - * @return 数据源类型 - */ - @Override - public DataType selectDataTypeById(Long id) { - return dataTypeMapper.selectDataTypeById(id); - } - - /** - * 查询数据源类型列表 - * - * @param dataType 数据源类型 - * @return 数据源类型 - */ - @Override - public List selectDataTypeList(DataType dataType) { - return dataTypeMapper.selectDataTypeList(dataType); - } - - /** - * 新增数据源类型 - * - * @param dataType 数据源类型 - * @return 结果 - */ - @Override - public int insertDataType(DataType dataType) { - dataType.setCreateTime(DateUtils.getNowDate()); - dataType.setDataType(lowerCase(dataType.getDataType())); - return dataTypeMapper.insertDataType(dataType); - } - - /** - * 修改数据源类型 - * - * @param dataType 数据源类型 - * @return 结果 - */ - @Override - public int updateDataType(DataType dataType) { - dataType.setUpdateTime(DateUtils.getNowDate()); - dataType.setDataType(lowerCase(dataType.getDataType())); - return dataTypeMapper.updateDataType(dataType); - } - - /** - * 批量删除数据源类型 - * - * @param ids 需要删除的数据源类型主键 - * @return 结果 - */ - @Override - public int deleteDataTypeByIds(Long[] ids) { - return dataTypeMapper.deleteDataTypeByIds(ids); - } - - /** - * 删除数据源类型信息 - * - * @param id 数据源类型主键 - * @return 结果 - */ - @Override - public int deleteDataTypeById(Long id) { - return dataTypeMapper.deleteDataTypeById(id); - } - - /** - * 将所有的大写转换成小写并清除中间所有的空格 - * @param str 需要转换的参数 - * @return 转换后的参数 - */ - public static String lowerCase(String str){ - return str.toLowerCase().replaceAll(" ",""); - } -} diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/bootstrap.yml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/bootstrap.yml index bdd3d41..4160fb2 100644 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/bootstrap.yml +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/bootstrap.yml @@ -31,4 +31,4 @@ spring: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} logging: level: - com.etl.shop.cart.mapper: DEBUG + com.etl.data.mapper: DEBUG diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/AssetsModelMqpper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/AssetsModelMqpper.xml new file mode 100644 index 0000000..223dae1 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/AssetsModelMqpper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataManagerMqpper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataManagerMqpper.xml new file mode 100644 index 0000000..d9a976b --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataManagerMqpper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataSourceMapper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataSourceMapper.xml deleted file mode 100644 index 6c1e67c..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataSourceMapper.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - select id, data_source_name, data_source_system_name, type_id, data_source_ip, data_source_port, data_source_database_name, data_source_username, data_source_password, additional_configuration, status, remark, initial_number_of_connections, maximum_number_of_connections, maximum_waiting_time, maximum_waiting_times, create_by, create_time, update_by, update_time from data_source - - - - - - - - insert into data_source - - data_source_name, - data_source_system_name, - type_id, - data_source_ip, - data_source_port, - data_source_database_name, - data_source_username, - data_source_password, - additional_configuration, - status, - remark, - initial_number_of_connections, - maximum_number_of_connections, - maximum_waiting_time, - maximum_waiting_times, - create_by, - create_time, - update_by, - update_time, - - - #{dataSourceName}, - #{dataSourceSystemName}, - #{typeId}, - #{dataSourceIp}, - #{dataSourcePort}, - #{dataSourceDatabaseName}, - #{dataSourceUsername}, - #{dataSourcePassword}, - #{additionalConfiguration}, - #{status}, - #{remark}, - #{initialNumberOfConnections}, - #{maximumNumberOfConnections}, - #{maximumWaitingTime}, - #{maximumWaitingTimes}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - - - - - update data_source - - data_source_name = #{dataSourceName}, - data_source_system_name = #{dataSourceSystemName}, - type_id = #{typeId}, - data_source_ip = #{dataSourceIp}, - data_source_port = #{dataSourcePort}, - data_source_database_name = #{dataSourceDatabaseName}, - data_source_username = #{dataSourceUsername}, - data_source_password = #{dataSourcePassword}, - additional_configuration = #{additionalConfiguration}, - status = #{status}, - remark = #{remark}, - initial_number_of_connections = #{initialNumberOfConnections}, - maximum_number_of_connections = #{maximumNumberOfConnections}, - maximum_waiting_time = #{maximumWaitingTime}, - maximum_waiting_times = #{maximumWaitingTimes}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - - where id = #{id} - - - - delete from data_source where id = #{id} - - - - delete from data_source where id in - - #{id} - - - diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTableMqpper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTableMqpper.xml new file mode 100644 index 0000000..6f0c543 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTableMqpper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMapper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMapper.xml deleted file mode 100644 index e15b4b4..0000000 --- a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMapper.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - select id, data_type, driver_manager, jdbc_pre, remark, create_by, create_time, update_by, update_time from data_type - - - - - - - - insert into data_type - - data_type, - driver_manager, - jdbc_pre, - remark, - create_by, - create_time, - update_by, - update_time, - - - #{dataType}, - #{driverManager}, - #{jdbcPre}, - #{remark}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - - - - - update data_type - - data_type = #{dataType}, - driver_manager = #{driverManager}, - jdbc_pre = #{jdbcPre}, - remark = #{remark}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - - where id = #{id} - - - - delete from data_type where id = #{id} - - - - delete from data_type where id in - - #{id} - - - diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMqpper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMqpper.xml new file mode 100644 index 0000000..cfe1bdc --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DataTypeMqpper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryInfoMqpper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryInfoMqpper.xml new file mode 100644 index 0000000..fe672b4 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryInfoMqpper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryMqpper.xml b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryMqpper.xml new file mode 100644 index 0000000..25c1f27 --- /dev/null +++ b/etl-modules/etl-data-source/etl-data-source-server/src/main/resources/mapper/data/DictionaryMqpper.xml @@ -0,0 +1,7 @@ + + + + +