优化代码
This commit is contained in:
parent
b01775a245
commit
730b587eda
3
pom.xml
3
pom.xml
@ -12,9 +12,6 @@
|
||||
<groupId>cn.zyjblogs</groupId>
|
||||
<artifactId>zyjblogs-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>server/zyjblogs-sms</module>
|
||||
</modules>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<developers>
|
||||
|
@ -30,6 +30,10 @@
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-mybatisplus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-redis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-oauth-spring-boot-starter</artifactId>
|
||||
@ -38,6 +42,14 @@
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-sms</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>zyjblogs-web-spring-boot-starter</artifactId>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
|
@ -0,0 +1,23 @@
|
||||
package cn.zyjblogs;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* Copyright (C), 2021, 北京同创永益科技发展有限公司
|
||||
*
|
||||
* @author zhuyijun
|
||||
* @version 3.0.0
|
||||
* @description
|
||||
* @date 2022/8/17 15:53
|
||||
*/
|
||||
@EnableAsync
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
public class SmsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SmsApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.zyjblogs.sms.task.controller;
|
||||
|
||||
import cn.zyjblogs.sms.task.dto.SmsTaskDTO;
|
||||
import cn.zyjblogs.sms.task.service.SmsTaskService;
|
||||
import cn.zyjblogs.sms.task.vo.SmsTaskVO;
|
||||
import cn.zyjblogs.starter.common.entity.response.ResponseObject;
|
||||
import cn.zyjblogs.starter.common.entity.response.ResponseResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sms")
|
||||
@RequiredArgsConstructor
|
||||
public class SmsTaskController {
|
||||
private final SmsTaskService smsTaskService;
|
||||
|
||||
@PostMapping("/sendSmsTask")
|
||||
public ResponseObject<SmsTaskVO> sendSmsTask(@RequestBody SmsTaskDTO smsTaskDTO){
|
||||
return ResponseResult.success(smsTaskService.sendSmsTask(smsTaskDTO));
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import cn.zyjblogs.sms.task.constant.TaskStatus;
|
||||
import cn.zyjblogs.starter.common.entity.dto.Kv;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -18,6 +19,7 @@ import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class SmsTaskDTO {
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
|
@ -36,7 +36,7 @@ import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@TableName("e_sms_send_status")
|
||||
@TableName("sms_send_status")
|
||||
@ApiModel(value = "SmsSendStatus", description = "短信发送状态")
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
|
@ -31,7 +31,7 @@ import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("e_sms_template")
|
||||
@TableName("sms_template")
|
||||
@ApiModel(value = "SmsTemplate", description = "短信模板")
|
||||
@AllArgsConstructor
|
||||
public class SmsTemplatePO {
|
||||
|
@ -59,8 +59,8 @@ public class SmsTaskServiceImpl extends ServiceImpl<SmsTaskMapper,SmsTaskPO> imp
|
||||
if (data.getSourceType() == null) {
|
||||
data.setSourceType(SourceType.OTHER);
|
||||
}
|
||||
SmsTemplatePO template = smsTemplateService.getById(data.getId());
|
||||
Asserts.isNull(template,"查询不到该模板,请选择正确的短信模板");
|
||||
SmsTemplatePO template = smsTemplateService.getById(data.getTemplateId());
|
||||
Asserts.notNull(template,"查询不到该模板,请选择正确的短信模板");
|
||||
|
||||
//1,验证必要参数
|
||||
Asserts.notEmpty(data.getTelNum(), "请填写短信接收人");
|
||||
@ -119,6 +119,7 @@ public class SmsTaskServiceImpl extends ServiceImpl<SmsTaskMapper,SmsTaskPO> imp
|
||||
smsSendStatusService.saveBatch(sendStatusList);
|
||||
}
|
||||
updateStatus(smsTask.getId(),TaskStatus.SUCCESS);
|
||||
smsTask.setStatus(TaskStatus.SUCCESS);
|
||||
return BeanUtils.map(smsTask,SmsTaskVO.class);
|
||||
}
|
||||
|
||||
@ -162,12 +163,21 @@ public class SmsTaskServiceImpl extends ServiceImpl<SmsTaskMapper,SmsTaskPO> imp
|
||||
return sb.toString();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
List<Kv<String,String>> list = new ArrayList<>();
|
||||
list.add(Kv.<String,String>builder().k("var").v("atg").build());
|
||||
list.add(Kv.<String,String>builder().k("var").v("1234").build());
|
||||
list.add(Kv.<String,String>builder().k("var").v("01").build());
|
||||
list.add(Kv.<String,String>builder().k("var").v("5").build());
|
||||
list.add(Kv.<String,String>builder().k("k").v("$5").build());
|
||||
System.out.println(JSON.toJSONString(SmsTaskDTO.builder()
|
||||
.id("xx010")
|
||||
.draft(false)
|
||||
.sourceType(SourceType.SERVICE)
|
||||
.templateId("1")
|
||||
.topic("登录验证")
|
||||
.templateParams(List.of(Kv.<String, String>builder().k("code").v("999999").build()))
|
||||
.telNum(List.of("13476152541"))
|
||||
.build()));
|
||||
List<Kv<String,String>> list = new ArrayList<>();
|
||||
list.add(Kv.<String,String>builder().k("var").v("atg").build());
|
||||
list.add(Kv.<String,String>builder().k("var").v("1234").build());
|
||||
list.add(Kv.<String,String>builder().k("var").v("01").build());
|
||||
list.add(Kv.<String,String>builder().k("var").v("5").build());
|
||||
list.add(Kv.<String,String>builder().k("k").v("$5").build());
|
||||
System.out.println(processTemplate("${var}您好!验证码是:${var}(序号${var}),有效时间为${var}分钟。尝试次数: ${k}", ProviderType.ALI.getRegex(), list));
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import cn.zyjblogs.sms.task.mapper.SmsTemplateMapper;
|
||||
import cn.zyjblogs.sms.task.po.SmsTemplatePO;
|
||||
import cn.zyjblogs.sms.task.service.SmsTemplateService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@Service
|
||||
public class SmsTemplateServiceImpl extends ServiceImpl<SmsTemplateMapper, SmsTemplatePO> implements SmsTemplateService {
|
||||
}
|
||||
|
9
server/zyjblogs-sms/src/main/resources/banner.txt
Normal file
9
server/zyjblogs-sms/src/main/resources/banner.txt
Normal file
@ -0,0 +1,9 @@
|
||||
________ ___ ___ ___ ________ ___ ________ ________ ________
|
||||
|\_____ \ |\ \ / /||\ \|\ __ \|\ \ |\ __ \|\ ____\|\ ____\
|
||||
\|___/ /| \ \ \/ / /\ \ \ \ \|\ /\ \ \ \ \ \|\ \ \ \___|\ \ \___|_
|
||||
/ / / \ \ / /_ \ \ \ \ __ \ \ \ \ \ \\\ \ \ \ __\ \_____ \
|
||||
/ /_/__ \/ / /\ \\_\ \ \ \|\ \ \ \____\ \ \\\ \ \ \|\ \|____|\ \
|
||||
|\________\__/ / / \ \________\ \_______\ \_______\ \_______\ \_______\____\_\ \
|
||||
\|_______|\___/ / \|________|\|_______|\|_______|\|_______|\|_______|\_________\
|
||||
\|___|/ \|_________|
|
||||
Release 1.0.0. Powered by zyjblogs-framework 1.0.0.
|
@ -0,0 +1,8 @@
|
||||
zyjblogs:
|
||||
config:
|
||||
nacos:
|
||||
host: ${ZYJBLOGS_CONFIG_NACOS_HOST:127.0.0.1}
|
||||
port: ${ZYJBLOGS_CONFIG_NACOS_PORT:8848}
|
||||
username: ${ZYJBLOGS_CONFIG_NACOS_USERNAME:nacos}
|
||||
password: ${ZYJBLOGS_CONFIG_NACOS_PASSWORD:nacos}
|
||||
|
111
server/zyjblogs-sms/src/main/resources/bootstrap.yml
Normal file
111
server/zyjblogs-sms/src/main/resources/bootstrap.yml
Normal file
@ -0,0 +1,111 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: test
|
||||
|
||||
---
|
||||
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
name: zyjblogs-sms
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password:
|
||||
timeout: 10000 #连接超时时间(毫秒)
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 # 连接池最大连接数
|
||||
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
max-idle: 8 # 连接池中的最大空闲连接
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: ${zyjblogs.config.nacos.host}:${zyjblogs.config.nacos.port}
|
||||
username: ${zyjblogs.config.nacos.username}
|
||||
password: ${zyjblogs.config.nacos.password}
|
||||
namespace: ${spring.profiles.active}
|
||||
group: public
|
||||
file-extension: yml
|
||||
shared-configs[0]:
|
||||
data-id: zyjblogs-global-${spring.profiles.active}.yml
|
||||
group: global
|
||||
refresh: true
|
||||
discovery:
|
||||
server-addr: ${spring.cloud.nacos.config.server-addr}
|
||||
username: ${spring.cloud.nacos.config.username}
|
||||
password: ${spring.cloud.nacos.config.password}
|
||||
namespace: ${spring.cloud.nacos.config.namespace}
|
||||
group: public
|
||||
sharding-sphere:
|
||||
datasource:
|
||||
names: write-ds,read-ds-0
|
||||
write-ds:
|
||||
jdbc-url: jdbc:mysql://127.0.0.1:3306/zyjblogs_sms?allowPublicKeyRetrieval=true&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
connectionTimeoutMilliseconds: 3000
|
||||
idleTimeoutMilliseconds: 60000
|
||||
maxLifetimeMilliseconds: 1800000
|
||||
maxPoolSize: 50
|
||||
minPoolSize: 1
|
||||
maintenanceIntervalMilliseconds: 30000\
|
||||
hikari:
|
||||
minimum-idle: 10
|
||||
maximum-pool-size: 100
|
||||
auto-commit: true
|
||||
idle-timeout: 1800000
|
||||
pool-name: DatebookHikariCP
|
||||
max-lifetime: 1800000
|
||||
connection-timeout: 60000
|
||||
connection-test-query: SELECT 1
|
||||
read-ds-0:
|
||||
jdbc-url: jdbc:mysql://127.0.0.1:3306/zyjblogs_sms?allowPublicKeyRetrieval=true&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: read
|
||||
password: 123456
|
||||
connectionTimeoutMilliseconds: 3000
|
||||
idleTimeoutMilliseconds: 60000
|
||||
maxLifetimeMilliseconds: 1800000
|
||||
maxPoolSize: 50
|
||||
minPoolSize: 1
|
||||
maintenanceIntervalMilliseconds: 30000
|
||||
hikari:
|
||||
minimum-idle: 10
|
||||
maximum-pool-size: 100
|
||||
auto-commit: true
|
||||
idle-timeout: 1800000
|
||||
pool-name: DatebookHikariCP
|
||||
max-lifetime: 1800000
|
||||
connection-timeout: 60000
|
||||
connection-test-query: SELECT 1
|
||||
sharding:
|
||||
master-slave-rules:
|
||||
master0:
|
||||
master-data-source-name: write-ds
|
||||
slave-data-source-names: read-ds-0
|
||||
props:
|
||||
sql:
|
||||
show: true
|
||||
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
client-id: ${spring.application.name}
|
||||
client-secret: secret
|
||||
scope: user
|
||||
resource:
|
||||
id: ${spring.application.name}
|
||||
rsa:
|
||||
key:
|
||||
enable: true
|
||||
pubKey-path: public.txt
|
||||
priKey-path: private.txt
|
198
server/zyjblogs-sms/src/main/resources/logback-spring.xml
Normal file
198
server/zyjblogs-sms/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,198 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<!-- 获取application.yml配置文件中的属性 -->
|
||||
<springProperty scope="context" name="SPRING_APPLICATION_NAME" source="spring.application.name"/>
|
||||
<springProperty scope="context" name="SPRING_PROFILES_ACTIVE" source="spring.profiles.active"/>
|
||||
|
||||
<!-- 配置文件存放路径 -->
|
||||
<property name="logger.path" value="./log/${SPRING_APPLICATION_NAME}/${SPRING_PROFILES_ACTIVE}" />
|
||||
|
||||
<!-- 彩色日志 -->
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr([%X{traceId}]) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
|
||||
<!-- 输出到控制台 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>info</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 输出到文件 -->
|
||||
<!-- 时间滚动输出 level为 DEBUG 日志 -->
|
||||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${logger.path}/log_debug.log</file>
|
||||
<!--日志文件输出格式-->
|
||||
<encoder>
|
||||
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 日志归档 -->
|
||||
<fileNamePattern>${logger.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<!-- 日志采集保留天数 -->
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
|
||||
<!-- 此日志文件只记录debug级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>debug</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 时间滚动输出 level为 INFO 日志 -->
|
||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${logger.path}/log_info.log</file>
|
||||
<!--日志文件输出格式-->
|
||||
<encoder>
|
||||
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${logger.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<!-- 日志采集保留天数 -->
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文件只记录info级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>info</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 时间滚动输出 level为 WARN 日志 -->
|
||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${logger.path}/log_warn.log</file>
|
||||
<!--日志文件输出格式-->
|
||||
<encoder>
|
||||
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${logger.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<!-- 日志采集保留天数 -->
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文件只记录warn级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>warn</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 时间滚动输出 level为 ERROR 日志 -->
|
||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${logger.path}/log_error.log</file>
|
||||
<!--日志文件输出格式-->
|
||||
<encoder>
|
||||
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${logger.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<!-- 日志采集保留天数 -->
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文件只记录ERROR级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--
|
||||
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
|
||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
||||
不能设置为INHERITED或者同义词NULL。默认是DEBUG
|
||||
可以包含零个或多个元素,标识这个appender将会添加到这个logger。
|
||||
-->
|
||||
<!-- 开发环境配置 -->
|
||||
<springProfile name="dev">
|
||||
<root level="debug">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="DEBUG_FILE" />
|
||||
<appender-ref ref="INFO_FILE" />
|
||||
<appender-ref ref="WARN_FILE" />
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<!-- 测试环境配置 -->
|
||||
<springProfile name="test">
|
||||
<root level="debug">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="DEBUG_FILE" />
|
||||
<appender-ref ref="INFO_FILE" />
|
||||
<appender-ref ref="WARN_FILE" />
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<!-- 上线环境配置 -->
|
||||
<springProfile name="prod">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="DEBUG_FILE" />
|
||||
<appender-ref ref="INFO_FILE" />
|
||||
<appender-ref ref="WARN_FILE" />
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<!-- 高可用环境配置-->
|
||||
<springProfile name="ha">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="DEBUG_FILE" />
|
||||
<appender-ref ref="INFO_FILE" />
|
||||
<appender-ref ref="WARN_FILE" />
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<!-- k8s环境配置-->
|
||||
<springProfile name="k8s">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="DEBUG_FILE" />
|
||||
<appender-ref ref="INFO_FILE" />
|
||||
<appender-ref ref="WARN_FILE" />
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
@ -19,7 +19,7 @@ public class RsaKeyProperties {
|
||||
/**
|
||||
* 启用rsa对token进行加密
|
||||
*/
|
||||
private Boolean enable;
|
||||
private Boolean enable = true;
|
||||
|
||||
/**
|
||||
* 公钥地址
|
||||
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -16,5 +17,5 @@ import java.util.List;
|
||||
@ConfigurationProperties(prefix = "zyjblogs.whilelist")
|
||||
public class WhiteListProperties {
|
||||
|
||||
private List<String> allowPaths;
|
||||
private List<String> allowPaths = new LinkedList<>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user