init
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>data-masterdata-service-parent</artifactId>
|
||||
<groupId>com.platform</groupId>
|
||||
<version>0.4.x</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.4.x</version>
|
||||
<artifactId>data-masterdata-service-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
<!--feign 依赖-->
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>0.4.x</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.datax.service.data.masterdata.api.dto;
|
||||
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 实体DTO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@ApiModel(value = "主数据模型列信息表Model")
|
||||
@Data
|
||||
public class ModelColumnDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
// @NotBlank(message = "主键ID不能为空", groups = {ValidationGroups.Update.class})
|
||||
private String id;
|
||||
@ApiModelProperty(value = "列名称")
|
||||
@NotBlank(message = "列名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String columnName;
|
||||
@ApiModelProperty(value = "列描述")
|
||||
@NotBlank(message = "列描述不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String columnComment;
|
||||
@ApiModelProperty(value = "列类型")
|
||||
@NotBlank(message = "列类型不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String columnType;
|
||||
@ApiModelProperty(value = "列长度")
|
||||
private String columnLength;
|
||||
@ApiModelProperty(value = "列小数位数")
|
||||
private String columnScale;
|
||||
@ApiModelProperty(value = "列默认值")
|
||||
private String defaultValue;
|
||||
@ApiModelProperty(value = "是否系统默认(0否,1是)")
|
||||
private String isSystem;
|
||||
@ApiModelProperty(value = "是否主键(0否,1是)")
|
||||
private String isPk;
|
||||
@ApiModelProperty(value = "是否必填(0否,1是)")
|
||||
private String isRequired;
|
||||
@ApiModelProperty(value = "是否为插入字段(0否,1是)")
|
||||
private String isInsert;
|
||||
@ApiModelProperty(value = "是否编辑字段(0否,1是)")
|
||||
private String isEdit;
|
||||
@ApiModelProperty(value = "是否详情字段(0否,1是)")
|
||||
private String isDetail;
|
||||
@ApiModelProperty(value = "是否列表字段(0否,1是)")
|
||||
private String isList;
|
||||
@ApiModelProperty(value = "是否查询字段(0否,1是)")
|
||||
private String isQuery;
|
||||
@ApiModelProperty(value = "查询方式(EQ等于、NE不等于、GT大于、GE大于等于、LT小于、LE小于等于、LIKE模糊、BETWEEN范围)")
|
||||
private String queryType;
|
||||
@ApiModelProperty(value = "显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件)")
|
||||
private String htmlType;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "是否绑定数据标准(0否,1是)")
|
||||
private String isBindDict;
|
||||
@ApiModelProperty(value = "绑定数据标准类别")
|
||||
private String bindDictTypeId;
|
||||
@ApiModelProperty(value = "绑定数据标准字典字段(GB_CODE,GB_NAME)")
|
||||
private String bindDictColumn;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.datax.service.data.masterdata.api.dto;
|
||||
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 实体DTO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@ApiModel(value = "主数据模型表Model")
|
||||
@Data
|
||||
public class ModelDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@NotBlank(message = "主键ID不能为空", groups = {ValidationGroups.Update.class})
|
||||
private String id;
|
||||
@ApiModelProperty(value = "模型名称")
|
||||
@NotBlank(message = "模型名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String modelName;
|
||||
@ApiModelProperty(value = "逻辑表")
|
||||
@NotBlank(message = "逻辑表不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String modelLogicTable;
|
||||
@ApiModelProperty(value = "模型列信息")
|
||||
@Valid
|
||||
@NotEmpty(message = "模型列信息不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
@Size(min = 1, message="模型列信息长度不能少于{min}位")
|
||||
private List<ModelColumnDto> modelColumns;
|
||||
@ApiModelProperty(value = "状态")
|
||||
@NotNull(message = "状态不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String status;
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package cn.datax.service.data.masterdata.api.entity;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
|
||||
import cn.datax.service.data.masterdata.api.parser.ColumnParser;
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
import cn.datax.service.data.masterdata.api.parser.mysql.MysqlColumnParser;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import cn.datax.common.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("masterdata_model_column")
|
||||
public class ModelColumnEntity extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 模型表主键
|
||||
*/
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* 列名称
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 列描述
|
||||
*/
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
* 列类型
|
||||
*/
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 列长度
|
||||
*/
|
||||
private String columnLength;
|
||||
|
||||
/**
|
||||
* 列小数位数
|
||||
*/
|
||||
private String columnScale;
|
||||
|
||||
/**
|
||||
* 列默认值
|
||||
*/
|
||||
private String defaultValue;
|
||||
|
||||
/**
|
||||
* 是否系统默认(0否,1是)
|
||||
*/
|
||||
private String isSystem;
|
||||
|
||||
/**
|
||||
* 是否主键(0否,1是)
|
||||
*/
|
||||
private String isPk;
|
||||
|
||||
/**
|
||||
* 是否必填(0否,1是)
|
||||
*/
|
||||
private String isRequired;
|
||||
|
||||
/**
|
||||
* 是否为插入字段(0否,1是)
|
||||
*/
|
||||
private String isInsert;
|
||||
|
||||
/**
|
||||
* 是否编辑字段(0否,1是)
|
||||
*/
|
||||
private String isEdit;
|
||||
|
||||
/**
|
||||
* 是否详情字段(0否,1是)
|
||||
*/
|
||||
private String isDetail;
|
||||
|
||||
/**
|
||||
* 是否列表字段(0否,1是)
|
||||
*/
|
||||
private String isList;
|
||||
|
||||
/**
|
||||
* 是否查询字段(0否,1是)
|
||||
*/
|
||||
private String isQuery;
|
||||
|
||||
/**
|
||||
* 查询方式(EQ等于、NE不等于、GT大于、GE大于等于、LT小于、LE小于等于、LIKE模糊、BETWEEN范围)
|
||||
*/
|
||||
private String queryType;
|
||||
|
||||
/**
|
||||
* 是否绑定数据标准(0否,1是)
|
||||
*/
|
||||
private String isBindDict;
|
||||
|
||||
/**
|
||||
* 绑定数据标准类别
|
||||
*/
|
||||
private String bindDictTypeId;
|
||||
|
||||
/**
|
||||
* 绑定数据标准字典字段(GB_CODE,GB_NAME)
|
||||
*/
|
||||
private String bindDictColumn;
|
||||
|
||||
/**
|
||||
* 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件)
|
||||
*/
|
||||
private String htmlType;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String columnDefinition;
|
||||
|
||||
public String getColumnDefinition() {
|
||||
ColumnParser columnParser = new MysqlColumnParser();
|
||||
DataType parse = columnParser.mysqlParse(MysqlDataTypeEnum.match(this.columnType, MysqlDataTypeEnum.VARCHAR));
|
||||
return parse.fillTypeString(this.columnLength, this.columnScale);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.datax.service.data.masterdata.api.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ModelCommentEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
private String comment;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.datax.service.data.masterdata.api.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ModelDataEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String tableName;
|
||||
private String id;
|
||||
private Map<String, Object> datas;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.datax.service.data.masterdata.api.entity;
|
||||
|
||||
import cn.datax.common.base.DataFlowBaseEntity;
|
||||
import cn.datax.common.base.DataScopeBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "masterdata_model", resultMap = "BaseResultMap")
|
||||
public class ModelEntity extends DataFlowBaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 逻辑表
|
||||
*/
|
||||
private String modelLogicTable;
|
||||
|
||||
/**
|
||||
* 物理表
|
||||
*/
|
||||
private String modelPhysicalTable;
|
||||
|
||||
/**
|
||||
* 是否建模(0否,1是)
|
||||
*/
|
||||
private String isSync;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ModelColumnEntity> modelColumns;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.datax.service.data.masterdata.api.enums;
|
||||
|
||||
public enum MysqlDataTypeEnum {
|
||||
|
||||
TINYINT("tinyint", "tinyint整型"), INT("int", "int整型"), BIGINT("bigint", "bigint整型"),
|
||||
FLOAT("float", "单精度"), DOUBLE("double", "双精度"), DECIMAL("decimal", "定点数"),
|
||||
CHAR("char", "定长字符串"), VARCHAR("varchar", "变长字符串"), TEXT("text", "长文本"),
|
||||
DATE("date", "date日期"), TIME("time", "time日期"), YEAR("year", "year日期"), DATETIME("datetime", "datetime日期"),
|
||||
BLOB("blob", "二进制");
|
||||
|
||||
private String value;
|
||||
private String title;
|
||||
|
||||
MysqlDataTypeEnum(String value, String title) {
|
||||
this.value = value;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public static MysqlDataTypeEnum match(String value, MysqlDataTypeEnum defaultItem) {
|
||||
if (value != null) {
|
||||
for (MysqlDataTypeEnum item: MysqlDataTypeEnum.values()) {
|
||||
if (item.getValue().equals(value)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.datax.service.data.masterdata.api.enums;
|
||||
|
||||
public enum OracleDataTypeEnum {
|
||||
|
||||
CHAR("char", "字符串"), NUMBER("number", "数值"), DATE("date", "日期"), CLOB("clob", "长文本"), BLOB("blob", "二进制");
|
||||
|
||||
private String value;
|
||||
private String title;
|
||||
|
||||
OracleDataTypeEnum(String value, String title) {
|
||||
this.value = value;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public static OracleDataTypeEnum match(String value, OracleDataTypeEnum defaultItem) {
|
||||
if (value != null) {
|
||||
for (OracleDataTypeEnum item: OracleDataTypeEnum.values()) {
|
||||
if (item.getValue().equals(value)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
|
||||
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum;
|
||||
|
||||
public abstract class ColumnParser {
|
||||
|
||||
public abstract DataType oracleParse(OracleDataTypeEnum dataTypeEnum);
|
||||
|
||||
public abstract DataType mysqlParse(MysqlDataTypeEnum dataTypeEnum);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.datax.service.data.masterdata.api.parser;
|
||||
|
||||
public interface DataType {
|
||||
|
||||
String fillTypeString(String columnLength, String columnScale);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlBigintDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "bigint";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlBlobDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "blob";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MysqlCharDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "char(" + Optional.ofNullable(columnLength).orElse("1") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.common.exception.DataException;
|
||||
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
|
||||
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum;
|
||||
import cn.datax.service.data.masterdata.api.parser.ColumnParser;
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlColumnParser extends ColumnParser {
|
||||
|
||||
@Override
|
||||
public DataType oracleParse(OracleDataTypeEnum dataTypeEnum) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType mysqlParse(MysqlDataTypeEnum dataTypeEnum) {
|
||||
switch(dataTypeEnum) {
|
||||
case TINYINT:
|
||||
return new MysqlTinyintDataType();
|
||||
case INT:
|
||||
return new MysqlIntDataType();
|
||||
case BIGINT:
|
||||
return new MysqlBigintDataType();
|
||||
case FLOAT:
|
||||
return new MysqlFloatDataType();
|
||||
case DOUBLE:
|
||||
return new MysqlDoubleDataType();
|
||||
case DECIMAL:
|
||||
return new MysqlDecimalDataType();
|
||||
case CHAR:
|
||||
return new MysqlCharDataType();
|
||||
case VARCHAR:
|
||||
return new MysqlVarcharDataType();
|
||||
case TEXT:
|
||||
return new MysqlTextDataType();
|
||||
case DATE:
|
||||
return new MysqlDateDataType();
|
||||
case TIME:
|
||||
return new MysqlTimeDataType();
|
||||
case YEAR:
|
||||
return new MysqlYearDataType();
|
||||
case DATETIME:
|
||||
return new MysqlDatetimeDataType();
|
||||
case BLOB:
|
||||
return new MysqlBlobDataType();
|
||||
default:
|
||||
throw new DataException("字段数据类型错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlDateDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "date";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlDatetimeDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "datetime";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MysqlDecimalDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "decimal(" + Optional.ofNullable(columnLength).orElse("10") + ", " + Optional.ofNullable(columnScale).orElse("2") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MysqlDoubleDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "double(" + Optional.ofNullable(columnLength).orElse("5") + ", " + Optional.ofNullable(columnScale).orElse("2") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MysqlFloatDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "float(" + Optional.ofNullable(columnLength).orElse("5") + ", " + Optional.ofNullable(columnScale).orElse("2") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlIntDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "int";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlTextDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "text";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlTimeDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "time";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlTinyintDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "tinyint";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MysqlVarcharDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "varchar(" + Optional.ofNullable(columnLength).orElse("255") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.mysql;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class MysqlYearDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "year";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.oracle;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class OracleBlobDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "BLOB";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.oracle;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class OracleCharDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "VARCHAR2(" + Optional.ofNullable(columnLength).orElse("255") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.oracle;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class OracleClobDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "CLOB";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.oracle;
|
||||
|
||||
import cn.datax.common.exception.DataException;
|
||||
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
|
||||
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum;
|
||||
import cn.datax.service.data.masterdata.api.parser.ColumnParser;
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class OracleColumnParser extends ColumnParser {
|
||||
|
||||
@Override
|
||||
public DataType oracleParse(OracleDataTypeEnum dataTypeEnum) {
|
||||
switch(dataTypeEnum) {
|
||||
case CHAR:
|
||||
return new OracleCharDataType();
|
||||
case DATE:
|
||||
return new OracleDateDataType();
|
||||
case NUMBER:
|
||||
return new OracleNumberDataType();
|
||||
case CLOB:
|
||||
return new OracleClobDataType();
|
||||
case BLOB:
|
||||
return new OracleBlobDataType();
|
||||
default:
|
||||
throw new DataException("字段数据类型错误");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType mysqlParse(MysqlDataTypeEnum dataTypeEnum) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.oracle;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
public class OracleDateDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "DATE";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.datax.service.data.masterdata.api.parser.oracle;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.parser.DataType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class OracleNumberDataType implements DataType {
|
||||
|
||||
@Override
|
||||
public String fillTypeString(String columnLength, String columnScale) {
|
||||
return "NUMBER(" + Optional.ofNullable(columnLength).orElse("22") + ", " + Optional.ofNullable(columnScale).orElse("0") + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.datax.service.data.masterdata.api.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class Condition implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 数据库字段名
|
||||
*/
|
||||
private String column;
|
||||
|
||||
/**
|
||||
* 字段值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 查询类型,如like,eq,gt,ge,lt,le,eq,ne,between
|
||||
*/
|
||||
private String queryType;
|
||||
|
||||
/**
|
||||
* 查询类型between时left查询字段值
|
||||
*/
|
||||
private String leftValue;
|
||||
|
||||
/**
|
||||
* 查询类型between时right查询字段值
|
||||
*/
|
||||
private String rightValue;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.datax.service.data.masterdata.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ModelColumnQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String modelId;
|
||||
private String columnName;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.datax.service.data.masterdata.api.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelDataQuery implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 数据库表名
|
||||
private String tableName;
|
||||
// 查询条件
|
||||
private List<Condition> conditions;
|
||||
// 查询字段
|
||||
private List<String> columns;
|
||||
|
||||
// 关键字
|
||||
private String keyword;
|
||||
// 当前页码
|
||||
private Integer pageNum = 1;
|
||||
// 分页条数
|
||||
private Integer pageSize = 20;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.masterdata.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ModelQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String modelName;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.datax.service.data.masterdata.api.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 实体VO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Data
|
||||
public class ModelColumnVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String id;
|
||||
private String status;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
private String modelId;
|
||||
private String columnName;
|
||||
private String columnComment;
|
||||
private String columnType;
|
||||
private String columnLength;
|
||||
private String columnScale;
|
||||
private String defaultValue;
|
||||
private String isSystem;
|
||||
private String isPk;
|
||||
private String isRequired;
|
||||
private String isInsert;
|
||||
private String isEdit;
|
||||
private String isDetail;
|
||||
private String isList;
|
||||
private String isQuery;
|
||||
private String queryType;
|
||||
private String isBindDict;
|
||||
private String bindDictTypeId;
|
||||
private String bindDictColumn;
|
||||
private String htmlType;
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.datax.service.data.masterdata.api.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 实体VO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Data
|
||||
public class ModelVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String id;
|
||||
private String status;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
private String modelName;
|
||||
private String modelLogicTable;
|
||||
private String modelPhysicalTable;
|
||||
private String isSync;
|
||||
private String flowStatus;
|
||||
private String processInstanceId;
|
||||
private List<ModelColumnVo> modelColumns;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>data-masterdata-service-parent</artifactId>
|
||||
<groupId>com.platform</groupId>
|
||||
<version>0.4.x</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.4.x</version>
|
||||
<artifactId>data-masterdata-service</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!--web 模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<!--配置中心客户端 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>common-mybatis</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>common-log</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>data-masterdata-service-api</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>data-standard-service-api</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>workflow-service-api</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>common-rabbitmq</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.datax.service.data.masterdata;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@EnableFeignClients(basePackages = {"cn.datax.service.system.api.feign", "cn.datax.service.workflow.api.feign"})
|
||||
@SpringBootApplication
|
||||
public class DataxMasterdataApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataxMasterdataApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.datax.service.data.masterdata.config;
|
||||
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationAdvisor;
|
||||
import com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor;
|
||||
import com.baomidou.dynamic.datasource.processor.DsProcessor;
|
||||
import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider;
|
||||
import com.baomidou.dynamic.datasource.provider.YmlDynamicDataSourceProvider;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceCreatorAutoConfiguration;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.druid.DruidDynamicDataSourceConfiguration;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Role;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 动态数据源核心自动配置类
|
||||
* @author AllDataDC
|
||||
* @date 2023/03/17
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@AllArgsConstructor
|
||||
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
|
||||
@AutoConfigureBefore(DataSourceAutoConfiguration.class)
|
||||
@Import(value = {DruidDynamicDataSourceConfiguration.class, DynamicDataSourceCreatorAutoConfiguration.class})
|
||||
@ConditionalOnProperty(prefix = DynamicDataSourceProperties.PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class DynamicDSConfiguration {
|
||||
|
||||
private final DynamicDataSourceProperties properties;
|
||||
|
||||
//读取多数据源配置,注入到spring容器中
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public DynamicDataSourceProvider dynamicDataSourceProvider() {
|
||||
Map<String, DataSourceProperty> datasourceMap = properties.getDatasource();
|
||||
return new YmlDynamicDataSourceProvider(datasourceMap);
|
||||
}
|
||||
|
||||
//注册自己的动态多数据源DataSource
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public DataSource dataSource(DynamicDataSourceProvider dynamicDataSourceProvider) {
|
||||
DynamicRoutingDataSource dataSource = new DynamicRoutingDataSource();
|
||||
dataSource.setPrimary(properties.getPrimary());
|
||||
dataSource.setStrict(properties.getStrict());
|
||||
dataSource.setStrategy(properties.getStrategy());
|
||||
dataSource.setProvider(dynamicDataSourceProvider);
|
||||
dataSource.setP6spy(properties.getP6spy());
|
||||
dataSource.setSeata(properties.getSeata());
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
//AOP切面,对DS注解过的方法进行增强,达到切换数据源的目的
|
||||
@Role(value = BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public DynamicDataSourceAnnotationAdvisor dynamicDatasourceAnnotationAdvisor(DsProcessor dsProcessor) {
|
||||
DynamicDataSourceAnnotationInterceptor interceptor = new DynamicDataSourceAnnotationInterceptor(properties.isAllowedPublicOnly(), dsProcessor);
|
||||
DynamicDataSourceAnnotationAdvisor advisor = new DynamicDataSourceAnnotationAdvisor(interceptor);
|
||||
advisor.setOrder(properties.getOrder());
|
||||
return advisor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.datax.service.data.masterdata.config;
|
||||
|
||||
import cn.datax.common.rabbitmq.config.RabbitMqConstant;
|
||||
import cn.datax.common.utils.ThrowableUtil;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import cn.datax.service.data.masterdata.dao.ModelDao;
|
||||
import cn.datax.service.workflow.api.enums.VariablesEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class RabbitMqListenerConfig {
|
||||
|
||||
@Autowired
|
||||
private ModelDao modelDao;
|
||||
|
||||
/**
|
||||
* 消费工作流 业务编码 5011
|
||||
* @param map
|
||||
* @param channel
|
||||
* @param message
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RabbitListener(bindings = @QueueBinding(exchange = @Exchange(name = RabbitMqConstant.TOPIC_EXCHANGE_WORKFLOW, type = "topic", durable = "true", autoDelete = "false"),
|
||||
key = { RabbitMqConstant.TOPIC_WORKFLOW_KEY + "5011" },
|
||||
value = @Queue(value = RabbitMqConstant.TOPIC_WORKFLOW_QUEUE, durable = "true", exclusive = "false", autoDelete = "false")))
|
||||
public void fanoutQueueRelease(Map map, Channel channel, Message message) throws Exception {
|
||||
try {
|
||||
log.info("接收到了消息:{}", map);
|
||||
String businessKey = (String) map.get(VariablesEnum.businessKey.toString());
|
||||
String businessCode = (String) map.get(VariablesEnum.businessCode.toString());
|
||||
String flowStatus = (String) map.get("flowStatus");
|
||||
LambdaUpdateWrapper<ModelEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(ModelEntity::getFlowStatus, flowStatus);
|
||||
updateWrapper.eq(ModelEntity::getId, businessKey);
|
||||
modelDao.update(null, updateWrapper);
|
||||
} catch (Exception e) {
|
||||
log.error("全局异常信息ex={}, StackTrace={}", e.getMessage(), ThrowableUtil.getStackTrace(e));
|
||||
if (message.getMessageProperties().getRedelivered()){
|
||||
log.error("消息已处理,请勿重复处理!");
|
||||
// 拒绝消息
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
|
||||
}else {
|
||||
//记录日志
|
||||
log.error("消息消费失败处理:{}", e.getMessage());
|
||||
//第一个参数为消息的index,第二个参数是是否批量处理,第三个参数为是否让被拒绝的消息重新入队列
|
||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
|
||||
}
|
||||
} finally {
|
||||
// 手动确认
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.datax.service.data.masterdata.config;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class StartedUpRunner implements ApplicationRunner {
|
||||
|
||||
private final ConfigurableApplicationContext context;
|
||||
private final Environment environment;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
if (context.isActive()) {
|
||||
String banner = "-----------------------------------------\n" +
|
||||
"服务启动成功,时间:" + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()) + "\n" +
|
||||
"服务名称:" + environment.getProperty("spring.application.name") + "\n" +
|
||||
"端口号:" + environment.getProperty("server.port") + "\n" +
|
||||
"-----------------------------------------";
|
||||
System.out.println(banner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package cn.datax.service.data.masterdata.config;
|
||||
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||
import springfox.documentation.builders.*;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
|
||||
@EnableConfigurationProperties(SwaggerProperties.class)
|
||||
@EnableSwagger2
|
||||
@EnableKnife4j
|
||||
@Import(BeanValidatorPluginsConfiguration.class)
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Autowired
|
||||
private SwaggerProperties swaggerProperties;
|
||||
|
||||
/**
|
||||
* 创建API应用
|
||||
* apiInfo() 增加API相关信息
|
||||
* 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现,
|
||||
* 本例采用指定扫描的包路径来定义指定要建立API的目录。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi(){
|
||||
//版本类型是swagger2
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
//通过调用自定义方法apiInfo,获得文档的主要信息
|
||||
.apiInfo(apiInfo())
|
||||
//设置全局参数
|
||||
.globalOperationParameters(globalParamBuilder())
|
||||
//设置全局响应参数
|
||||
.globalResponseMessage(RequestMethod.GET,responseBuilder())
|
||||
.globalResponseMessage(RequestMethod.POST,responseBuilder())
|
||||
.globalResponseMessage(RequestMethod.PUT,responseBuilder())
|
||||
.globalResponseMessage(RequestMethod.DELETE,responseBuilder())
|
||||
.select()
|
||||
//扫描该包下面的API注解
|
||||
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
//设置安全认证
|
||||
;
|
||||
}
|
||||
/**
|
||||
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
|
||||
* 访问地址:http://项目实际地址/swagger-ui.html
|
||||
* @return
|
||||
*/
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title(swaggerProperties.getTitle())
|
||||
.description(swaggerProperties.getDescription())
|
||||
.termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl())
|
||||
.version(swaggerProperties.getVersion())
|
||||
.contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail()))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全认证参数
|
||||
* @return
|
||||
*/
|
||||
private List<ApiKey> security() {
|
||||
List<ApiKey> apiKeys = new ArrayList<>();
|
||||
apiKeys.add(new ApiKey("Authorization", "Authorization", "header"));
|
||||
return apiKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建全局参数列表
|
||||
* @return
|
||||
*/
|
||||
private List<Parameter> globalParamBuilder(){
|
||||
List<Parameter> pars = new ArrayList<>();
|
||||
pars.add(parameterBuilder("Authorization","令牌","string","header",false).build());
|
||||
return pars;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建参数
|
||||
* @return
|
||||
*/
|
||||
private ParameterBuilder parameterBuilder(String name, String desc, String type, String parameterType, boolean required) {
|
||||
ParameterBuilder tokenPar = new ParameterBuilder();
|
||||
tokenPar.name(name).description(desc).modelRef(new ModelRef(type)).parameterType(parameterType).required(required).build();
|
||||
return tokenPar;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建全局响应值
|
||||
* @return
|
||||
*/
|
||||
private List<ResponseMessage> responseBuilder() {
|
||||
List<ResponseMessage> responseMessageList = new ArrayList<>();
|
||||
responseMessageList.add(new ResponseMessageBuilder().code(200).message("响应成功").build());
|
||||
responseMessageList.add(new ResponseMessageBuilder().code(500).message("服务器内部错误").build());
|
||||
return responseMessageList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package cn.datax.service.data.masterdata.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(ignoreUnknownFields = false, prefix = "swagger")
|
||||
public class SwaggerProperties {
|
||||
|
||||
private Boolean enable;
|
||||
private String title;
|
||||
private String description;
|
||||
private String version;
|
||||
private String termsOfServiceUrl;
|
||||
private String basePackage;
|
||||
private Contact contact;
|
||||
|
||||
public Boolean getEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public void setEnable(Boolean enable) {
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getTermsOfServiceUrl() {
|
||||
return termsOfServiceUrl;
|
||||
}
|
||||
|
||||
public void setTermsOfServiceUrl(String termsOfServiceUrl) {
|
||||
this.termsOfServiceUrl = termsOfServiceUrl;
|
||||
}
|
||||
|
||||
public String getBasePackage() {
|
||||
return basePackage;
|
||||
}
|
||||
|
||||
public void setBasePackage(String basePackage) {
|
||||
this.basePackage = basePackage;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public void setContact(Contact contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public static class Contact {
|
||||
private String name;
|
||||
private String url;
|
||||
private String email;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.masterdata.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity(debug = false)
|
||||
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.csrf().disable().authorizeRequests().anyRequest().permitAll().and().logout().permitAll();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.masterdata.controller;
|
||||
|
||||
import cn.datax.common.base.BaseController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/inner")
|
||||
public class InnerController extends BaseController {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package cn.datax.service.data.masterdata.controller;
|
||||
|
||||
import cn.datax.common.core.JsonPage;
|
||||
import cn.datax.common.core.R;
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelColumnDto;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
|
||||
import cn.datax.service.data.masterdata.api.vo.ModelColumnVo;
|
||||
import cn.datax.service.data.masterdata.api.query.ModelColumnQuery;
|
||||
import cn.datax.service.data.masterdata.mapstruct.ModelColumnMapstruct;
|
||||
import cn.datax.service.data.masterdata.service.ModelColumnService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import cn.datax.common.base.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Api(tags = {"主数据模型列信息表"})
|
||||
@RestController
|
||||
@RequestMapping("/columns")
|
||||
public class ModelColumnController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ModelColumnService modelColumnService;
|
||||
|
||||
@Autowired
|
||||
private ModelColumnMapstruct modelColumnMapstruct;
|
||||
|
||||
/**
|
||||
* 通过ID查询信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public R getModelColumnById(@PathVariable String id) {
|
||||
ModelColumnEntity modelColumnEntity = modelColumnService.getModelColumnById(id);
|
||||
return R.ok().setData(modelColumnMapstruct.toVO(modelColumnEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询信息
|
||||
*
|
||||
* @param modelColumnQuery
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询", notes = "")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelColumnQuery", value = "查询实体modelColumnQuery", required = true, dataTypeClass = ModelColumnQuery.class)
|
||||
})
|
||||
@GetMapping("/page")
|
||||
public R getModelColumnPage(ModelColumnQuery modelColumnQuery) {
|
||||
QueryWrapper<ModelColumnEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(StrUtil.isNotBlank(modelColumnQuery.getModelId()), "model_id", modelColumnQuery.getModelId());
|
||||
queryWrapper.like(StrUtil.isNotBlank(modelColumnQuery.getColumnName()), "column_name", modelColumnQuery.getColumnName());
|
||||
IPage<ModelColumnEntity> page = modelColumnService.page(new Page<>(modelColumnQuery.getPageNum(), modelColumnQuery.getPageSize()), queryWrapper);
|
||||
List<ModelColumnVo> collect = page.getRecords().stream().map(modelColumnMapstruct::toVO).collect(Collectors.toList());
|
||||
JsonPage<ModelColumnVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
|
||||
return R.ok().setData(jsonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param modelColumn
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加信息", notes = "根据modelColumn对象添加信息")
|
||||
@ApiImplicitParam(name = "modelColumn", value = "详细实体modelColumn", required = true, dataType = "ModelColumnDto")
|
||||
@PostMapping()
|
||||
public R saveModelColumn(@RequestBody @Validated({ValidationGroups.Insert.class}) ModelColumnDto modelColumn) {
|
||||
ModelColumnEntity modelColumnEntity = modelColumnService.saveModelColumn(modelColumn);
|
||||
return R.ok().setData(modelColumnMapstruct.toVO(modelColumnEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param modelColumn
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改信息", notes = "根据url的id来指定修改对象,并根据传过来的信息来修改详细信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "modelColumn", value = "详细实体modelColumn", required = true, dataType = "ModelColumnDto")
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public R updateModelColumn(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ModelColumnDto modelColumn) {
|
||||
ModelColumnEntity modelColumnEntity = modelColumnService.updateModelColumn(modelColumn);
|
||||
return R.ok().setData(modelColumnMapstruct.toVO(modelColumnEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@DeleteMapping("/{id}")
|
||||
public R deleteModelColumnById(@PathVariable String id) {
|
||||
modelColumnService.deleteModelColumnById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除角色", notes = "根据url的ids来批量删除对象")
|
||||
@ApiImplicitParam(name = "ids", value = "ID集合", required = true, dataType = "List", paramType = "path")
|
||||
@DeleteMapping("/batch/{ids}")
|
||||
public R deleteModelColumnBatch(@PathVariable List<String> ids) {
|
||||
modelColumnService.deleteModelColumnBatch(ids);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package cn.datax.service.data.masterdata.controller;
|
||||
|
||||
import cn.datax.common.core.DataConstant;
|
||||
import cn.datax.common.core.JsonPage;
|
||||
import cn.datax.common.core.R;
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelDto;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import cn.datax.service.data.masterdata.api.vo.ModelVo;
|
||||
import cn.datax.service.data.masterdata.api.query.ModelQuery;
|
||||
import cn.datax.service.data.masterdata.mapstruct.ModelMapstruct;
|
||||
import cn.datax.service.data.masterdata.service.ModelService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import cn.datax.common.base.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Api(tags = {"主数据模型表"})
|
||||
@RestController
|
||||
@RequestMapping("/models")
|
||||
public class ModelController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
|
||||
@Autowired
|
||||
private ModelMapstruct modelMapstruct;
|
||||
|
||||
/**
|
||||
* 通过ID查询信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public R getModelById(@PathVariable String id) {
|
||||
ModelEntity modelEntity = modelService.getModelById(id);
|
||||
return R.ok().setData(modelMapstruct.toVO(modelEntity));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取列表", notes = "")
|
||||
@GetMapping("/list")
|
||||
public R getModelList() {
|
||||
QueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status", DataConstant.EnableState.ENABLE.getKey());
|
||||
queryWrapper.eq("flow_status", DataConstant.AuditState.AGREE.getKey());
|
||||
List<ModelEntity> list = modelService.list(queryWrapper);
|
||||
List<ModelVo> collect = list.stream().map(modelMapstruct::toVO).collect(Collectors.toList());
|
||||
return R.ok().setData(collect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询信息
|
||||
*
|
||||
* @param modelQuery
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询", notes = "")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelQuery", value = "查询实体modelQuery", required = true, dataTypeClass = ModelQuery.class)
|
||||
})
|
||||
@GetMapping("/page")
|
||||
public R getModelPage(ModelQuery modelQuery) {
|
||||
QueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(modelQuery.getModelName()), "model_name", modelQuery.getModelName());
|
||||
IPage<ModelEntity> page = modelService.page(new Page<>(modelQuery.getPageNum(), modelQuery.getPageSize()), queryWrapper);
|
||||
List<ModelVo> collect = page.getRecords().stream().map(modelMapstruct::toVO).collect(Collectors.toList());
|
||||
JsonPage<ModelVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
|
||||
return R.ok().setData(jsonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加信息", notes = "根据model对象添加信息")
|
||||
@ApiImplicitParam(name = "model", value = "详细实体model", required = true, dataType = "ModelDto")
|
||||
@PostMapping()
|
||||
public R saveModel(@RequestBody @Validated({ValidationGroups.Insert.class}) ModelDto model) {
|
||||
ModelEntity modelEntity = modelService.saveModel(model);
|
||||
return R.ok().setData(modelMapstruct.toVO(modelEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改信息", notes = "根据url的id来指定修改对象,并根据传过来的信息来修改详细信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "model", value = "详细实体model", required = true, dataType = "ModelDto")
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public R updateModel(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ModelDto model) {
|
||||
ModelEntity modelEntity = modelService.updateModel(model);
|
||||
return R.ok().setData(modelMapstruct.toVO(modelEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@DeleteMapping("/{id}")
|
||||
public R deleteModelById(@PathVariable String id) {
|
||||
modelService.deleteModelById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除", notes = "根据url的ids来批量删除对象")
|
||||
@ApiImplicitParam(name = "ids", value = "ID集合", required = true, dataType = "List", paramType = "path")
|
||||
@DeleteMapping("/batch/{ids}")
|
||||
public R deleteModelBatch(@PathVariable List<String> ids) {
|
||||
modelService.deleteModelBatch(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作流提交
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/submit/{id}")
|
||||
public R submitModelById(@PathVariable String id) {
|
||||
modelService.submitModelById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/table/create/{id}")
|
||||
public R createTable(@PathVariable String id) {
|
||||
modelService.createTable(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("/table/drop/{id}")
|
||||
public R dropTable(@PathVariable String id) {
|
||||
modelService.dropTable(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/table/param/{id}")
|
||||
public R getTableParamById(@PathVariable String id) {
|
||||
Map<String, Object> map = modelService.getTableParamById(id);
|
||||
return R.ok().setData(map);
|
||||
}
|
||||
|
||||
@GetMapping("/form/param/{id}")
|
||||
public R getFormParamById(@PathVariable String id) {
|
||||
Map<String, Object> map = modelService.getFormParamById(id);
|
||||
return R.ok().setData(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.datax.service.data.masterdata.controller;
|
||||
|
||||
import cn.datax.common.base.BaseController;
|
||||
import cn.datax.common.core.JsonPage;
|
||||
import cn.datax.common.core.R;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
|
||||
import cn.datax.service.data.masterdata.api.query.ModelDataQuery;
|
||||
import cn.datax.service.data.masterdata.service.ModelDataService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/datas")
|
||||
public class ModelDataController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ModelDataService modelDataService;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public R getModelDataById(@PathVariable String id, ModelDataEntity modelDataEntity) {
|
||||
Map<String, Object> data = modelDataService.getModelDataById(modelDataEntity);
|
||||
return R.ok().setData(data);
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public R getPageModelDatas(@RequestBody ModelDataQuery modelDataQuery) {
|
||||
IPage<Map<String, Object>> page = modelDataService.getPageModelDatas(modelDataQuery);
|
||||
JsonPage<Map<String, Object>> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), page.getRecords());
|
||||
return R.ok().setData(jsonPage);
|
||||
}
|
||||
|
||||
@PostMapping("/addData")
|
||||
public R addModelData(@RequestBody ModelDataEntity modelDataEntity) {
|
||||
modelDataService.addModelData(modelDataEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PutMapping("/updateData/{id}")
|
||||
public R updateModelData(@PathVariable String id, @RequestBody ModelDataEntity modelDataEntity) {
|
||||
modelDataService.updateModelData(modelDataEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/delData/{id}")
|
||||
public R deleteModelData(@PathVariable String id, @RequestBody ModelDataEntity modelDataEntity) {
|
||||
modelDataService.delModelData(modelDataEntity);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.datax.service.data.masterdata.dao;
|
||||
|
||||
import cn.datax.common.base.BaseDao;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Mapper
|
||||
public interface ModelColumnDao extends BaseDao<ModelColumnEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.masterdata.dao;
|
||||
|
||||
import cn.datax.common.base.BaseDao;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Mapper
|
||||
public interface ModelDao extends BaseDao<ModelEntity> {
|
||||
|
||||
@Override
|
||||
ModelEntity selectById(Serializable id);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.datax.service.data.masterdata.dao;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface MysqlDynamicDao {
|
||||
|
||||
void createTable(ModelEntity modelEntity);
|
||||
|
||||
void dropTable(@Param("tableName") String tableName);
|
||||
|
||||
void insertData(ModelDataEntity modelDataEntity);
|
||||
|
||||
void updateData(ModelDataEntity modelDataEntity);
|
||||
|
||||
void deleteData(ModelDataEntity modelDataEntity);
|
||||
|
||||
IPage<Map<String, Object>> getPageModelDatas(Page<Object> page, @Param(Constants.WRAPPER) Wrapper wrapper, @Param("tableName") String tableName);
|
||||
|
||||
Map<String, Object> getData(ModelDataEntity modelDataEntity);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.datax.service.data.masterdata.dao;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelCommentEntity;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface OracleDynamicDao {
|
||||
|
||||
void createTable(ModelEntity modelEntity);
|
||||
|
||||
void commentTable(ModelCommentEntity modelCommentEntity);
|
||||
|
||||
void commentColumn(ModelCommentEntity modelCommentEntity);
|
||||
|
||||
void dropTable(@Param("tableName") String tableName);
|
||||
|
||||
void insertData(ModelDataEntity modelDataEntity);
|
||||
|
||||
void updateData(ModelDataEntity modelDataEntity);
|
||||
|
||||
void deleteData(ModelDataEntity modelDataEntity);
|
||||
|
||||
IPage<Map<String, Object>> getPageModelDatas(Page<Object> page, @Param(Constants.WRAPPER) Wrapper wrapper, @Param("tableName") String tableName);
|
||||
|
||||
Map<String, Object> getData(ModelDataEntity modelDataEntity);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.datax.service.data.masterdata.mapstruct;
|
||||
|
||||
import cn.datax.common.mapstruct.EntityMapper;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelColumnDto;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
|
||||
import cn.datax.service.data.masterdata.api.vo.ModelColumnVo;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 Mapper 实体映射
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ModelColumnMapstruct extends EntityMapper<ModelColumnDto, ModelColumnEntity, ModelColumnVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.datax.service.data.masterdata.mapstruct;
|
||||
|
||||
import cn.datax.common.mapstruct.EntityMapper;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelDto;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import cn.datax.service.data.masterdata.api.vo.ModelVo;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 Mapper 实体映射
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ModelMapstruct extends EntityMapper<ModelDto, ModelEntity, ModelVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.datax.service.data.masterdata.service;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelColumnDto;
|
||||
import cn.datax.common.base.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
public interface ModelColumnService extends BaseService<ModelColumnEntity> {
|
||||
|
||||
ModelColumnEntity saveModelColumn(ModelColumnDto modelColumn);
|
||||
|
||||
ModelColumnEntity updateModelColumn(ModelColumnDto modelColumn);
|
||||
|
||||
ModelColumnEntity getModelColumnById(String id);
|
||||
|
||||
void deleteModelColumnById(String id);
|
||||
|
||||
void deleteModelColumnBatch(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.datax.service.data.masterdata.service;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
|
||||
import cn.datax.service.data.masterdata.api.query.ModelDataQuery;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ModelDataService {
|
||||
|
||||
IPage<Map<String, Object>> getPageModelDatas(ModelDataQuery modelDataQuery);
|
||||
|
||||
void addModelData(ModelDataEntity modelDataEntity);
|
||||
|
||||
void updateModelData(ModelDataEntity modelDataEntity);
|
||||
|
||||
void delModelData(ModelDataEntity modelDataEntity);
|
||||
|
||||
Map<String, Object> getModelDataById(ModelDataEntity modelDataEntity);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.datax.service.data.masterdata.service;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelDto;
|
||||
import cn.datax.common.base.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
public interface ModelService extends BaseService<ModelEntity> {
|
||||
|
||||
ModelEntity saveModel(ModelDto model);
|
||||
|
||||
ModelEntity updateModel(ModelDto model);
|
||||
|
||||
ModelEntity getModelById(String id);
|
||||
|
||||
void deleteModelById(String id);
|
||||
|
||||
void deleteModelBatch(List<String> ids);
|
||||
|
||||
void createTable(String id);
|
||||
|
||||
void dropTable(String id);
|
||||
|
||||
Map<String, Object> getTableParamById(String id);
|
||||
|
||||
Map<String, Object> getFormParamById(String id);
|
||||
|
||||
void submitModelById(String id);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.datax.service.data.masterdata.service.impl;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelColumnDto;
|
||||
import cn.datax.service.data.masterdata.service.ModelColumnService;
|
||||
import cn.datax.service.data.masterdata.mapstruct.ModelColumnMapstruct;
|
||||
import cn.datax.service.data.masterdata.dao.ModelColumnDao;
|
||||
import cn.datax.common.base.BaseServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型列信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class ModelColumnServiceImpl extends BaseServiceImpl<ModelColumnDao, ModelColumnEntity> implements ModelColumnService {
|
||||
|
||||
@Autowired
|
||||
private ModelColumnDao modelColumnDao;
|
||||
|
||||
@Autowired
|
||||
private ModelColumnMapstruct modelColumnMapstruct;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ModelColumnEntity saveModelColumn(ModelColumnDto modelColumnDto) {
|
||||
ModelColumnEntity modelColumn = modelColumnMapstruct.toEntity(modelColumnDto);
|
||||
modelColumnDao.insert(modelColumn);
|
||||
return modelColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ModelColumnEntity updateModelColumn(ModelColumnDto modelColumnDto) {
|
||||
ModelColumnEntity modelColumn = modelColumnMapstruct.toEntity(modelColumnDto);
|
||||
modelColumnDao.updateById(modelColumn);
|
||||
return modelColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelColumnEntity getModelColumnById(String id) {
|
||||
ModelColumnEntity modelColumnEntity = super.getById(id);
|
||||
return modelColumnEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteModelColumnById(String id) {
|
||||
modelColumnDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteModelColumnBatch(List<String> ids) {
|
||||
modelColumnDao.deleteBatchIds(ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package cn.datax.service.data.masterdata.service.impl;
|
||||
|
||||
import cn.datax.common.exception.DataException;
|
||||
import cn.datax.common.utils.SecurityUtil;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
|
||||
import cn.datax.service.data.masterdata.api.query.ModelDataQuery;
|
||||
import cn.datax.service.data.masterdata.dao.MysqlDynamicDao;
|
||||
import cn.datax.service.data.masterdata.service.ModelDataService;
|
||||
import cn.datax.service.data.masterdata.utils.SearchUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ModelDataServiceImpl implements ModelDataService {
|
||||
|
||||
@Autowired
|
||||
private MysqlDynamicDao dynamicDao;
|
||||
|
||||
private static String DEFAULT_PRIMARY_KEY = "id";
|
||||
private static String DEFAULT_CREATE_BY = "create_by";
|
||||
private static String DEFAULT_CREATE_TIME = "create_time";
|
||||
private static String DEFAULT_CREATE_DEPT = "create_dept";
|
||||
private static String DEFAULT_UPDATE_BY = "update_by";
|
||||
private static String DEFAULT_UPDATE_TIME = "update_time";
|
||||
|
||||
private static List<String> SUPER_COLUMNS = Arrays.asList("id", "create_time");
|
||||
|
||||
@Override
|
||||
public IPage<Map<String, Object>> getPageModelDatas(ModelDataQuery modelDataQuery) {
|
||||
String tableName = modelDataQuery.getTableName();
|
||||
if (StrUtil.isBlank(tableName)) {
|
||||
throw new DataException("数据库表为空");
|
||||
}
|
||||
QueryWrapper queryWrapper = SearchUtil.parseWhereSql(modelDataQuery);
|
||||
List<String> columns = modelDataQuery.getColumns();
|
||||
columns.addAll(SUPER_COLUMNS);
|
||||
String[] array = columns.toArray(new String[columns.size()]);
|
||||
queryWrapper.select(array);
|
||||
IPage<Map<String, Object>> page = dynamicDao.getPageModelDatas(new Page<>(modelDataQuery.getPageNum(), modelDataQuery.getPageSize()), queryWrapper, tableName);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModelData(ModelDataEntity modelDataEntity) {
|
||||
String tableName = modelDataEntity.getTableName();
|
||||
if (StrUtil.isBlank(tableName)) {
|
||||
throw new DataException("数据库表为空");
|
||||
}
|
||||
Map<String, Object> datas = modelDataEntity.getDatas();
|
||||
datas.put(DEFAULT_PRIMARY_KEY, new DefaultIdentifierGenerator().nextId(null));
|
||||
datas.put(DEFAULT_CREATE_BY, SecurityUtil.getUserId());
|
||||
datas.put(DEFAULT_CREATE_TIME, LocalDateTime.now());
|
||||
datas.put(DEFAULT_CREATE_DEPT, SecurityUtil.getUserDeptId());
|
||||
datas.put(DEFAULT_UPDATE_BY, SecurityUtil.getUserId());
|
||||
datas.put(DEFAULT_UPDATE_TIME, LocalDateTime.now());
|
||||
dynamicDao.insertData(modelDataEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateModelData(ModelDataEntity modelDataEntity) {
|
||||
String tableName = modelDataEntity.getTableName();
|
||||
if (StrUtil.isBlank(tableName)) {
|
||||
throw new DataException("数据库表为空");
|
||||
}
|
||||
String id = modelDataEntity.getId();
|
||||
if (StrUtil.isBlank(id)) {
|
||||
throw new DataException("数据库主键为空");
|
||||
}
|
||||
Map<String, Object> datas = modelDataEntity.getDatas();
|
||||
datas.put(DEFAULT_UPDATE_BY, SecurityUtil.getUserId());
|
||||
datas.put(DEFAULT_UPDATE_TIME, LocalDateTime.now());
|
||||
dynamicDao.updateData(modelDataEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delModelData(ModelDataEntity modelDataEntity) {
|
||||
String tableName = modelDataEntity.getTableName();
|
||||
if (StrUtil.isBlank(tableName)) {
|
||||
throw new DataException("数据库表为空");
|
||||
}
|
||||
String id = modelDataEntity.getId();
|
||||
if (StrUtil.isBlank(id)) {
|
||||
throw new DataException("数据库主键为空");
|
||||
}
|
||||
dynamicDao.deleteData(modelDataEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getModelDataById(ModelDataEntity modelDataEntity) {
|
||||
String tableName = modelDataEntity.getTableName();
|
||||
if (StrUtil.isBlank(tableName)) {
|
||||
throw new DataException("数据库表为空");
|
||||
}
|
||||
String id = modelDataEntity.getId();
|
||||
if (StrUtil.isBlank(id)) {
|
||||
throw new DataException("数据库主键为空");
|
||||
}
|
||||
Map<String, Object> data = dynamicDao.getData(modelDataEntity);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package cn.datax.service.data.masterdata.service.impl;
|
||||
|
||||
import cn.datax.common.core.DataConstant;
|
||||
import cn.datax.common.core.RedisConstant;
|
||||
import cn.datax.common.exception.DataException;
|
||||
import cn.datax.common.redis.service.RedisService;
|
||||
import cn.datax.common.utils.MsgFormatUtil;
|
||||
import cn.datax.common.utils.SecurityUtil;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
|
||||
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
|
||||
import cn.datax.service.data.masterdata.api.dto.ModelDto;
|
||||
import cn.datax.service.data.masterdata.dao.ModelColumnDao;
|
||||
import cn.datax.service.data.masterdata.dao.MysqlDynamicDao;
|
||||
import cn.datax.service.data.masterdata.mapstruct.ModelMapstruct;
|
||||
import cn.datax.service.data.masterdata.service.ModelService;
|
||||
import cn.datax.service.data.masterdata.dao.ModelDao;
|
||||
import cn.datax.common.base.BaseServiceImpl;
|
||||
import cn.datax.service.data.standard.api.entity.DictEntity;
|
||||
import cn.datax.service.workflow.api.dto.ProcessInstanceCreateRequest;
|
||||
import cn.datax.service.workflow.api.entity.BusinessEntity;
|
||||
import cn.datax.service.workflow.api.feign.FlowInstanceServiceFeign;
|
||||
import cn.datax.service.workflow.api.vo.FlowInstanceVo;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主数据模型表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-26
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> implements ModelService {
|
||||
|
||||
@Autowired
|
||||
private ModelDao modelDao;
|
||||
|
||||
@Autowired
|
||||
private ModelMapstruct modelMapstruct;
|
||||
|
||||
@Autowired
|
||||
private ModelColumnDao modelColumnDao;
|
||||
|
||||
@Autowired
|
||||
private MysqlDynamicDao dynamicDao;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private FlowInstanceServiceFeign flowInstanceServiceFeign;
|
||||
|
||||
private static String BIND_GB_CODE = "gb_code";
|
||||
private static String BIND_GB_NAME = "gb_name";
|
||||
|
||||
private static String DEFAULT_BUSINESS_CODE = "5011";
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ModelEntity saveModel(ModelDto modelDto) {
|
||||
ModelEntity model = modelMapstruct.toEntity(modelDto);
|
||||
model.setIsSync(DataConstant.TrueOrFalse.FALSE.getKey());
|
||||
model.setModelPhysicalTable("dynamic_" + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN));
|
||||
modelDao.insert(model);
|
||||
String modelId = model.getId();
|
||||
List<ModelColumnEntity> modelColumns = model.getModelColumns();
|
||||
if(CollUtil.isNotEmpty(modelColumns)){
|
||||
modelColumns.forEach(c -> {
|
||||
c.setModelId(modelId);
|
||||
modelColumnDao.insert(c);
|
||||
});
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ModelEntity updateModel(ModelDto modelDto) {
|
||||
ModelEntity model = modelMapstruct.toEntity(modelDto);
|
||||
modelDao.updateById(model);
|
||||
String modelId = model.getId();
|
||||
modelColumnDao.delete(Wrappers.<ModelColumnEntity>lambdaQuery()
|
||||
.eq(ModelColumnEntity::getModelId, modelId));
|
||||
List<ModelColumnEntity> modelColumns = model.getModelColumns();
|
||||
if(CollUtil.isNotEmpty(modelColumns)){
|
||||
modelColumns.forEach(c -> {
|
||||
c.setModelId(modelId);
|
||||
modelColumnDao.insert(c);
|
||||
});
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelEntity getModelById(String id) {
|
||||
ModelEntity modelEntity = super.getById(id);
|
||||
return modelEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteModelById(String id) {
|
||||
modelColumnDao.delete(Wrappers.<ModelColumnEntity>lambdaQuery()
|
||||
.eq(ModelColumnEntity::getModelId, id));
|
||||
modelDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteModelBatch(List<String> ids) {
|
||||
modelColumnDao.delete(Wrappers.<ModelColumnEntity>lambdaQuery()
|
||||
.in(ModelColumnEntity::getModelId, ids));
|
||||
modelDao.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable(String id) {
|
||||
ModelEntity modelEntity = super.getById(id);
|
||||
if (DataConstant.TrueOrFalse.TRUE.getKey().equals(modelEntity.getIsSync())) {
|
||||
throw new DataException("重复建模");
|
||||
}
|
||||
dynamicDao.createTable(modelEntity);
|
||||
modelEntity.setIsSync(DataConstant.TrueOrFalse.TRUE.getKey());
|
||||
modelDao.updateById(modelEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropTable(String id) {
|
||||
ModelEntity modelEntity = super.getById(id);
|
||||
String tableName = modelEntity.getModelPhysicalTable();
|
||||
dynamicDao.dropTable(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTableParamById(String id) {
|
||||
ModelEntity modelEntity = super.getById(id);
|
||||
String tableName = modelEntity.getModelPhysicalTable();
|
||||
List<ModelColumnEntity> modelColumns = modelEntity.getModelColumns();
|
||||
// 列表展示字段
|
||||
List<Map<String, Object>> columnList = modelColumns.stream().filter(s -> DataConstant.TrueOrFalse.TRUE.getKey().equals(s.getIsList())).map(s -> {
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("prop", s.getColumnName());
|
||||
map.put("label", s.getColumnComment());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
// 查询参数字段
|
||||
List<Map<String, Object>> queryList = modelColumns.stream().filter(s -> DataConstant.TrueOrFalse.TRUE.getKey().equals(s.getIsQuery())).map(s -> {
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("column", s.getColumnName());
|
||||
map.put("columnName", s.getColumnComment());
|
||||
map.put("columnType", s.getColumnType());
|
||||
map.put("columnScale", s.getColumnScale());
|
||||
map.put("queryType", s.getQueryType());
|
||||
map.put("htmlType", s.getHtmlType());
|
||||
if (DataConstant.TrueOrFalse.TRUE.getKey().equals(s.getIsBindDict()) && StrUtil.isNotBlank(s.getBindDictTypeId())) {
|
||||
String bindDictColumn = s.getBindDictColumn();
|
||||
List<DictEntity> dictList = (List<DictEntity>) redisService.hget(RedisConstant.STANDARD_DICT_KEY, s.getBindDictTypeId());
|
||||
List<Map<String, Object>> mapList = dictList.stream().map(d -> {
|
||||
Map<String, Object> dictMap = new HashMap<>(4);
|
||||
dictMap.put("id", d.getId());
|
||||
dictMap.put("value", BIND_GB_CODE.equals(bindDictColumn) ? d.getGbCode() : d.getGbName());
|
||||
dictMap.put("label", d.getGbName());
|
||||
return dictMap;
|
||||
}).collect(Collectors.toList());
|
||||
map.put("dictList", mapList);
|
||||
}
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("modelId", id);
|
||||
map.put("tableName", tableName);
|
||||
map.put("columnList", columnList);
|
||||
map.put("queryList", queryList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFormParamById(String id) {
|
||||
ModelEntity modelEntity = super.getById(id);
|
||||
String tableName = modelEntity.getModelPhysicalTable();
|
||||
List<ModelColumnEntity> modelColumns = modelEntity.getModelColumns();
|
||||
List<Map<String, Object>> columnList = modelColumns.stream().filter(s -> DataConstant.TrueOrFalse.FALSE.getKey().equals(s.getIsSystem())).map(s -> {
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
map.put("id", s.getId());
|
||||
map.put("columnName", s.getColumnName());
|
||||
map.put("columnComment", s.getColumnComment());
|
||||
map.put("columnType", s.getColumnType());
|
||||
map.put("columnLength", s.getColumnLength());
|
||||
map.put("columnScale", s.getColumnScale());
|
||||
map.put("defaultValue", s.getDefaultValue());
|
||||
map.put("isRequired", s.getIsRequired());
|
||||
map.put("isInsert", s.getIsInsert());
|
||||
map.put("isEdit", s.getIsEdit());
|
||||
map.put("isDetail", s.getIsEdit());
|
||||
map.put("isList", s.getIsList());
|
||||
map.put("isQuery", s.getIsQuery());
|
||||
map.put("queryType", s.getQueryType());
|
||||
map.put("isBindDict", s.getIsBindDict());
|
||||
if (DataConstant.TrueOrFalse.TRUE.getKey().equals(s.getIsBindDict()) && StrUtil.isNotBlank(s.getBindDictTypeId())) {
|
||||
String bindDictColumn = s.getBindDictColumn();
|
||||
List<DictEntity> dictList = (List<DictEntity>) redisService.hget(RedisConstant.STANDARD_DICT_KEY, s.getBindDictTypeId());
|
||||
List<Map<String, Object>> mapList = dictList.stream().map(d -> {
|
||||
Map<String, Object> dictMap = new HashMap<>(4);
|
||||
dictMap.put("id", d.getId());
|
||||
dictMap.put("value", BIND_GB_CODE.equals(bindDictColumn) ? d.getGbCode() : d.getGbName());
|
||||
dictMap.put("label", d.getGbName());
|
||||
return dictMap;
|
||||
}).collect(Collectors.toList());
|
||||
map.put("dictList", mapList);
|
||||
}
|
||||
map.put("htmlType", s.getHtmlType());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("modelId", id);
|
||||
map.put("tableName", tableName);
|
||||
map.put("columnList", columnList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitModelById(String id) {
|
||||
BusinessEntity businessEntity = (BusinessEntity) redisService.hget(RedisConstant.WORKFLOW_BUSINESS_KEY, DEFAULT_BUSINESS_CODE);
|
||||
if (businessEntity != null) {
|
||||
ProcessInstanceCreateRequest request = new ProcessInstanceCreateRequest();
|
||||
request.setSubmitter(SecurityUtil.getUserId());
|
||||
request.setBusinessKey(id);
|
||||
request.setBusinessCode(DEFAULT_BUSINESS_CODE);
|
||||
request.setBusinessAuditGroup(businessEntity.getBusinessAuditGroup());
|
||||
String processDefinitionId = businessEntity.getProcessDefinitionId();
|
||||
request.setProcessDefinitionId(processDefinitionId);
|
||||
// 流程实例标题(动态拼接)
|
||||
String tempalte = businessEntity.getBusinessTempalte();
|
||||
String businessName = businessEntity.getBusinessName();
|
||||
Map<String, String> parameters = new HashMap<>(4);
|
||||
parameters.put(MsgFormatUtil.TEMPALTE_NICKNAME, SecurityUtil.getNickname());
|
||||
parameters.put(MsgFormatUtil.TEMPALTE_DATETIME, DateUtil.formatLocalDateTime(LocalDateTime.now()));
|
||||
parameters.put(MsgFormatUtil.TEMPALTE_BUSINESS_NAME, businessName);
|
||||
parameters.put(MsgFormatUtil.TEMPALTE_BUSINESS_KEY, id);
|
||||
String content = MsgFormatUtil.getContent(tempalte, parameters);
|
||||
request.setBusinessName(content);
|
||||
FlowInstanceVo flowInstanceVo = flowInstanceServiceFeign.startById(request);
|
||||
if (flowInstanceVo != null) {
|
||||
ModelEntity modelEntity = new ModelEntity();
|
||||
modelEntity.setId(id);
|
||||
modelEntity.setProcessInstanceId(flowInstanceVo.getProcessInstanceId());
|
||||
modelDao.updateById(modelEntity);
|
||||
}
|
||||
} else {
|
||||
throw new DataException("业务流程未配置");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.datax.service.data.masterdata.utils;
|
||||
|
||||
import cn.datax.service.data.masterdata.api.query.Condition;
|
||||
import cn.datax.service.data.masterdata.api.query.ModelDataQuery;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SearchUtil {
|
||||
|
||||
public static QueryWrapper parseWhereSql(ModelDataQuery modelDataQuery) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
List<Condition> conditionList = modelDataQuery.getConditions();
|
||||
if(CollUtil.isNotEmpty(conditionList)){
|
||||
for(Condition condition : conditionList){
|
||||
switch (condition.getQueryType()) {
|
||||
case "eq":
|
||||
queryWrapper.eq(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "ne":
|
||||
queryWrapper.ne(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "like":
|
||||
queryWrapper.like(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "gt":
|
||||
queryWrapper.gt(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "ge":
|
||||
queryWrapper.ge(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "lt":
|
||||
queryWrapper.lt(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "le":
|
||||
queryWrapper.le(StrUtil.isNotBlank(condition.getValue()), condition.getColumn(), condition.getValue());
|
||||
break;
|
||||
case "between":
|
||||
queryWrapper.between(StrUtil.isNotBlank(condition.getLeftValue()) && StrUtil.isNotBlank(condition.getRightValue()), condition.getColumn(), condition.getLeftValue(), condition.getRightValue());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
server:
|
||||
port: 8828
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: service-data-masterdata
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
config:
|
||||
label: master
|
||||
name: ${spring.application.name}
|
||||
profile: ${spring.profiles.active}
|
||||
discovery:
|
||||
enabled: true
|
||||
service-id: config
|
||||
|
||||
# 注册中心配置
|
||||
eureka:
|
||||
instance:
|
||||
lease-renewal-interval-in-seconds: 20
|
||||
prefer-ip-address: true
|
||||
ip-address: 192.168.1.169
|
||||
client:
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
instance-info-replication-interval-seconds: 30
|
||||
registry-fetch-interval-seconds: 3
|
||||
service-url:
|
||||
defaultZone: http://192.168.1.169:8610/eureka
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<springProperty scope="context" name="springAppName" source="spring.application.name"/>
|
||||
<property name="log.path" value="logs/service-data-masterdata"/>
|
||||
<property name="log.maxHistory" value="15"/>
|
||||
<property name="log.totalSizeCap" value="500MB"/>
|
||||
<property name="log.maxFileSize" value="10MB"/>
|
||||
<property name="log.colorPattern"
|
||||
value="%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %boldCyan(${springAppName:-}) %yellow(%thread) %green(%logger) %msg%n"/>
|
||||
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level ${springAppName:-} %thread %logger %msg%n"/>
|
||||
|
||||
<!--输出到控制台-->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.colorPattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--输出到文件-->
|
||||
<!-- RollingFileAppender:滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 -->
|
||||
<!-- 以下的大概意思是:1.先按日期存日志,日期变了,将前一天的日志文件名重命名为XXX%日期%索引,新的日志仍然是project_info.log -->
|
||||
<!-- 2.如果日期没有发生变化,但是当前日志的文件大小超过10MB时,对当前日志进行分割 重命名-->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!--日志文件路径和名称-->
|
||||
<File>${log.path}/info/info.log</File>
|
||||
<!--是否追加到文件末尾,默认为true-->
|
||||
<append>true</append>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 日志文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 -->
|
||||
<!-- 文件名:logs/project_info.2017-12-05.0.log -->
|
||||
<!-- 注意:SizeAndTimeBasedRollingPolicy中 %i和%d令牌都是强制性的,必须存在,要不会报错 -->
|
||||
<fileNamePattern>${log.path}/info/info.%d.%i.log</fileNamePattern>
|
||||
<!-- 每产生一个日志文件,该日志文件的保存期限为30天, ps:maxHistory的单位是根据fileNamePattern中的翻转策略自动推算出来的,例如上面选用了yyyy-MM-dd,则单位为天
|
||||
如果上面选用了yyyy-MM,则单位为月,另外上面的单位默认为yyyy-MM-dd-->
|
||||
<MaxHistory>${log.maxHistory}</MaxHistory>
|
||||
<!-- 每个日志文件到2mb的时候开始切分,最多保留30天,但最大到500MB,哪怕没到30天也要删除多余的日志 -->
|
||||
<totalSizeCap>${log.totalSizeCap}</totalSizeCap>
|
||||
<!-- maxFileSize:这是活动文件的大小,默认值是10MB,测试时可改成5KB看效果 -->
|
||||
<maxFileSize>${log.maxFileSize}</maxFileSize>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.path}/error/error.log</File>
|
||||
<append>true</append>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/error/error.%d.%i.log</fileNamePattern>
|
||||
<MaxHistory>${log.maxHistory}</MaxHistory>
|
||||
<totalSizeCap>${log.totalSizeCap}</totalSizeCap>
|
||||
<maxFileSize>${log.maxFileSize}</maxFileSize>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<root level="debug">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.datax.service.data.masterdata.dao.ModelColumnDao">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.datax.service.data.masterdata.api.entity.ModelColumnEntity">
|
||||
<result column="id" property="id" />
|
||||
<result column="status" property="status" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="remark" property="remark" />
|
||||
<result column="model_id" property="modelId" />
|
||||
<result column="column_name" property="columnName" />
|
||||
<result column="column_comment" property="columnComment" />
|
||||
<result column="column_type" property="columnType" />
|
||||
<result column="column_length" property="columnLength" />
|
||||
<result column="column_scale" property="columnScale" />
|
||||
<result column="default_value" property="defaultValue" />
|
||||
<result column="is_system" property="isSystem" />
|
||||
<result column="is_pk" property="isPk" />
|
||||
<result column="is_required" property="isRequired" />
|
||||
<result column="is_insert" property="isInsert" />
|
||||
<result column="is_edit" property="isEdit" />
|
||||
<result column="is_detail" property="isDetail" />
|
||||
<result column="is_list" property="isList" />
|
||||
<result column="is_query" property="isQuery" />
|
||||
<result column="query_type" property="queryType" />
|
||||
<result column="is_bind_dict" property="isBindDict" />
|
||||
<result column="bind_dict_type_id" property="bindDictTypeId" />
|
||||
<result column="bind_dict_column" property="bindDictColumn" />
|
||||
<result column="html_type" property="htmlType" />
|
||||
<result column="sort" property="sort" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
status,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
model_id, column_name, column_comment, column_type, column_length, column_scale, default_value, is_system, is_pk, is_required, is_insert, is_edit, is_detail, is_list, is_query, query_type, is_bind_dict, bind_dict_type_id, bind_dict_column, html_type, sort
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.datax.service.data.masterdata.dao.ModelDao">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.datax.service.data.masterdata.api.entity.ModelEntity">
|
||||
<result column="id" property="id" />
|
||||
<result column="status" property="status" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_dept" property="createDept" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="remark" property="remark" />
|
||||
<result column="model_name" property="modelName" />
|
||||
<result column="model_logic_table" property="modelLogicTable" />
|
||||
<result column="model_physical_table" property="modelPhysicalTable" />
|
||||
<result column="is_sync" property="isSync" />
|
||||
<result column="flow_status" property="flowStatus" />
|
||||
<result column="process_instance_id" property="processInstanceId" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="ExtendResultMap" type="cn.datax.service.data.masterdata.api.entity.ModelEntity" extends="BaseResultMap">
|
||||
<collection property="modelColumns" column="{modelId=id}" select="getModelColumnList"></collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
status,
|
||||
create_by,
|
||||
create_time,
|
||||
create_dept,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
model_name, model_logic_table, model_physical_table, is_sync, flow_status, process_instance_id
|
||||
</sql>
|
||||
|
||||
<select id="getModelColumnList" resultType="cn.datax.service.data.masterdata.api.entity.ModelColumnEntity">
|
||||
SELECT
|
||||
<include refid="cn.datax.service.data.masterdata.dao.ModelColumnDao.Base_Column_List"></include>
|
||||
FROM masterdata_model_column
|
||||
WHERE 1 = 1
|
||||
<if test="modelId != null and modelId != ''">
|
||||
AND model_id = #{modelId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultMap="ExtendResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"></include>
|
||||
FROM masterdata_model
|
||||
WHERE 1 = 1 AND id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.datax.service.data.masterdata.dao.MysqlDynamicDao">
|
||||
|
||||
<insert id="createTable" parameterType="cn.datax.service.data.masterdata.api.entity.ModelEntity">
|
||||
CREATE TABLE `${modelPhysicalTable}` (
|
||||
<foreach collection="modelColumns" item="column" separator=",">
|
||||
`${column.columnName}` ${column.columnDefinition}
|
||||
<if test="column.defaultValue != null and column.defaultValue != ''">
|
||||
DEFAULT #{column.defaultValue}
|
||||
</if>
|
||||
<if test="column.isRequired != null and column.isRequired == '1'.toString()">
|
||||
NOT NULL
|
||||
</if>
|
||||
<if test="column.columnComment != null and column.columnComment != ''">
|
||||
comment #{column.columnComment}
|
||||
</if>
|
||||
</foreach>
|
||||
, PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC
|
||||
<if test="modelName != null and modelName != ''">
|
||||
comment=#{modelName}
|
||||
</if>
|
||||
</insert>
|
||||
|
||||
<!-- 验证表是否存在 -->
|
||||
<delete id="dropTable" parameterType="java.lang.String">
|
||||
DROP TABLE IF EXISTS ${tableName}
|
||||
</delete>
|
||||
|
||||
<!-- 插入数据 -->
|
||||
<insert id="insertData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
|
||||
INSERT INTO ${tableName}
|
||||
<foreach collection="datas.keys" item="key" open="(" close=")" separator=",">
|
||||
${key}
|
||||
</foreach>
|
||||
VALUES
|
||||
<foreach collection="datas.values" item="value" open="(" close=")" separator=",">
|
||||
#{value}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 更新数据 -->
|
||||
<update id="updateData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
|
||||
UPDATE ${tableName} SET
|
||||
<foreach collection="datas" index="key" item="value" separator=",">
|
||||
${key} = #{value}
|
||||
</foreach>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除数据 -->
|
||||
<delete id="deleteData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
|
||||
DELETE FROM ${tableName} WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getPageModelDatas" resultType="java.util.Map">
|
||||
SELECT ${ew.SqlSelect} FROM ${tableName} ${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="getData" resultType="java.util.Map">
|
||||
SELECT * FROM ${tableName} WHERE id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.datax.service.data.masterdata.dao.OracleDynamicDao">
|
||||
|
||||
<insert id="createTable" parameterType="cn.datax.service.data.masterdata.api.entity.ModelEntity">
|
||||
CREATE TABLE ${modelPhysicalTable} (
|
||||
<foreach collection="modelColumns" item="column" separator=",">
|
||||
${column.columnName} ${column.columnDefinition}
|
||||
<if test="column.defaultValue != null and column.defaultValue != ''">
|
||||
DEFAULT #{column.defaultValue}
|
||||
</if>
|
||||
<if test="column.isRequired != null and column.isRequired == '1'.toString()">
|
||||
NOT NULL
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 表注释 -->
|
||||
<update id="commentTable" parameterType="cn.datax.service.data.masterdata.api.entity.ModelCommentEntity">
|
||||
COMMENT ON TABLE ${tableName} IS #{comment}
|
||||
</update>
|
||||
|
||||
<!-- 字段注释 -->
|
||||
<update id="commentColumn" parameterType="cn.datax.service.data.masterdata.api.entity.ModelCommentEntity">
|
||||
COMMENT ON COLUMN ${tableName}.${columnName} IS #{comment}
|
||||
</update>
|
||||
|
||||
<!-- 验证表是否存在 -->
|
||||
<update id="dropTable" parameterType="java.lang.String">
|
||||
DROP TABLE IF EXISTS ${tableName}
|
||||
</update>
|
||||
|
||||
<!-- 插入数据 -->
|
||||
<insert id="insertData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
|
||||
INSERT INTO ${tableName}
|
||||
<foreach collection="datas.keys" item="key" open="(" close=")" separator=",">
|
||||
${key}
|
||||
</foreach>
|
||||
VALUES
|
||||
<foreach collection="datas.values" item="value" open="(" close=")" separator=",">
|
||||
#{value}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 更新数据 -->
|
||||
<update id="updateData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
|
||||
UPDATE ${tableName} SET
|
||||
<foreach collection="datas" index="key" item="value" separator=",">
|
||||
${key} = #{value}
|
||||
</foreach>
|
||||
WHERE ID = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除数据 -->
|
||||
<delete id="deleteData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
|
||||
DELETE FROM ${tableName} WHERE ID = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getPageModelDatas" resultType="java.util.Map">
|
||||
SELECT ${ew.SqlSelect} FROM ${tableName} ${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="getData" resultType="java.util.Map">
|
||||
SELECT * FROM ${tableName} WHERE id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,25 @@
|
||||
module.log=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
|
||||
# <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>ӡ
|
||||
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||
#<23><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨
|
||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||
# ʹ<><CAB9><EFBFBD><EFBFBD>־ϵͳ<CFB5><CDB3>¼ sql
|
||||
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||
# <20><><EFBFBD><EFBFBD> p6spy driver <20><><EFBFBD><EFBFBD>
|
||||
deregisterdrivers=true
|
||||
# ȡ<><C8A1>JDBC URLǰ
|
||||
useprefix=true
|
||||
# <20><><EFBFBD>ü<EFBFBD>¼ Log <20><><EFBFBD><EFBFBD>,<2C><>ȥ<EFBFBD><C8A5><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||
excludecategories=info,debug,result,batch,resultset
|
||||
# <20><><EFBFBD>ڸ<EFBFBD>ʽ
|
||||
dateformat=yyyy-MM-dd HH:mm:ss
|
||||
# ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>
|
||||
#driverlist=org.h2.Driver
|
||||
# <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51><4C>¼
|
||||
outagedetection=true
|
||||
# <20><>SQL<51><4C>¼<EFBFBD><C2BC> 2 <20><>
|
||||
outagedetectioninterval=2
|
||||
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
filter=true
|
||||
# <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
exclude=select 1
|
||||
20
studio/modules/data-masterdata-service-parent/pom.xml
Normal file
20
studio/modules/data-masterdata-service-parent/pom.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>modules</artifactId>
|
||||
<groupId>com.platform</groupId>
|
||||
<version>0.4.x</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.4.x</version>
|
||||
<description>主数据</description>
|
||||
<artifactId>data-masterdata-service-parent</artifactId>
|
||||
|
||||
<modules>
|
||||
<module>data-masterdata-service-api</module>
|
||||
<module>data-masterdata-service</module>
|
||||
</modules>
|
||||
</project>
|
||||
Reference in New Issue
Block a user