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-market-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-market-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,24 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ApiLogDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String id;
|
||||
private String apiId;
|
||||
private String callerId;
|
||||
private String callerIp;
|
||||
private String callerUrl;
|
||||
private String callerParams;
|
||||
private Integer callerSize;
|
||||
private LocalDateTime callerDate;
|
||||
private Long time;
|
||||
private String msg;
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.datax.service.data.market.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>
|
||||
* 数据API脱敏信息表 实体DTO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-14
|
||||
*/
|
||||
@ApiModel(value = "数据API脱敏信息表Model")
|
||||
@Data
|
||||
public class ApiMaskDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@NotBlank(message = "主键ID不能为空", groups = {ValidationGroups.Update.class})
|
||||
private String id;
|
||||
@ApiModelProperty(value = "数据API")
|
||||
@NotBlank(message = "数据API不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String apiId;
|
||||
@ApiModelProperty(value = "脱敏名称")
|
||||
@NotBlank(message = "脱敏名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String maskName;
|
||||
@ApiModelProperty(value = "脱敏字段规则配置")
|
||||
@Valid
|
||||
@NotEmpty(message = "脱敏字段规则配置不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
@Size(min = 1, message="脱敏字段规则配置长度不能少于{min}位")
|
||||
private List<FieldRule> rules;
|
||||
@ApiModelProperty(value = "状态")
|
||||
@NotNull(message = "状态不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String status;
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package cn.datax.service.data.market.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>
|
||||
* 数据API信息表 实体DTO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-31
|
||||
*/
|
||||
@ApiModel(value = "数据API信息表Model")
|
||||
@Data
|
||||
public class DataApiDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@NotBlank(message = "主键ID不能为空", groups = {ValidationGroups.Update.class})
|
||||
private String id;
|
||||
@ApiModelProperty(value = "API名称")
|
||||
@NotBlank(message = "API名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String apiName;
|
||||
@ApiModelProperty(value = "API版本")
|
||||
@NotBlank(message = "API版本不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String apiVersion;
|
||||
@ApiModelProperty(value = "API路径")
|
||||
@NotBlank(message = "API路径不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String apiUrl;
|
||||
@ApiModelProperty(value = "请求方式")
|
||||
@NotBlank(message = "请求方式不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String reqMethod;
|
||||
@ApiModelProperty(value = "返回格式")
|
||||
@NotBlank(message = "返回格式不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String resType;
|
||||
@ApiModelProperty(value = "IP黑名单多个用英文,隔开")
|
||||
private String deny;
|
||||
@ApiModelProperty(value = "数据源")
|
||||
@NotBlank(message = "数据源不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String sourceId;
|
||||
@ApiModelProperty(value = "限流配置")
|
||||
@Valid
|
||||
private RateLimit rateLimit;
|
||||
@ApiModelProperty(value = "执行配置")
|
||||
@Valid
|
||||
private ExecuteConfig executeConfig;
|
||||
@ApiModelProperty(value = "请求参数")
|
||||
@Valid
|
||||
@NotEmpty(message = "请求参数不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
@Size(min = 1, message="请求参数长度不能少于{min}位")
|
||||
private List<ReqParam> reqParams;
|
||||
@ApiModelProperty(value = "返回参数")
|
||||
@Valid
|
||||
@NotEmpty(message = "返回字段不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
@Size(min = 1, message="返回字段长度不能少于{min}位")
|
||||
private List<ResParam> resParams;
|
||||
@ApiModelProperty(value = "状态")
|
||||
@NotNull(message = "状态不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String status;
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.datax.service.data.market.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.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "执行配置信息Model")
|
||||
@Data
|
||||
public class ExecuteConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "数据源")
|
||||
@NotBlank(message = "数据源不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String sourceId;
|
||||
|
||||
@ApiModelProperty(value = "配置方式")
|
||||
@NotNull(message = "配置方式不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String configType;
|
||||
|
||||
@ApiModelProperty(value = "数据库表主键")
|
||||
private String tableId;
|
||||
|
||||
@ApiModelProperty(value = "数据库表")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty(value = "表字段列表")
|
||||
@Valid
|
||||
private List<FieldParam> fieldParams;
|
||||
|
||||
@ApiModelProperty(value = "解析SQL")
|
||||
private String sqlText;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "字段信息Model")
|
||||
@Data
|
||||
public class FieldParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 数据长度
|
||||
*/
|
||||
private Integer dataLength;
|
||||
|
||||
/**
|
||||
* 数据精度
|
||||
*/
|
||||
private Integer dataPrecision;
|
||||
|
||||
/**
|
||||
* 数据小数位
|
||||
*/
|
||||
private Integer dataScale;
|
||||
|
||||
/**
|
||||
* 是否主键
|
||||
*/
|
||||
private String columnKey;
|
||||
|
||||
/**
|
||||
* 是否允许为空
|
||||
*/
|
||||
private String columnNullable;
|
||||
|
||||
/**
|
||||
* 列的序号
|
||||
*/
|
||||
private Integer columnPosition;
|
||||
|
||||
/**
|
||||
* 列默认值
|
||||
*/
|
||||
private String dataDefault;
|
||||
|
||||
/**
|
||||
* 列注释
|
||||
*/
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
* 作为请求参数
|
||||
*/
|
||||
private String reqable;
|
||||
|
||||
/**
|
||||
* 作为返回参数
|
||||
*/
|
||||
private String resable;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.datax.service.data.market.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 javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "字段信息Model")
|
||||
@Data
|
||||
public class FieldRule implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "字段名称")
|
||||
@NotBlank(message = "字段名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String fieldName;
|
||||
@ApiModelProperty(value = "脱敏类型")
|
||||
@NotNull(message = "脱敏类型不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String cipherType;
|
||||
@ApiModelProperty(value = "规则类型")
|
||||
@NotNull(message = "规则类型不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String cryptType;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "http接口Model")
|
||||
@Data
|
||||
public class HttpService implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "请求地址")
|
||||
private String url;
|
||||
@ApiModelProperty(value = "请求头")
|
||||
private String header;
|
||||
@ApiModelProperty(value = "请求参数")
|
||||
private String param;
|
||||
@ApiModelProperty(value = "请求方式")
|
||||
private String httpMethod;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.datax.service.data.market.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.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "限流信息Model")
|
||||
@Data
|
||||
public class RateLimit implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "是否限流:0:否,1:是")
|
||||
@NotNull(message = "是否限流不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String enable;
|
||||
@ApiModelProperty(value = "请求次数默认5次")
|
||||
private Integer times = 5;
|
||||
@ApiModelProperty(value = "请求时间范围默认60秒")
|
||||
private Integer seconds = 60;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.datax.service.data.market.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 javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "请求参数信息Model")
|
||||
@Data
|
||||
public class ReqParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "参数名称")
|
||||
@NotBlank(message = "参数名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String paramName;
|
||||
|
||||
@ApiModelProperty(value = "是否为空")
|
||||
@NotNull(message = "是否为空不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String nullable;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
@NotBlank(message = "描述不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String paramComment;
|
||||
|
||||
@ApiModelProperty(value = "操作符")
|
||||
@NotNull(message = "操作符不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String whereType;
|
||||
|
||||
@ApiModelProperty(value = "参数类型")
|
||||
@NotNull(message = "参数类型不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String paramType;
|
||||
|
||||
@ApiModelProperty(value = "示例值")
|
||||
@NotBlank(message = "示例值不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String exampleValue;
|
||||
|
||||
@ApiModelProperty(value = "默认值")
|
||||
@NotBlank(message = "默认值不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String defaultValue;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.datax.service.data.market.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 javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "返回参数信息Model")
|
||||
@Data
|
||||
public class ResParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "字段名称")
|
||||
@NotBlank(message = "字段名称不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String fieldName;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
@NotBlank(message = "描述不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String fieldComment;
|
||||
|
||||
@ApiModelProperty(value = "数据类型")
|
||||
@NotNull(message = "数据类型不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty(value = "示例值")
|
||||
@NotBlank(message = "示例值不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String exampleValue;
|
||||
|
||||
@ApiModelProperty(value = "字段别名")
|
||||
private String fieldAliasName;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "服务调用Model")
|
||||
@Data
|
||||
public class ServiceExecuteDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "服务编号")
|
||||
private String serviceNo;
|
||||
|
||||
@ApiModelProperty(value = "http服务请求头")
|
||||
private String header;
|
||||
@ApiModelProperty(value = "http服务请求参数")
|
||||
private String param;
|
||||
|
||||
@ApiModelProperty(value = "webservice服务请求报文")
|
||||
private String soap;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.datax.service.data.market.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.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表 实体DTO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@ApiModel(value = "服务集成表Model")
|
||||
@Data
|
||||
public class ServiceIntegrationDto 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 serviceName;
|
||||
@ApiModelProperty(value = "服务类型(1http接口,2webservice接口)")
|
||||
private String serviceType;
|
||||
@ApiModelProperty(value = "http接口")
|
||||
@Valid
|
||||
private HttpService httpService;
|
||||
@ApiModelProperty(value = "webservice接口")
|
||||
@Valid
|
||||
private WebService webService;
|
||||
@ApiModelProperty(value = "状态")
|
||||
@NotNull(message = "状态不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
|
||||
private String status;
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.datax.service.data.market.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;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成调用日志表 实体DTO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@ApiModel(value = "服务集成调用日志表Model")
|
||||
@Data
|
||||
public class ServiceLogDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@NotBlank(message = "主键ID不能为空", groups = {ValidationGroups.Update.class})
|
||||
private String id;
|
||||
@ApiModelProperty(value = "服务id")
|
||||
private String serviceId;
|
||||
@ApiModelProperty(value = "调用者id")
|
||||
private String callerId;
|
||||
@ApiModelProperty(value = "调用者ip")
|
||||
private String callerIp;
|
||||
@ApiModelProperty(value = "调用时间")
|
||||
private LocalDateTime callerDate;
|
||||
@ApiModelProperty(value = "调用请求头")
|
||||
private String callerHeader;
|
||||
@ApiModelProperty(value = "调用请求参数")
|
||||
private String callerParam;
|
||||
@ApiModelProperty(value = "调用报文")
|
||||
private String callerSoap;
|
||||
@ApiModelProperty(value = "调用耗时")
|
||||
private Long time;
|
||||
@ApiModelProperty(value = "信息记录")
|
||||
private String msg;
|
||||
@ApiModelProperty(value = "状态:0:失败,1:成功")
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SqlParseDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "数据源")
|
||||
@NotBlank(message = "数据源不能为空")
|
||||
private String sourceId;
|
||||
|
||||
@ApiModelProperty(value = "SQL文本")
|
||||
@NotBlank(message = "SQL不能为空")
|
||||
private String sqlText;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "API调用参数信息Model")
|
||||
@Data
|
||||
public class TryParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "参数名称")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
private String paramName;
|
||||
|
||||
@ApiModelProperty(value = "参数值")
|
||||
private Object paramValue;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.datax.service.data.market.api.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel(value = "webservice接口Model")
|
||||
@Data
|
||||
public class WebService implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "wsdl地址")
|
||||
private String wsdl;
|
||||
@ApiModelProperty(value = "命名空间")
|
||||
private String targetNamespace;
|
||||
@ApiModelProperty(value = "请求报文")
|
||||
private String soap;
|
||||
@ApiModelProperty(value = "调用方法")
|
||||
private String method;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.datax.service.data.market.api.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("market_api_log")
|
||||
public class ApiLogEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**
|
||||
* 调用api
|
||||
*/
|
||||
private String apiId;
|
||||
/**
|
||||
* api名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String apiName;
|
||||
/**
|
||||
* 调用者id
|
||||
*/
|
||||
private String callerId;
|
||||
/**
|
||||
* 调用者ip
|
||||
*/
|
||||
private String callerIp;
|
||||
/**
|
||||
* 调用url
|
||||
*/
|
||||
private String callerUrl;
|
||||
/**
|
||||
* 调用参数
|
||||
*/
|
||||
private String callerParams;
|
||||
/**
|
||||
* 调用数据量
|
||||
*/
|
||||
private Integer callerSize;
|
||||
/**
|
||||
* 调用耗时
|
||||
*/
|
||||
private Long time;
|
||||
/**
|
||||
* 信息记录
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 状态:0:失败,1:成功
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 调用时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime callerDate;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.datax.service.data.market.api.entity;
|
||||
|
||||
import cn.datax.common.base.DataScopeBaseEntity;
|
||||
import cn.datax.service.data.market.api.dto.FieldRule;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import cn.datax.common.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据API脱敏信息表
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "market_api_mask", autoResultMap = true)
|
||||
public class ApiMaskEntity extends DataScopeBaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 数据API
|
||||
*/
|
||||
private String apiId;
|
||||
|
||||
/**
|
||||
* 脱敏名称
|
||||
*/
|
||||
private String maskName;
|
||||
|
||||
/**
|
||||
* 脱敏字段规则配置
|
||||
*/
|
||||
@TableField(value = "config_json", typeHandler = JacksonTypeHandler.class)
|
||||
private List<FieldRule> rules;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.datax.service.data.market.api.entity;
|
||||
|
||||
import cn.datax.common.base.DataScopeBaseEntity;
|
||||
import cn.datax.service.data.market.api.dto.ExecuteConfig;
|
||||
import cn.datax.service.data.market.api.dto.RateLimit;
|
||||
import cn.datax.service.data.market.api.dto.ReqParam;
|
||||
import cn.datax.service.data.market.api.dto.ResParam;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据API信息表
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "market_api", autoResultMap = true)
|
||||
public class DataApiEntity extends DataScopeBaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* API名称
|
||||
*/
|
||||
private String apiName;
|
||||
|
||||
/**
|
||||
* API版本
|
||||
*/
|
||||
private String apiVersion;
|
||||
|
||||
/**
|
||||
* API路径
|
||||
*/
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
private String sourceId;
|
||||
|
||||
/**
|
||||
* 请求类型
|
||||
*/
|
||||
private String reqMethod;
|
||||
|
||||
/**
|
||||
* 返回格式
|
||||
*/
|
||||
private String resType;
|
||||
|
||||
/**
|
||||
* IP黑名单多个,隔开
|
||||
*/
|
||||
private String deny;
|
||||
|
||||
/**
|
||||
* 限流配置
|
||||
*/
|
||||
@TableField(value = "limit_json", typeHandler = JacksonTypeHandler.class)
|
||||
private RateLimit rateLimit;
|
||||
|
||||
|
||||
/**
|
||||
* 执行配置
|
||||
*/
|
||||
@TableField(value = "config_json", typeHandler = JacksonTypeHandler.class)
|
||||
private ExecuteConfig executeConfig;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@TableField(value = "req_json", typeHandler = JacksonTypeHandler.class)
|
||||
private List<ReqParam> reqParams;
|
||||
|
||||
/**
|
||||
* 返回字段
|
||||
*/
|
||||
@TableField(value = "res_json", typeHandler = JacksonTypeHandler.class)
|
||||
private List<ResParam> resParams;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.datax.service.data.market.api.entity;
|
||||
|
||||
import cn.datax.common.base.DataScopeBaseEntity;
|
||||
import cn.datax.service.data.market.api.dto.HttpService;
|
||||
import cn.datax.service.data.market.api.dto.WebService;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "market_service_integration", autoResultMap = true)
|
||||
public class ServiceIntegrationEntity extends DataScopeBaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 服务编号
|
||||
*/
|
||||
private String serviceNo;
|
||||
|
||||
/**
|
||||
* 服务名称
|
||||
*/
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* 服务类型(1http接口,2webservice接口)
|
||||
*/
|
||||
private String serviceType;
|
||||
|
||||
/**
|
||||
* http接口
|
||||
*/
|
||||
@TableField(value = "httpservice_json", typeHandler = JacksonTypeHandler.class)
|
||||
private HttpService httpService;
|
||||
|
||||
/**
|
||||
* webservice接口
|
||||
*/
|
||||
@TableField(value = "webservice_json", typeHandler = JacksonTypeHandler.class)
|
||||
private WebService webService;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.datax.service.data.market.api.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成调用日志表
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("market_service_log")
|
||||
public class ServiceLogEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 服务id
|
||||
*/
|
||||
private String serviceId;
|
||||
|
||||
/**
|
||||
* 服务名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* 调用者id
|
||||
*/
|
||||
private String callerId;
|
||||
|
||||
/**
|
||||
* 调用者ip
|
||||
*/
|
||||
private String callerIp;
|
||||
|
||||
/**
|
||||
* 调用时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime callerDate;
|
||||
|
||||
/**
|
||||
* 调用请求头
|
||||
*/
|
||||
private String callerHeader;
|
||||
|
||||
/**
|
||||
* 调用请求参数
|
||||
*/
|
||||
private String callerParam;
|
||||
|
||||
/**
|
||||
* 调用报文
|
||||
*/
|
||||
private String callerSoap;
|
||||
|
||||
/**
|
||||
* 调用耗时
|
||||
*/
|
||||
private Long time;
|
||||
|
||||
/**
|
||||
* 信息记录
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 状态:0:失败,1:成功
|
||||
*/
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum AlgorithmCrypto {
|
||||
|
||||
BASE64("1", "BASE64加密"),
|
||||
MD5("2", "MD5加密"),
|
||||
SHA_1("3", "SHA_1加密"),
|
||||
SHA_256("4", "SHA_256加密"),
|
||||
AES("5", "AES加密"),
|
||||
DES("6", "DES加密");
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String val;
|
||||
|
||||
AlgorithmCrypto(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public static AlgorithmCrypto getAlgorithmCrypto(String algorithmCrypt) {
|
||||
for (AlgorithmCrypto type : AlgorithmCrypto.values()) {
|
||||
if (type.key.equals(algorithmCrypt)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return BASE64;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum CipherType {
|
||||
|
||||
REGEX("1", "正则替换"),
|
||||
ALGORITHM("2", "加密算法");
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String val;
|
||||
|
||||
CipherType(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public static CipherType getCipherType(String cipherType) {
|
||||
for (CipherType type : CipherType.values()) {
|
||||
if (type.key.equals(cipherType)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return REGEX;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum ConfigType {
|
||||
|
||||
FORM("1", "表引导模式"),
|
||||
SCRIPT("2", "脚本模式");
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String val;
|
||||
|
||||
ConfigType(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
import cn.datax.common.exception.DataException;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public enum ParamType {
|
||||
|
||||
String("1", "字符串"),
|
||||
Integer("2", "整型"),
|
||||
Float("3", "浮点型"),
|
||||
Date("4", "时间"),
|
||||
List("5", "集合");
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String val;
|
||||
|
||||
ParamType(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public static Object parse(ParamType paramType, Object obj) {
|
||||
if (ObjectUtil.isEmpty(obj)) {
|
||||
return null;
|
||||
}
|
||||
switch (paramType) {
|
||||
case String:
|
||||
try {
|
||||
return (java.lang.String)obj;
|
||||
} catch (Exception e) {
|
||||
throw new DataException("参数值[" + obj + "]不是" + String.getVal() + "数据类型]");
|
||||
}
|
||||
case Float:
|
||||
try {
|
||||
return new BigDecimal(obj.toString()).doubleValue();
|
||||
} catch (Exception e) {
|
||||
throw new DataException("参数值[" + obj + "]不是" + Float.getVal() + "数据类型]");
|
||||
}
|
||||
case Integer:
|
||||
try {
|
||||
return (java.lang.Integer)obj;
|
||||
} catch (Exception e) {
|
||||
throw new DataException("参数值[" + obj + "]不是" + Integer.getVal() + "数据类型]");
|
||||
}
|
||||
case List:
|
||||
try {
|
||||
return (java.util.List<?>)obj;
|
||||
} catch (Exception e) {
|
||||
throw new DataException("参数值[" + obj + "]不是" + List.getVal() + "数据类型]");
|
||||
}
|
||||
case Date:
|
||||
try {
|
||||
return DateUtil.parse(obj.toString(), "yyyy-MM-dd HH:mm:ss");
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
return DateUtil.parse(obj.toString(), "yyyy-MM-dd");
|
||||
} catch (Exception ex) {
|
||||
throw new DataException("参数值[" + obj + "]不是" + Date.getVal() + "数据类型]");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ParamType getParamType(String paramType) {
|
||||
for (ParamType type : ParamType.values()) {
|
||||
if (type.key.equals(paramType)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return String;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum RegexCrypto {
|
||||
|
||||
CHINESE_NAME("1", "中文姓名"),
|
||||
ID_CARD("2", "身份证号"),
|
||||
FIXED_PHONE("3", "固定电话"),
|
||||
MOBILE_PHONE("4", "手机号码"),
|
||||
ADDRESS("5", "地址"),
|
||||
EMAIL("6", "电子邮箱"),
|
||||
BANK_CARD("7", "银行卡号"),
|
||||
CNAPS_CODE("8", "公司开户银行联号");
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String val;
|
||||
|
||||
RegexCrypto(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public static RegexCrypto getRegexCrypto(String regexCrypt) {
|
||||
for (RegexCrypto type : RegexCrypto.values()) {
|
||||
if (type.key.equals(regexCrypt)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return CHINESE_NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum ReqMethod {
|
||||
|
||||
GET("GET"),
|
||||
POST("POST");
|
||||
|
||||
private String desc;
|
||||
|
||||
ReqMethod(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum ResType {
|
||||
|
||||
JSON("JSON"),
|
||||
XML("XML");
|
||||
|
||||
private String desc;
|
||||
|
||||
ResType(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum ServiceType {
|
||||
|
||||
HTTP("1", "http接口"),
|
||||
WEBSERVICE("2", "webservice接口");
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String val;
|
||||
|
||||
ServiceType(String key, String val) {
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.datax.service.data.market.api.enums;
|
||||
|
||||
public enum WhereType {
|
||||
|
||||
EQUALS("1", "=", "等于"),
|
||||
NOT_EQUALS("2", "!=", "不等于"),
|
||||
LIKE("3", "LIKE", "全模糊查询"),
|
||||
LIKE_LEFT("4", "LIKE", "左模糊查询"),
|
||||
LIKE_RIGHT("5", "LIKE", "右模糊查询"),
|
||||
GREATER_THAN("6", ">", "大于"),
|
||||
GREATER_THAN_EQUALS("7", ">=", "大于等于"),
|
||||
LESS_THAN("8", "<", "小于"),
|
||||
LESS_THAN_EQUALS("9", "<=", "小于等于"),
|
||||
NULL("10", "IS NULL", "是否为空"),
|
||||
NOT_NULL("11", "IS NOT NULL", "是否不为空"),
|
||||
IN("12", "IN", "IN");
|
||||
|
||||
private final String type;
|
||||
|
||||
private final String key;
|
||||
|
||||
private final String desc;
|
||||
|
||||
WhereType(String type, String key, String desc) {
|
||||
this.type = type;
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static WhereType getWhereType(String whereType) {
|
||||
for (WhereType type : WhereType.values()) {
|
||||
if (type.type.equals(whereType)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return EQUALS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.datax.service.data.market.api.feign;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.ApiMaskEntity;
|
||||
import cn.datax.service.data.market.api.feign.factory.ApiMaskServiceFeignFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@FeignClient(contextId = "apiMaskServiceFeign", value = "service-data-market", fallbackFactory = ApiMaskServiceFeignFallbackFactory.class)
|
||||
public interface ApiMaskServiceFeign {
|
||||
|
||||
@GetMapping("/inner/apiMasks/api/{id}")
|
||||
ApiMaskEntity getApiMaskByApiId(@PathVariable("id") String id);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.api.feign;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.DataApiEntity;
|
||||
import cn.datax.service.data.market.api.feign.factory.DataApiServiceFeignFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "dataApiServiceFeign", value = "service-data-market", fallbackFactory = DataApiServiceFeignFallbackFactory.class)
|
||||
public interface DataApiServiceFeign {
|
||||
|
||||
@GetMapping("/inner/apis/{id}")
|
||||
DataApiEntity getDataApiById(@PathVariable("id") String id);
|
||||
|
||||
@GetMapping("/dataApis/source/{sourceId}")
|
||||
DataApiEntity getBySourceId(@PathVariable String sourceId);
|
||||
|
||||
@GetMapping("/inner/apis/release/list")
|
||||
List<DataApiEntity> getReleaseDataApiList();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.market.api.feign.factory;
|
||||
|
||||
import cn.datax.service.data.market.api.feign.ApiMaskServiceFeign;
|
||||
import cn.datax.service.data.market.api.feign.fallback.ApiMaskServiceFeignFallbackImpl;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApiMaskServiceFeignFallbackFactory implements FallbackFactory<ApiMaskServiceFeign> {
|
||||
|
||||
@Override
|
||||
public ApiMaskServiceFeign create(Throwable throwable) {
|
||||
ApiMaskServiceFeignFallbackImpl apiMaskServiceFeignFallbackImpl = new ApiMaskServiceFeignFallbackImpl();
|
||||
apiMaskServiceFeignFallbackImpl.setCause(throwable);
|
||||
return apiMaskServiceFeignFallbackImpl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.market.api.feign.factory;
|
||||
|
||||
import cn.datax.service.data.market.api.feign.DataApiServiceFeign;
|
||||
import cn.datax.service.data.market.api.feign.fallback.DataApiServiceFeignFallbackImpl;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DataApiServiceFeignFallbackFactory implements FallbackFactory<DataApiServiceFeign> {
|
||||
|
||||
@Override
|
||||
public DataApiServiceFeign create(Throwable throwable) {
|
||||
DataApiServiceFeignFallbackImpl dataApiServiceFeignFallback = new DataApiServiceFeignFallbackImpl();
|
||||
dataApiServiceFeignFallback.setCause(throwable);
|
||||
return dataApiServiceFeignFallback;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.datax.service.data.market.api.feign.fallback;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.ApiMaskEntity;
|
||||
import cn.datax.service.data.market.api.feign.ApiMaskServiceFeign;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ApiMaskServiceFeignFallbackImpl implements ApiMaskServiceFeign {
|
||||
|
||||
@Setter
|
||||
private Throwable cause;
|
||||
|
||||
@Override
|
||||
public ApiMaskEntity getApiMaskByApiId(String id) {
|
||||
log.error("feign 调用{}出错", id, cause);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.datax.service.data.market.api.feign.fallback;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.DataApiEntity;
|
||||
import cn.datax.service.data.market.api.feign.DataApiServiceFeign;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataApiServiceFeignFallbackImpl implements DataApiServiceFeign {
|
||||
|
||||
@Setter
|
||||
private Throwable cause;
|
||||
|
||||
@Override
|
||||
public DataApiEntity getDataApiById(String id) {
|
||||
log.error("feign 调用{}出错", id, cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataApiEntity getBySourceId(String sourceId) {
|
||||
log.error("feign 调用数据集市关联出错", cause);
|
||||
throw new RuntimeException("feign 调用数据集市关联出错", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataApiEntity> getReleaseDataApiList() {
|
||||
log.error("feign 调用出错", cause);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* api调用日志信息表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-21
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ApiLogQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String apiName;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据API脱敏信息表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ApiMaskQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String maskName;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据API信息表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DataApiQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String apiName;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.datax.service.data.market.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ServiceIntegrationQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String serviceName;
|
||||
private String serviceType;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.api.query;
|
||||
|
||||
import cn.datax.common.base.BaseQueryParams;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成调用日志表 查询实体
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ServiceLogQuery extends BaseQueryParams {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String serviceName;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiHeader implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String apiKey;
|
||||
private String secretKey;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ApiLogVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String id;
|
||||
private String apiId;
|
||||
private String apiName;
|
||||
private String callerId;
|
||||
private String callerIp;
|
||||
private String callerUrl;
|
||||
private Integer callerSize;
|
||||
private String callerParams;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime callerDate;
|
||||
private Long time;
|
||||
private String msg;
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.FieldRule;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据API脱敏信息表 实体VO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-14
|
||||
*/
|
||||
@Data
|
||||
public class ApiMaskVo 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 remark;
|
||||
private String apiId;
|
||||
private String maskName;
|
||||
private List<FieldRule> rules;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.ExecuteConfig;
|
||||
import cn.datax.service.data.market.api.dto.RateLimit;
|
||||
import cn.datax.service.data.market.api.dto.ReqParam;
|
||||
import cn.datax.service.data.market.api.dto.ResParam;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据API信息表 实体VO
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-31
|
||||
*/
|
||||
@Data
|
||||
public class DataApiVo 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 remark;
|
||||
private String apiName;
|
||||
private String apiVersion;
|
||||
private String apiUrl;
|
||||
private String reqMethod;
|
||||
private String deny;
|
||||
private String resType;
|
||||
private RateLimit rateLimit;
|
||||
private ExecuteConfig executeConfig;
|
||||
private List<ReqParam> reqParams;
|
||||
private List<ResParam> resParams;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ServiceHeader implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String serviceKey;
|
||||
private String secretKey;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.HttpService;
|
||||
import cn.datax.service.data.market.api.dto.WebService;
|
||||
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-20
|
||||
*/
|
||||
@Data
|
||||
public class ServiceIntegrationVo 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 serviceNo;
|
||||
private String serviceName;
|
||||
private String serviceType;
|
||||
private HttpService httpService;
|
||||
private WebService webService;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.datax.service.data.market.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-20
|
||||
*/
|
||||
@Data
|
||||
public class ServiceLogVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private String id;
|
||||
private String status;
|
||||
private String serviceId;
|
||||
private String serviceName;
|
||||
private String callerId;
|
||||
private String callerIp;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime callerDate;
|
||||
private String callerHeader;
|
||||
private String callerParam;
|
||||
private String callerSoap;
|
||||
private Long time;
|
||||
private String msg;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.market.api.vo;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.ReqParam;
|
||||
import cn.datax.service.data.market.api.dto.ResParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SqlParseVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private List<ReqParam> reqParams;
|
||||
private List<ResParam> resParams;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.datax.service.data.market.api.feign.factory.DataApiServiceFeignFallbackFactory,\
|
||||
cn.datax.service.data.market.api.feign.fallback.DataApiServiceFeignFallbackImpl,\
|
||||
cn.datax.service.data.market.api.feign.factory.ApiMaskServiceFeignFallbackFactory,\
|
||||
cn.datax.service.data.market.api.feign.fallback.ApiMaskServiceFeignFallbackImpl
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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-market-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-market-service-integration</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-database</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-market-service-api</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.market.integration;
|
||||
|
||||
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"})
|
||||
@SpringBootApplication
|
||||
public class DataxIntegrationApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataxIntegrationApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.datax.service.data.market.integration.async;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.ServiceLogDto;
|
||||
import cn.datax.service.data.market.integration.service.ServiceLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 异步处理
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AsyncTask {
|
||||
|
||||
@Autowired
|
||||
private ServiceLogService serviceLogService;
|
||||
|
||||
@Async("taskExecutor")
|
||||
public void doTask(ServiceLogDto serviceLog) {
|
||||
serviceLogService.saveServiceLog(serviceLog);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.datax.service.data.market.integration.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
public class AsyncConfig {
|
||||
|
||||
@Bean("taskExecutor")
|
||||
public Executor taskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(20);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setKeepAliveSeconds(30);
|
||||
executor.setThreadNamePrefix("async-service-");
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
executor.setAwaitTerminationSeconds(60);
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.datax.service.data.market.integration.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,31 @@
|
||||
package cn.datax.service.data.market.integration.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.market.integration.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.market.integration.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.market.integration.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.market.integration.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,21 @@
|
||||
package cn.datax.service.data.market.integration.controller;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.ServiceExecuteDto;
|
||||
import cn.datax.service.data.market.integration.service.ServiceExecuteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
public class ServiceExecuteController {
|
||||
|
||||
@Autowired
|
||||
private ServiceExecuteService serviceExecuteService;
|
||||
|
||||
@PostMapping("/execute")
|
||||
public Object execute(@RequestBody ServiceExecuteDto serviceExecuteDto, HttpServletRequest request) {
|
||||
Object obj = serviceExecuteService.execute(serviceExecuteDto, request);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package cn.datax.service.data.market.integration.controller;
|
||||
|
||||
import cn.datax.common.core.JsonPage;
|
||||
import cn.datax.common.core.R;
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import cn.datax.service.data.market.api.dto.ServiceIntegrationDto;
|
||||
import cn.datax.service.data.market.api.entity.ServiceIntegrationEntity;
|
||||
import cn.datax.service.data.market.api.vo.ServiceIntegrationVo;
|
||||
import cn.datax.service.data.market.api.query.ServiceIntegrationQuery;
|
||||
import cn.datax.service.data.market.integration.mapstruct.ServiceIntegrationMapper;
|
||||
import cn.datax.service.data.market.integration.service.ServiceIntegrationService;
|
||||
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-20
|
||||
*/
|
||||
@Api(tags = {"服务集成表"})
|
||||
@RestController
|
||||
@RequestMapping("/services")
|
||||
public class ServiceIntegrationController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ServiceIntegrationService serviceIntegrationService;
|
||||
|
||||
@Autowired
|
||||
private ServiceIntegrationMapper serviceIntegrationMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public R getServiceIntegrationById(@PathVariable String id) {
|
||||
ServiceIntegrationEntity serviceIntegrationEntity = serviceIntegrationService.getServiceIntegrationById(id);
|
||||
return R.ok().setData(serviceIntegrationMapper.toVO(serviceIntegrationEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询信息
|
||||
*
|
||||
* @param serviceIntegrationQuery
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询", notes = "")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "serviceIntegrationQuery", value = "查询实体serviceIntegrationQuery", required = true, dataTypeClass = ServiceIntegrationQuery.class)
|
||||
})
|
||||
@GetMapping("/page")
|
||||
public R getServiceIntegrationPage(ServiceIntegrationQuery serviceIntegrationQuery) {
|
||||
QueryWrapper<ServiceIntegrationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(serviceIntegrationQuery.getServiceName()), "service_name", serviceIntegrationQuery.getServiceName());
|
||||
IPage<ServiceIntegrationEntity> page = serviceIntegrationService.page(new Page<>(serviceIntegrationQuery.getPageNum(), serviceIntegrationQuery.getPageSize()), queryWrapper);
|
||||
List<ServiceIntegrationVo> collect = page.getRecords().stream().map(serviceIntegrationMapper::toVO).collect(Collectors.toList());
|
||||
JsonPage<ServiceIntegrationVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
|
||||
return R.ok().setData(jsonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param serviceIntegration
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加信息", notes = "根据serviceIntegration对象添加信息")
|
||||
@ApiImplicitParam(name = "serviceIntegration", value = "详细实体serviceIntegration", required = true, dataType = "ServiceIntegrationDto")
|
||||
@PostMapping()
|
||||
public R saveServiceIntegration(@RequestBody @Validated({ValidationGroups.Insert.class}) ServiceIntegrationDto serviceIntegration) {
|
||||
ServiceIntegrationEntity serviceIntegrationEntity = serviceIntegrationService.saveServiceIntegration(serviceIntegration);
|
||||
return R.ok().setData(serviceIntegrationMapper.toVO(serviceIntegrationEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param serviceIntegration
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改信息", notes = "根据url的id来指定修改对象,并根据传过来的信息来修改详细信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "serviceIntegration", value = "详细实体serviceIntegration", required = true, dataType = "ServiceIntegrationDto")
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public R updateServiceIntegration(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ServiceIntegrationDto serviceIntegration) {
|
||||
ServiceIntegrationEntity serviceIntegrationEntity = serviceIntegrationService.updateServiceIntegration(serviceIntegration);
|
||||
return R.ok().setData(serviceIntegrationMapper.toVO(serviceIntegrationEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@DeleteMapping("/{id}")
|
||||
public R deleteServiceIntegrationById(@PathVariable String id) {
|
||||
serviceIntegrationService.deleteServiceIntegrationById(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 deleteServiceIntegrationBatch(@PathVariable List<String> ids) {
|
||||
serviceIntegrationService.deleteServiceIntegrationBatch(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{id}")
|
||||
public R getServiceIntegrationDetailById(@PathVariable String id) {
|
||||
Map<String, Object> map = serviceIntegrationService.getServiceIntegrationDetailById(id);
|
||||
return R.ok().setData(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package cn.datax.service.data.market.integration.controller;
|
||||
|
||||
import cn.datax.common.core.JsonPage;
|
||||
import cn.datax.common.core.R;
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import cn.datax.service.data.market.api.dto.ServiceLogDto;
|
||||
import cn.datax.service.data.market.api.entity.ServiceLogEntity;
|
||||
import cn.datax.service.data.market.api.vo.ServiceLogVo;
|
||||
import cn.datax.service.data.market.api.query.ServiceLogQuery;
|
||||
import cn.datax.service.data.market.integration.mapstruct.ServiceLogMapper;
|
||||
import cn.datax.service.data.market.integration.service.ServiceLogService;
|
||||
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-20
|
||||
*/
|
||||
@Api(tags = {"服务集成调用日志表"})
|
||||
@RestController
|
||||
@RequestMapping("/serviceLogs")
|
||||
public class ServiceLogController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ServiceLogService serviceLogService;
|
||||
|
||||
@Autowired
|
||||
private ServiceLogMapper serviceLogMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public R getServiceLogById(@PathVariable String id) {
|
||||
ServiceLogEntity serviceLogEntity = serviceLogService.getServiceLogById(id);
|
||||
return R.ok().setData(serviceLogMapper.toVO(serviceLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询信息
|
||||
*
|
||||
* @param serviceLogQuery
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询", notes = "")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "serviceLogQuery", value = "查询实体serviceLogQuery", required = true, dataTypeClass = ServiceLogQuery.class)
|
||||
})
|
||||
@GetMapping("/page")
|
||||
public R getServiceLogPage(ServiceLogQuery serviceLogQuery) {
|
||||
QueryWrapper<ServiceLogEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(serviceLogQuery.getServiceName()), "service_name", serviceLogQuery.getServiceName());
|
||||
IPage<ServiceLogEntity> page = serviceLogService.page(new Page<>(serviceLogQuery.getPageNum(), serviceLogQuery.getPageSize()), queryWrapper);
|
||||
List<ServiceLogVo> collect = page.getRecords().stream().map(serviceLogMapper::toVO).collect(Collectors.toList());
|
||||
JsonPage<ServiceLogVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
|
||||
return R.ok().setData(jsonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param serviceLog
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加信息", notes = "根据serviceLog对象添加信息")
|
||||
@ApiImplicitParam(name = "serviceLog", value = "详细实体serviceLog", required = true, dataType = "ServiceLogDto")
|
||||
@PostMapping()
|
||||
public R saveServiceLog(@RequestBody @Validated({ValidationGroups.Insert.class}) ServiceLogDto serviceLog) {
|
||||
ServiceLogEntity serviceLogEntity = serviceLogService.saveServiceLog(serviceLog);
|
||||
return R.ok().setData(serviceLogMapper.toVO(serviceLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param serviceLog
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改信息", notes = "根据url的id来指定修改对象,并根据传过来的信息来修改详细信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "serviceLog", value = "详细实体serviceLog", required = true, dataType = "ServiceLogDto")
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public R updateServiceLog(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ServiceLogDto serviceLog) {
|
||||
ServiceLogEntity serviceLogEntity = serviceLogService.updateServiceLog(serviceLog);
|
||||
return R.ok().setData(serviceLogMapper.toVO(serviceLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@DeleteMapping("/{id}")
|
||||
public R deleteServiceLogById(@PathVariable String id) {
|
||||
serviceLogService.deleteServiceLogById(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 deleteServiceLogBatch(@PathVariable List<String> ids) {
|
||||
serviceLogService.deleteServiceLogBatch(ids);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.datax.service.data.market.integration.dao;
|
||||
|
||||
import cn.datax.common.base.BaseDao;
|
||||
import cn.datax.service.data.market.api.entity.ServiceIntegrationEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface ServiceIntegrationDao extends BaseDao<ServiceIntegrationEntity> {
|
||||
|
||||
@Override
|
||||
ServiceIntegrationEntity selectById(Serializable id);
|
||||
|
||||
@Override
|
||||
<E extends IPage<ServiceIntegrationEntity>> E selectPage(E page, @Param(Constants.WRAPPER) Wrapper<ServiceIntegrationEntity> queryWrapper);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.datax.service.data.market.integration.dao;
|
||||
|
||||
import cn.datax.common.base.BaseDao;
|
||||
import cn.datax.service.data.market.api.entity.ServiceLogEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成调用日志表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface ServiceLogDao extends BaseDao<ServiceLogEntity> {
|
||||
|
||||
@Override
|
||||
ServiceLogEntity selectById(Serializable id);
|
||||
|
||||
@Override
|
||||
<E extends IPage<ServiceLogEntity>> E selectPage(E page, @Param(Constants.WRAPPER) Wrapper<ServiceLogEntity> queryWrapper);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.datax.service.data.market.integration.mapstruct;
|
||||
|
||||
import cn.datax.common.mapstruct.EntityMapper;
|
||||
import cn.datax.service.data.market.api.dto.ServiceIntegrationDto;
|
||||
import cn.datax.service.data.market.api.entity.ServiceIntegrationEntity;
|
||||
import cn.datax.service.data.market.api.vo.ServiceIntegrationVo;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表 Mapper 实体映射
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ServiceIntegrationMapper extends EntityMapper<ServiceIntegrationDto, ServiceIntegrationEntity, ServiceIntegrationVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.datax.service.data.market.integration.mapstruct;
|
||||
|
||||
import cn.datax.common.mapstruct.EntityMapper;
|
||||
import cn.datax.service.data.market.api.dto.ServiceLogDto;
|
||||
import cn.datax.service.data.market.api.entity.ServiceLogEntity;
|
||||
import cn.datax.service.data.market.api.vo.ServiceLogVo;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成调用日志表 Mapper 实体映射
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ServiceLogMapper extends EntityMapper<ServiceLogDto, ServiceLogEntity, ServiceLogVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.datax.service.data.market.integration.service;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.ServiceExecuteDto;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public interface ServiceExecuteService {
|
||||
|
||||
Object execute(ServiceExecuteDto serviceExecuteDto, HttpServletRequest request);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.datax.service.data.market.integration.service;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.ServiceIntegrationEntity;
|
||||
import cn.datax.service.data.market.api.dto.ServiceIntegrationDto;
|
||||
import cn.datax.common.base.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
public interface ServiceIntegrationService extends BaseService<ServiceIntegrationEntity> {
|
||||
|
||||
ServiceIntegrationEntity saveServiceIntegration(ServiceIntegrationDto serviceIntegration);
|
||||
|
||||
ServiceIntegrationEntity updateServiceIntegration(ServiceIntegrationDto serviceIntegration);
|
||||
|
||||
ServiceIntegrationEntity getServiceIntegrationById(String id);
|
||||
|
||||
void deleteServiceIntegrationById(String id);
|
||||
|
||||
void deleteServiceIntegrationBatch(List<String> ids);
|
||||
|
||||
Map<String, Object> getServiceIntegrationDetailById(String id);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.datax.service.data.market.integration.service;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.ServiceLogEntity;
|
||||
import cn.datax.service.data.market.api.dto.ServiceLogDto;
|
||||
import cn.datax.common.base.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成调用日志表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
public interface ServiceLogService extends BaseService<ServiceLogEntity> {
|
||||
|
||||
ServiceLogEntity saveServiceLog(ServiceLogDto serviceLog);
|
||||
|
||||
ServiceLogEntity updateServiceLog(ServiceLogDto serviceLog);
|
||||
|
||||
ServiceLogEntity getServiceLogById(String id);
|
||||
|
||||
void deleteServiceLogById(String id);
|
||||
|
||||
void deleteServiceLogBatch(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package cn.datax.service.data.market.integration.service.impl;
|
||||
|
||||
import cn.datax.common.exception.DataException;
|
||||
import cn.datax.service.data.market.api.dto.ServiceExecuteDto;
|
||||
import cn.datax.service.data.market.api.entity.ServiceIntegrationEntity;
|
||||
import cn.datax.service.data.market.api.enums.ReqMethod;
|
||||
import cn.datax.service.data.market.api.enums.ServiceType;
|
||||
import cn.datax.service.data.market.integration.dao.ServiceIntegrationDao;
|
||||
import cn.datax.service.data.market.integration.service.ServiceExecuteService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ServiceExecuteServiceImpl implements ServiceExecuteService {
|
||||
|
||||
@Autowired
|
||||
private ServiceIntegrationDao serviceIntegrationDao;
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public Object execute(ServiceExecuteDto execute, HttpServletRequest request) {
|
||||
// 密钥校验
|
||||
String serviceKey = request.getHeader("service_key");
|
||||
String secretKey = request.getHeader("secret_key");
|
||||
if (StrUtil.isBlank(serviceKey) || StrUtil.isBlank(secretKey)) {
|
||||
throw new DataException("service_key或secret_key空");
|
||||
}
|
||||
if (StrUtil.isBlank(execute.getServiceNo())) {
|
||||
throw new DataException("服务编号不能为空");
|
||||
}
|
||||
ServiceIntegrationEntity serviceIntegrationEntity = serviceIntegrationDao.selectOne(Wrappers.<ServiceIntegrationEntity>lambdaQuery()
|
||||
.eq(ServiceIntegrationEntity::getServiceNo, execute.getServiceNo()));
|
||||
if (serviceIntegrationEntity == null) {
|
||||
throw new DataException("找不到服务:" + execute.getServiceNo());
|
||||
}
|
||||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
ResponseEntity<String> response = null;
|
||||
if (ServiceType.HTTP.getKey().equals(serviceIntegrationEntity.getServiceType())) {
|
||||
String header = execute.getHeader();
|
||||
String param = execute.getParam();
|
||||
if (StrUtil.isNotBlank(header)) {
|
||||
try {
|
||||
Map<String, Object> headerMap = objectMapper.readValue(header, new TypeReference<HashMap<String,Object>>(){});
|
||||
Iterator<Map.Entry<String, Object>> headerEntries = headerMap.entrySet().iterator();
|
||||
while(headerEntries.hasNext()){
|
||||
Map.Entry<String, Object> entry = headerEntries.next();
|
||||
headers.add(entry.getKey(), String.valueOf(entry.getValue()));
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new DataException("请求头格式有问题");
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(param)) {
|
||||
try {
|
||||
Map<String, Object> paramMap = objectMapper.readValue(param, new TypeReference<HashMap<String,Object>>(){});
|
||||
Iterator<Map.Entry<String, Object>> paramEntries = paramMap.entrySet().iterator();
|
||||
while(paramEntries.hasNext()){
|
||||
Map.Entry<String, Object> entry = paramEntries.next();
|
||||
params.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new DataException("请求参数格式有问题");
|
||||
}
|
||||
}
|
||||
// http服务
|
||||
HttpMethod httpMethod = HttpMethod.GET;
|
||||
if (ReqMethod.POST.getDesc().equals(serviceIntegrationEntity.getHttpService().getHttpMethod())) {
|
||||
httpMethod = HttpMethod.POST;
|
||||
}
|
||||
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(params, headers);
|
||||
try {
|
||||
response = restTemplate.exchange(serviceIntegrationEntity.getHttpService().getUrl(), httpMethod, httpEntity, String.class);
|
||||
} catch (Exception e) {
|
||||
throw new DataException(e.getMessage());
|
||||
}
|
||||
} else if (ServiceType.WEBSERVICE.getKey().equals(serviceIntegrationEntity.getServiceType())) {
|
||||
// webservice服务
|
||||
headers.add("SOAPAction", serviceIntegrationEntity.getWebService().getTargetNamespace() + serviceIntegrationEntity.getWebService().getMethod());
|
||||
headers.add("Content-Type", "text/xml;charset=UTF-8");
|
||||
HttpEntity<String> entity = new HttpEntity<>(execute.getSoap(), headers);
|
||||
try {
|
||||
response = restTemplate.exchange(serviceIntegrationEntity.getWebService().getWsdl(), HttpMethod.POST, entity, String.class);
|
||||
} catch (Exception e) {
|
||||
throw new DataException(e.getMessage());
|
||||
}
|
||||
}
|
||||
return response.getBody();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.datax.service.data.market.integration.service.impl;
|
||||
|
||||
import cn.datax.common.utils.MD5Util;
|
||||
import cn.datax.common.utils.SecurityUtil;
|
||||
import cn.datax.service.data.market.api.entity.ServiceIntegrationEntity;
|
||||
import cn.datax.service.data.market.api.dto.ServiceIntegrationDto;
|
||||
import cn.datax.service.data.market.api.vo.ApiHeader;
|
||||
import cn.datax.service.data.market.api.vo.ServiceHeader;
|
||||
import cn.datax.service.data.market.integration.service.ServiceIntegrationService;
|
||||
import cn.datax.service.data.market.integration.mapstruct.ServiceIntegrationMapper;
|
||||
import cn.datax.service.data.market.integration.dao.ServiceIntegrationDao;
|
||||
import cn.datax.common.base.BaseServiceImpl;
|
||||
import cn.datax.service.data.market.integration.utils.SerialUtil;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务集成表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-20
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class ServiceIntegrationServiceImpl extends BaseServiceImpl<ServiceIntegrationDao, ServiceIntegrationEntity> implements ServiceIntegrationService {
|
||||
|
||||
@Autowired
|
||||
private ServiceIntegrationDao serviceIntegrationDao;
|
||||
|
||||
@Autowired
|
||||
private ServiceIntegrationMapper serviceIntegrationMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServiceIntegrationEntity saveServiceIntegration(ServiceIntegrationDto serviceIntegrationDto) {
|
||||
ServiceIntegrationEntity serviceIntegration = serviceIntegrationMapper.toEntity(serviceIntegrationDto);
|
||||
String serialNo = SerialUtil.getSerialNo(3);
|
||||
serviceIntegration.setServiceNo(serialNo);
|
||||
serviceIntegrationDao.insert(serviceIntegration);
|
||||
return serviceIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServiceIntegrationEntity updateServiceIntegration(ServiceIntegrationDto serviceIntegrationDto) {
|
||||
ServiceIntegrationEntity serviceIntegration = serviceIntegrationMapper.toEntity(serviceIntegrationDto);
|
||||
serviceIntegrationDao.updateById(serviceIntegration);
|
||||
return serviceIntegration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceIntegrationEntity getServiceIntegrationById(String id) {
|
||||
ServiceIntegrationEntity serviceIntegrationEntity = super.getById(id);
|
||||
return serviceIntegrationEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteServiceIntegrationById(String id) {
|
||||
serviceIntegrationDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteServiceIntegrationBatch(List<String> ids) {
|
||||
serviceIntegrationDao.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getServiceIntegrationDetailById(String id) {
|
||||
ServiceIntegrationEntity serviceIntegrationEntity = super.getById(id);
|
||||
ServiceHeader serviceHeader = new ServiceHeader();
|
||||
MD5Util mt = null;
|
||||
try {
|
||||
mt = MD5Util.getInstance();
|
||||
serviceHeader.setServiceKey(mt.encode(id));
|
||||
serviceHeader.setSecretKey(mt.encode(SecurityUtil.getUserId()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("data", serviceIntegrationMapper.toVO(serviceIntegrationEntity));
|
||||
map.put("header", serviceHeader);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.datax.service.data.market.integration.service.impl;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.ServiceLogEntity;
|
||||
import cn.datax.service.data.market.api.dto.ServiceLogDto;
|
||||
import cn.datax.service.data.market.integration.service.ServiceLogService;
|
||||
import cn.datax.service.data.market.integration.mapstruct.ServiceLogMapper;
|
||||
import cn.datax.service.data.market.integration.dao.ServiceLogDao;
|
||||
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-20
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class ServiceLogServiceImpl extends BaseServiceImpl<ServiceLogDao, ServiceLogEntity> implements ServiceLogService {
|
||||
|
||||
@Autowired
|
||||
private ServiceLogDao serviceLogDao;
|
||||
|
||||
@Autowired
|
||||
private ServiceLogMapper serviceLogMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServiceLogEntity saveServiceLog(ServiceLogDto serviceLogDto) {
|
||||
ServiceLogEntity serviceLog = serviceLogMapper.toEntity(serviceLogDto);
|
||||
serviceLogDao.insert(serviceLog);
|
||||
return serviceLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServiceLogEntity updateServiceLog(ServiceLogDto serviceLogDto) {
|
||||
ServiceLogEntity serviceLog = serviceLogMapper.toEntity(serviceLogDto);
|
||||
serviceLogDao.updateById(serviceLog);
|
||||
return serviceLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceLogEntity getServiceLogById(String id) {
|
||||
ServiceLogEntity serviceLogEntity = super.getById(id);
|
||||
return serviceLogEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteServiceLogById(String id) {
|
||||
serviceLogDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteServiceLogBatch(List<String> ids) {
|
||||
serviceLogDao.deleteBatchIds(ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.datax.service.data.market.integration.utils;
|
||||
|
||||
import cn.datax.common.utils.SpringContextHolder;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* redis生成每日流水号
|
||||
*/
|
||||
public class SerialUtil {
|
||||
|
||||
private static StringRedisTemplate redisTemplate = SpringContextHolder.getBean(StringRedisTemplate.class);
|
||||
|
||||
/**
|
||||
* 通过redis生成自增号
|
||||
* @param length 序号长度
|
||||
* @return
|
||||
*/
|
||||
public static String getSerialNo(int length) {
|
||||
// 编号
|
||||
String key = LocalDate.now().format(DateTimeFormatter.ISO_DATE).replace("-", "");
|
||||
String no;
|
||||
// 自增获取
|
||||
Long temp = redisTemplate.opsForValue().increment(key, 1);
|
||||
if (temp == 1) {
|
||||
// 过期时间,一天
|
||||
redisTemplate.expire(key, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return key + String.format("%0" + length + "d", temp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
server:
|
||||
port: 8824
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: service-data-integration
|
||||
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-api-integration"/>
|
||||
<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,63 @@
|
||||
<?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.market.integration.dao.ServiceIntegrationDao">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.datax.service.data.market.api.entity.ServiceIntegrationEntity">
|
||||
<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="create_dept" property="createDept" />
|
||||
<result column="service_no" property="serviceNo" />
|
||||
<result column="service_name" property="serviceName" />
|
||||
<result column="service_type" property="serviceType" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="ExtendResultMap" type="cn.datax.service.data.market.api.entity.ServiceIntegrationEntity" extends="BaseResultMap">
|
||||
<result column="httpservice_json" property="httpService" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
||||
<result column="webservice_json" property="webService" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
status,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
create_dept, service_no, service_name, service_type
|
||||
</sql>
|
||||
|
||||
<sql id="Extend_Column_List">
|
||||
id,
|
||||
status,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
create_dept, service_no, service_name, service_type, httpservice_json, webservice_json
|
||||
</sql>
|
||||
|
||||
<select id="selectById" resultMap="ExtendResultMap">
|
||||
SELECT
|
||||
<include refid="Extend_Column_List"></include>
|
||||
FROM market_service_integration
|
||||
WHERE 1=1 AND id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"></include>
|
||||
FROM market_service_integration
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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.market.integration.dao.ServiceLogDao">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.datax.service.data.market.api.entity.ServiceLogEntity">
|
||||
<result column="id" property="id" />
|
||||
<result column="status" property="status" />
|
||||
<result column="service_id" property="serviceId" />
|
||||
<result column="service_name" property="serviceName" />
|
||||
<result column="caller_id" property="callerId" />
|
||||
<result column="caller_ip" property="callerIp" />
|
||||
<result column="caller_date" property="callerDate" />
|
||||
<result column="caller_header" property="callerHeader" />
|
||||
<result column="caller_param" property="callerParam" />
|
||||
<result column="caller_soap" property="callerSoap" />
|
||||
<result column="time" property="time" />
|
||||
<result column="msg" property="msg" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
status,
|
||||
service_id, caller_id, caller_ip, caller_date, caller_header, caller_param, caller_soap, time, msg
|
||||
</sql>
|
||||
|
||||
<sql id="Log_Column_List">
|
||||
${alias}.id,
|
||||
${alias}.status,
|
||||
${alias}.service_id, ${alias}.caller_id, ${alias}.caller_ip, ${alias}.caller_date,
|
||||
${alias}.caller_header, ${alias}.caller_param, ${alias}.caller_soap, ${alias}.time, ${alias}.msg
|
||||
</sql>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT service.service_name,
|
||||
<include refid="Log_Column_List"><property name="alias" value="log"/></include>
|
||||
FROM market_service_log log
|
||||
LEFT JOIN market_service_integration service ON service.id = log.service_id
|
||||
WHERE 1 = 1 AND log.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT service.service_name,
|
||||
<include refid="Log_Column_List"><property name="alias" value="log"/></include>
|
||||
FROM market_service_log log
|
||||
LEFT JOIN market_service_integration service ON service.id = log.service_id
|
||||
${ew.customSqlSegment}
|
||||
</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
|
||||
@@ -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-market-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-market-service-mapping</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-database</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-market-service-api</artifactId>
|
||||
<version>0.4.x</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platform</groupId>
|
||||
<artifactId>data-metadata-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,14 @@
|
||||
package cn.datax.service.data.market.mapping;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@EnableFeignClients(basePackages = {"cn.datax.service.system.api.feign", "cn.datax.service.data.metadata.api.feign", "cn.datax.service.data.market.api.feign"})
|
||||
@SpringBootApplication
|
||||
public class DataxMappingApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataxMappingApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.datax.service.data.market.mapping.async;
|
||||
|
||||
import cn.datax.service.data.market.api.dto.ApiLogDto;
|
||||
import cn.datax.service.data.market.mapping.service.ApiLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 异步处理
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AsyncTask {
|
||||
|
||||
@Autowired
|
||||
private ApiLogService apiLogService;
|
||||
|
||||
@Async("taskExecutor")
|
||||
public void doTask(ApiLogDto apiLogDto) {
|
||||
apiLogService.saveApiLog(apiLogDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.datax.service.data.market.mapping.config;
|
||||
|
||||
import cn.datax.service.data.market.mapping.handler.MappingHandlerMapping;
|
||||
import cn.datax.service.data.market.mapping.handler.RequestHandler;
|
||||
import cn.datax.service.data.market.mapping.handler.RequestInterceptor;
|
||||
import cn.datax.service.data.market.mapping.service.impl.ApiMappingEngine;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
|
||||
@Configuration
|
||||
public class ApiMappingConfig {
|
||||
|
||||
@Bean
|
||||
public MappingHandlerMapping mappingHandlerMapping(RequestMappingHandlerMapping requestMappingHandlerMapping,
|
||||
ApiMappingEngine apiMappingEngine,
|
||||
RedisTemplate redisTemplate,
|
||||
ObjectMapper objectMapper) {
|
||||
MappingHandlerMapping mappingHandlerMapping = new MappingHandlerMapping();
|
||||
mappingHandlerMapping.setHandler(requestHandler(apiMappingEngine, redisTemplate, objectMapper));
|
||||
mappingHandlerMapping.setRequestMappingHandlerMapping(requestMappingHandlerMapping);
|
||||
return mappingHandlerMapping;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RequestHandler requestHandler(ApiMappingEngine apiMappingEngine, RedisTemplate redisTemplate, ObjectMapper objectMapper) {
|
||||
RequestHandler handler = new RequestHandler();
|
||||
handler.setApiMappingEngine(apiMappingEngine);
|
||||
handler.setObjectMapper(objectMapper);
|
||||
handler.setRequestInterceptor(new RequestInterceptor(redisTemplate));
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.datax.service.data.market.mapping.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
public class AsyncConfig {
|
||||
|
||||
@Bean("taskExecutor")
|
||||
public Executor taskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(20);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setKeepAliveSeconds(30);
|
||||
executor.setThreadNamePrefix("async-service-");
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
executor.setAwaitTerminationSeconds(60);
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.datax.service.data.market.mapping.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,73 @@
|
||||
package cn.datax.service.data.market.mapping.config;
|
||||
|
||||
import cn.datax.common.rabbitmq.config.RabbitMqConstant;
|
||||
import cn.datax.common.utils.ThrowableUtil;
|
||||
import cn.datax.service.data.market.api.entity.DataApiEntity;
|
||||
import cn.datax.service.data.market.api.feign.DataApiServiceFeign;
|
||||
import cn.datax.service.data.market.mapping.handler.MappingHandlerMapping;
|
||||
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 {
|
||||
|
||||
private static String HANDLER_RELEASE = "1";
|
||||
private static String HANDLER_CANCEL = "2";
|
||||
|
||||
@Autowired
|
||||
private DataApiServiceFeign dataApiServiceFeign;
|
||||
|
||||
@Autowired
|
||||
private MappingHandlerMapping mappingHandlerMapping;
|
||||
|
||||
/**
|
||||
* api发布与撤销
|
||||
* @param map type 1:发布 2:撤销
|
||||
* @param channel
|
||||
* @param message
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RabbitListener(bindings = @QueueBinding(exchange = @Exchange(name = RabbitMqConstant.FANOUT_EXCHANGE_API, type = "fanout", durable = "true", autoDelete = "false"),
|
||||
value = @Queue(value = RabbitMqConstant.FANOUT_API_QUEUE, durable = "true", exclusive = "false", autoDelete = "false")))
|
||||
public void fanoutQueueRelease(Map map, Channel channel, Message message) throws Exception {
|
||||
try {
|
||||
String id = (String) map.get("id");
|
||||
String type = (String) map.get("type");
|
||||
log.info("fanoutQueueRelease接收到了:{},{}", id, type);
|
||||
DataApiEntity dataApiEntity = dataApiServiceFeign.getDataApiById(id);
|
||||
if (dataApiEntity != null) {
|
||||
if (HANDLER_RELEASE.equals(type)) {
|
||||
mappingHandlerMapping.registerMapping(dataApiEntity);
|
||||
} else if (HANDLER_CANCEL.equals(type)) {
|
||||
mappingHandlerMapping.unregisterMapping(dataApiEntity);
|
||||
}
|
||||
}
|
||||
} 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,49 @@
|
||||
package cn.datax.service.data.market.mapping.config;
|
||||
|
||||
import cn.datax.service.data.market.api.entity.DataApiEntity;
|
||||
import cn.datax.service.data.market.api.feign.DataApiServiceFeign;
|
||||
import cn.datax.service.data.market.mapping.handler.MappingHandlerMapping;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class StartedUpRunner implements ApplicationRunner {
|
||||
|
||||
private final ConfigurableApplicationContext context;
|
||||
private final Environment environment;
|
||||
|
||||
@Autowired
|
||||
private DataApiServiceFeign dataApiServiceFeign;
|
||||
|
||||
@Autowired
|
||||
private MappingHandlerMapping mappingHandlerMapping;
|
||||
|
||||
@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);
|
||||
|
||||
// 项目启动时,初始化已发布的接口
|
||||
List<DataApiEntity> releaseDataApiList = dataApiServiceFeign.getReleaseDataApiList();
|
||||
if (CollUtil.isNotEmpty(releaseDataApiList)) {
|
||||
releaseDataApiList.forEach(api -> mappingHandlerMapping.registerMapping(api));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package cn.datax.service.data.market.mapping.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.market.mapping.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.market.mapping.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,136 @@
|
||||
package cn.datax.service.data.market.mapping.controller;
|
||||
|
||||
import cn.datax.common.core.JsonPage;
|
||||
import cn.datax.common.core.R;
|
||||
import cn.datax.common.validate.ValidationGroups;
|
||||
import cn.datax.service.data.market.api.dto.ApiLogDto;
|
||||
import cn.datax.service.data.market.api.entity.ApiLogEntity;
|
||||
import cn.datax.service.data.market.api.query.ApiLogQuery;
|
||||
import cn.datax.service.data.market.api.vo.ApiLogVo;
|
||||
import cn.datax.service.data.market.mapping.mapstruct.ApiLogMapper;
|
||||
import cn.datax.service.data.market.mapping.service.ApiLogService;
|
||||
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>
|
||||
* api调用日志信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author AllDataDC
|
||||
* @date 2022-11-21
|
||||
*/
|
||||
@Api(tags = {"api调用日志信息表"})
|
||||
@RestController
|
||||
@RequestMapping("/apiLogs")
|
||||
public class ApiLogController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ApiLogService apiLogService;
|
||||
|
||||
@Autowired
|
||||
private ApiLogMapper apiLogMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public R getApiLogById(@PathVariable String id) {
|
||||
ApiLogEntity apiLogEntity = apiLogService.getApiLogById(id);
|
||||
return R.ok().setData(apiLogMapper.toVO(apiLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询信息
|
||||
*
|
||||
* @param apiLogQuery
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询", notes = "")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "apiLogQuery", value = "查询实体apiLogQuery", required = true, dataTypeClass = ApiLogQuery.class)
|
||||
})
|
||||
@GetMapping("/page")
|
||||
public R getApiLogPage(ApiLogQuery apiLogQuery) {
|
||||
QueryWrapper<ApiLogEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(apiLogQuery.getApiName()), "api.api_name", apiLogQuery.getApiName());
|
||||
IPage<ApiLogEntity> page = apiLogService.page(new Page<>(apiLogQuery.getPageNum(), apiLogQuery.getPageSize()), queryWrapper.orderByDesc("id"));
|
||||
List<ApiLogVo> collect = page.getRecords().stream().map(apiLogMapper::toVO).collect(Collectors.toList());
|
||||
JsonPage<ApiLogVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
|
||||
return R.ok().setData(jsonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param apiLog
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加信息", notes = "根据apiLog对象添加信息")
|
||||
@ApiImplicitParam(name = "apiLog", value = "详细实体apiLog", required = true, dataType = "ApiLogDto")
|
||||
@PostMapping()
|
||||
public R saveApiLog(@RequestBody @Validated({ValidationGroups.Insert.class}) ApiLogDto apiLog) {
|
||||
ApiLogEntity apiLogEntity = apiLogService.saveApiLog(apiLog);
|
||||
return R.ok().setData(apiLogMapper.toVO(apiLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param apiLog
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改信息", notes = "根据url的id来指定修改对象,并根据传过来的信息来修改详细信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "apiLog", value = "详细实体apiLog", required = true, dataType = "ApiLogDto")
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public R updateApiLog(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ApiLogDto apiLog) {
|
||||
ApiLogEntity apiLogEntity = apiLogService.updateApiLog(apiLog);
|
||||
return R.ok().setData(apiLogMapper.toVO(apiLogEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
|
||||
@DeleteMapping("/{id}")
|
||||
public R deleteApiLogById(@PathVariable String id) {
|
||||
apiLogService.deleteApiLogById(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 deleteApiLogBatch(@PathVariable List<String> ids) {
|
||||
apiLogService.deleteApiLogBatch(ids);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.datax.service.data.market.mapping.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,21 @@
|
||||
package cn.datax.service.data.market.mapping.dao;
|
||||
|
||||
import cn.datax.common.base.BaseDao;
|
||||
import cn.datax.service.data.market.api.entity.ApiLogEntity;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Mapper
|
||||
public interface ApiLogDao extends BaseDao<ApiLogEntity> {
|
||||
|
||||
@Override
|
||||
ApiLogEntity selectById(Serializable id);
|
||||
|
||||
@Override
|
||||
<E extends IPage<ApiLogEntity>> E selectPage(E page, @Param(Constants.WRAPPER) Wrapper<ApiLogEntity> queryWrapper);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.datax.service.data.market.mapping.factory;
|
||||
|
||||
import cn.datax.service.data.market.mapping.factory.crypto.Crypto;
|
||||
|
||||
public abstract class AbstractFactory {
|
||||
|
||||
public abstract Crypto getCrypto(String type);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.datax.service.data.market.mapping.factory;
|
||||
|
||||
import cn.datax.service.data.market.api.enums.AlgorithmCrypto;
|
||||
import cn.datax.service.data.market.mapping.factory.crypto.AlgorithmRegistry;
|
||||
import cn.datax.service.data.market.mapping.factory.crypto.Crypto;
|
||||
|
||||
public class AlgorithmFactory extends AbstractFactory {
|
||||
|
||||
private static final AlgorithmRegistry ALGORITHM_REGISTRY = new AlgorithmRegistry();
|
||||
|
||||
@Override
|
||||
public Crypto getCrypto(String type) {
|
||||
AlgorithmCrypto crypto = AlgorithmCrypto.getAlgorithmCrypto(type);
|
||||
return ALGORITHM_REGISTRY.getAlgorithm(crypto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.datax.service.data.market.mapping.factory;
|
||||
|
||||
import cn.datax.service.data.market.api.enums.CipherType;
|
||||
|
||||
public class FactoryProducer {
|
||||
|
||||
public static AbstractFactory getFactory(String type){
|
||||
CipherType cipherType = CipherType.getCipherType(type);
|
||||
switch (cipherType) {
|
||||
case REGEX:
|
||||
return new RegexFactory();
|
||||
case ALGORITHM:
|
||||
return new AlgorithmFactory();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.datax.service.data.market.mapping.factory;
|
||||
|
||||
import cn.datax.service.data.market.api.enums.RegexCrypto;
|
||||
import cn.datax.service.data.market.mapping.factory.crypto.Crypto;
|
||||
import cn.datax.service.data.market.mapping.factory.crypto.RegexRegistry;
|
||||
|
||||
public class RegexFactory extends AbstractFactory {
|
||||
|
||||
private static final RegexRegistry REGEX_REGISTRY = new RegexRegistry();
|
||||
|
||||
@Override
|
||||
public Crypto getCrypto(String type) {
|
||||
RegexCrypto crypto = RegexCrypto.getRegexCrypto(type);
|
||||
return REGEX_REGISTRY.getRegex(crypto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.datax.service.data.market.mapping.factory.crypto;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* [地址] 只显示前六位,不显示详细地址;我们要对个人信息增强保护<例子:北京市海淀区****>
|
||||
*/
|
||||
public class ADDRESSCrypto implements Crypto {
|
||||
|
||||
@Override
|
||||
public String encrypt(String content) {
|
||||
if (StringUtils.isBlank(content)) {
|
||||
return null;
|
||||
}
|
||||
return StringUtils.rightPad(StringUtils.left(content, 6), StringUtils.length(content), "*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decrypt(String content) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cn.datax.service.data.market.mapping.factory.crypto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Base64;
|
||||
|
||||
public class AESCrypto implements Crypto {
|
||||
|
||||
@Override
|
||||
public String encrypt(String content) {
|
||||
if (StrUtil.isBlank(content)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
//1.构造密钥生成器,指定为AES算法,不区分大小写
|
||||
KeyGenerator kGen = KeyGenerator.getInstance("AES");
|
||||
//2.根据 RULES 规则初始化密钥生成器,根据传入的字节数组生成一个128位的随机源
|
||||
kGen.init(128, new SecureRandom(SLAT.getBytes(CHARSET_UTF8)));
|
||||
//3.产生原始对称密钥
|
||||
SecretKey secretKey = kGen.generateKey();
|
||||
//4.获得原始对称密钥的字节数组
|
||||
byte[] enCodeFormat = secretKey.getEncoded();
|
||||
//5.根据字节数组生成AES密钥
|
||||
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
|
||||
//6.根据指定算法AES生成密码器
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
//7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作,第二个参数为使用的KEY
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
//8.根据密码器的初始化方式--加密:将数据加密
|
||||
byte[] AES_encrypt = cipher.doFinal(content.getBytes(CHARSET_UTF8));
|
||||
//9.将字符串返回
|
||||
return Base64.getEncoder().encodeToString(AES_encrypt);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decrypt(String content) {
|
||||
if (StringUtils.isBlank(content)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
//1.构造密钥生成器,指定为AES算法,不区分大小写
|
||||
KeyGenerator kGen = KeyGenerator.getInstance("AES");
|
||||
//2.根据 RULES 规则初始化密钥生成器,根据传入的字节数组生成一个128位的随机源
|
||||
kGen.init(128, new SecureRandom(SLAT.getBytes(CHARSET_UTF8)));
|
||||
//3.产生原始对称密钥
|
||||
SecretKey secretKey = kGen.generateKey();
|
||||
//4.获得原始对称密钥的字节数组
|
||||
byte[] enCodeFormat = secretKey.getEncoded();
|
||||
//5.根据字节数组生成AES密钥
|
||||
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
|
||||
//6.根据指定算法AES生成密码器
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
//7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作,第二个参数为使用的KEY
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);// 初始化
|
||||
//8.根据密码器的初始化方式--加密:将数据加密
|
||||
byte[] AES_decode = cipher.doFinal(Base64.getDecoder().decode(content));
|
||||
return new String(AES_decode, CHARSET_UTF8);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user