diff --git a/blade-service-api/logpm-patch-api/pom.xml b/blade-service-api/logpm-patch-api/pom.xml new file mode 100644 index 000000000..d76871da5 --- /dev/null +++ b/blade-service-api/logpm-patch-api/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + + org.springblade + blade-service-api + 3.1.0.RELEASE + + + org.springblade + logpm-patch-api + 3.1.0.RELEASE + jar + + + diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml index 6d66f56c4..961e147c9 100644 --- a/blade-service-api/pom.xml +++ b/blade-service-api/pom.xml @@ -33,6 +33,8 @@ logpm-statisticsdata-api logpm-old-project-api + + logpm-patch-api diff --git a/blade-service/logpm-patch/pom.xml b/blade-service/logpm-patch/pom.xml new file mode 100644 index 000000000..3390deeca --- /dev/null +++ b/blade-service/logpm-patch/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + + org.springblade + blade-service + 3.1.0.RELEASE + + + logpm-patch + ${bladex.project.version} + ${project.artifactId} + jar + + + + org.springblade + blade-core-boot + + + org.springblade + blade-starter-swagger + + + org.springblade + blade-core-auto + compile + + + org.springblade + logpm-patch-api + ${bladex.project.version} + + + + com.xuxueli + xxl-job-core + + + + + diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/PatchApplication.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/PatchApplication.java new file mode 100644 index 000000000..a04f93e8f --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/PatchApplication.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.patch; + +import org.springblade.common.constant.ModuleNameConstant; +import org.springblade.core.cloud.client.BladeCloudApplication; +import org.springblade.core.launch.BladeApplication; + +/** + * Demo启动器 + * + * @author Chill + */ +@BladeCloudApplication +public class PatchApplication { + + public static void main(String[] args) { + BladeApplication.run(ModuleNameConstant.APPLICATION_PATCH_NAME, PatchApplication.class, args); + } + +} + diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/config/PatchConfiguration.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/config/PatchConfiguration.java new file mode 100644 index 000000000..700cabffc --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/config/PatchConfiguration.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.patch.config; + + +import com.logpm.patch.props.PatchProperties; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * 配置feign、mybatis包名、properties + * + * @author Chill + */ +@Configuration(proxyBeanMethods = false) +@ComponentScan({"org.springblade", "com.logpm"}) +@EnableFeignClients({"org.springblade", "com.logpm"}) +@MapperScan({"org.springblade.**.mapper.**", "com.logpm.**.mapper.**"}) +@EnableConfigurationProperties(PatchProperties.class) +public class PatchConfiguration { + +} diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/config/XxlJobConfig.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/config/XxlJobConfig.java new file mode 100644 index 000000000..3271af5f7 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/config/XxlJobConfig.java @@ -0,0 +1,74 @@ +package com.logpm.patch.config; + +import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * xxl-job config + * + * @author xuxueli 2017-04-28 + */ +@Configuration(proxyBeanMethods = false) +public class XxlJobConfig { + private final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); + + @Value("${xxl.job.admin.addresses}") + private String adminAddresses; + + @Value("${xxl.job.executor.appname}") + private String appName; + + @Value("${xxl.job.executor.ip}") + private String ip; + + @Value("${xxl.job.executor.port}") + private int port; + + @Value("${xxl.job.accessToken}") + private String accessToken; + + @Value("${xxl.job.executor.logpath}") + private String logPath; + + @Value("${xxl.job.executor.logretentiondays}") + private int logRetentionDays; + + + @Bean + public XxlJobSpringExecutor xxlJobExecutor() { + logger.info(">>>>>>>>>>> xxl-job config init."); + XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); + xxlJobSpringExecutor.setAdminAddresses(adminAddresses); + xxlJobSpringExecutor.setAppName(appName); + xxlJobSpringExecutor.setIp(ip); + xxlJobSpringExecutor.setPort(port); + xxlJobSpringExecutor.setAccessToken(accessToken); + xxlJobSpringExecutor.setLogPath(logPath); + xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); + + return xxlJobSpringExecutor; + } + + /** + * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP; + * + * 1、引入依赖: + * + * org.springframework.cloud + * spring-cloud-commons + * ${version} + * + * + * 2、配置文件,或者容器启动变量 + * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.' + * + * 3、获取IP + * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + */ + + +} diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/props/PatchProperties.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/props/PatchProperties.java new file mode 100644 index 000000000..8953039d0 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/props/PatchProperties.java @@ -0,0 +1,21 @@ +package com.logpm.patch.props; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * FactoryProperties + * + * @author pref + */ +@Data +@ConfigurationProperties(prefix = "logpm") +public class PatchProperties { + /** + * 名称 + */ + private String name; + + + +} diff --git a/blade-service/logpm-patch/src/main/resources/application-dev.yml b/blade-service/logpm-patch/src/main/resources/application-dev.yml new file mode 100644 index 000000000..d9767d46a --- /dev/null +++ b/blade-service/logpm-patch/src/main/resources/application-dev.yml @@ -0,0 +1,44 @@ +#服务器端口 +server: + port: 19000 + +#数据源配置 +#spring: +# datasource: +# url: ${blade.datasource.dev.url} +# username: ${blade.datasource.dev.username} +# password: ${blade.datasource.dev.password} + +spring: + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + druid: + #通用校验配置 + validation-query: select 1 + #启用sql日志拦截器 + proxy-filters: + - sqlLogInterceptor + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.patch.master.url} + username: ${blade.datasource.patch.master.username} + password: ${blade.datasource.patch.master.password} + slave: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.patch.slave.url} + username: ${blade.datasource.patch.slave.username} + password: ${blade.datasource.patch.slave.password} diff --git a/blade-service/logpm-patch/src/main/resources/application-prod.yml b/blade-service/logpm-patch/src/main/resources/application-prod.yml new file mode 100644 index 000000000..a1cd4138d --- /dev/null +++ b/blade-service/logpm-patch/src/main/resources/application-prod.yml @@ -0,0 +1,31 @@ +#服务器端口 +server: + port: 19000 + +#数据源配置 +#spring: +# datasource: +# url: ${blade.datasource.prod.url} +# username: ${blade.datasource.prod.username} +# password: ${blade.datasource.prod.password} + +spring: + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + druid: + proxy-filters: + - sqlLogInterceptor + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + url: ${blade.datasource.patch.master.url} + username: ${blade.datasource.patch.master.username} + password: ${blade.datasource.patch.master.password} + slave: + url: ${blade.datasource.patch.slave.url} + username: ${blade.datasource.patch.slave.username} + password: ${blade.datasource.patch.slave.password} diff --git a/blade-service/logpm-patch/src/main/resources/application-test.yml b/blade-service/logpm-patch/src/main/resources/application-test.yml new file mode 100644 index 000000000..dff9455f7 --- /dev/null +++ b/blade-service/logpm-patch/src/main/resources/application-test.yml @@ -0,0 +1,31 @@ +#服务器端口 +server: + port: 19000 + +#数据源配置 +#spring: +# datasource: +# url: ${blade.datasource.test.url} +# username: ${blade.datasource.test.username} +# password: ${blade.datasource.test.password} + +spring: + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + druid: + proxy-filters: + - sqlLogInterceptor + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + url: ${blade.datasource.patch.master.url} + username: ${blade.datasource.patch.master.username} + password: ${blade.datasource.patch.master.password} + slave: + url: ${blade.datasource.patch.slave.url} + username: ${blade.datasource.patch.slave.username} + password: ${blade.datasource.patch.slave.password} diff --git a/blade-service/logpm-patch/src/main/resources/application.yml b/blade-service/logpm-patch/src/main/resources/application.yml new file mode 100644 index 000000000..ddad5233f --- /dev/null +++ b/blade-service/logpm-patch/src/main/resources/application.yml @@ -0,0 +1,41 @@ +#mybatis-plus配置 +mybatis-plus: + mapper-locations: classpath:com/logpm/**/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.logpm.**.entity + +#swagger扫描路径配置 +swagger: + base-packages: + - org.springblade + - com.logpm + +#blade配置 +blade: + #本地文件上传 + file: + remote-mode: true + upload-domain: http://localhost:8999 + remote-path: /usr/share/nginx/html + +logging: + config: classpath:logback.xml + + +spring: + main: + allow-circular-references: true + + +xxl: + job: + accessToken: '' + admin: + addresses: http://127.0.0.1:7009/xxl-job-admin + executor: + appname: logpm-patch-xxljob + ip: 127.0.0.1 + logpath: ../data/applogs/logpm-patch-xxljob/jobhandler + logretentiondays: -1 + port: 7118 + diff --git a/blade-service/logpm-patch/src/main/resources/logback.xml b/blade-service/logpm-patch/src/main/resources/logback.xml new file mode 100644 index 000000000..056bad7fb --- /dev/null +++ b/blade-service/logpm-patch/src/main/resources/logback.xml @@ -0,0 +1,40 @@ + + + + logback + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + ${log.path} + + ${log.path}.%d{yyyy-MM-dd}.zip + + + %date %level [%thread] %logger{36} [%file : %line] %msg%n + + + + + + + + + + diff --git a/blade-service/pom.xml b/blade-service/pom.xml index a0809ee5e..3284d07d7 100644 --- a/blade-service/pom.xml +++ b/blade-service/pom.xml @@ -38,6 +38,9 @@ logpm-statisticsdata logpm-old-project + + logpm-patch +