init
This commit is contained in:
@@ -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
|
||||
# 自定义日志打印
|
||||
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||
#日志输出到控制台
|
||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||
# 使用日志系统记录 sql
|
||||
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||
# 设置 p6spy driver 代理
|
||||
deregisterdrivers=true
|
||||
# 取消JDBC URL前缀
|
||||
useprefix=true
|
||||
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||
excludecategories=info,debug,result,batch,resultset
|
||||
# 日期格式
|
||||
dateformat=yyyy-MM-dd HH:mm:ss
|
||||
# 实际驱动可多个
|
||||
#driverlist=org.h2.Driver
|
||||
# 是否开启慢SQL记录
|
||||
outagedetection=true
|
||||
# 慢SQL记录标准 2 秒
|
||||
outagedetectioninterval=2
|
||||
# 开启过滤
|
||||
filter=true
|
||||
# 配置不打印的内容
|
||||
exclude=select 1
|
||||
Reference in New Issue
Block a user