diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml
index aace5ad0c9..74d7e7129b 100644
--- a/yudao-dependencies/pom.xml
+++ b/yudao-dependencies/pom.xml
@@ -31,11 +31,11 @@
1.5.4
4.3.1
3.0.6
- 3.50.0
+ 3.51.0
8.1.3.140
8.6.0
5.1.0
- 3.3.3
+ 3.7.3
2.3.4
@@ -52,11 +52,11 @@
6.8.0
1.4.0
- 1.21.1
+ 1.21.2
1.18.38
1.6.3
- 5.8.39
- 1.2.0
+ 5.8.40
+ 1.3.0
2.4
1.2.83
33.4.8-jre
@@ -77,7 +77,7 @@
1.4.0
2.1.0
1.9.5
- 4.7.5.B
+ 4.7.7-20250808.182223
1.2.13
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/db/TenantDatabaseInterceptor.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/db/TenantDatabaseInterceptor.java
index 47e5df004c..11f0a4b4c3 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/db/TenantDatabaseInterceptor.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/db/TenantDatabaseInterceptor.java
@@ -75,7 +75,7 @@ public class TenantDatabaseInterceptor implements TenantLineHandler {
if (TenantBaseDO.class.isAssignableFrom(tableInfo.getEntityType())) {
return false;
}
- // 如果添加了 @TenantIgnore 注解,显然也不忽略租户
+ // 如果添加了 @TenantIgnore 注解,则忽略租户
TenantIgnore tenantIgnore = tableInfo.getEntityType().getAnnotation(TenantIgnore.class);
return tenantIgnore != null;
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rabbitmq/TenantRabbitMQInitializer.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rabbitmq/TenantRabbitMQInitializer.java
index b856ce9542..f18ec1acf6 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rabbitmq/TenantRabbitMQInitializer.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rabbitmq/TenantRabbitMQInitializer.java
@@ -13,11 +13,10 @@ public class TenantRabbitMQInitializer implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
- if (bean instanceof RabbitTemplate) {
- RabbitTemplate rabbitTemplate = (RabbitTemplate) bean;
+ if (bean instanceof RabbitTemplate rabbitTemplate) {
rabbitTemplate.addBeforePublishPostProcessors(new TenantRabbitMQMessagePostProcessor());
}
return bean;
}
-}
\ No newline at end of file
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rocketmq/TenantRocketMQInitializer.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rocketmq/TenantRocketMQInitializer.java
index 7f12ac5205..6c3247df14 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rocketmq/TenantRocketMQInitializer.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/rocketmq/TenantRocketMQInitializer.java
@@ -18,11 +18,9 @@ public class TenantRocketMQInitializer implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
- if (bean instanceof DefaultRocketMQListenerContainer) {
- DefaultRocketMQListenerContainer container = (DefaultRocketMQListenerContainer) bean;
+ if (bean instanceof DefaultRocketMQListenerContainer container) {
initTenantConsumer(container.getConsumer());
- } else if (bean instanceof RocketMQTemplate) {
- RocketMQTemplate template = (RocketMQTemplate) bean;
+ } else if (bean instanceof RocketMQTemplate template) {
initTenantProducer(template.getProducer());
}
return bean;
@@ -50,4 +48,4 @@ public class TenantRocketMQInitializer implements BeanPostProcessor {
consumerImpl.registerConsumeMessageHook(new TenantRocketMQConsumeMessageHook());
}
-}
\ No newline at end of file
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/config/YudaoAsyncAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/config/YudaoAsyncAutoConfiguration.java
index 4b08210971..5f8a4944d3 100644
--- a/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/config/YudaoAsyncAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/config/YudaoAsyncAutoConfiguration.java
@@ -23,15 +23,13 @@ public class YudaoAsyncAutoConfiguration {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// 处理 ThreadPoolTaskExecutor
- if (bean instanceof ThreadPoolTaskExecutor) {
- ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) bean;
+ if (bean instanceof ThreadPoolTaskExecutor executor) {
executor.setTaskDecorator(TtlRunnable::get);
return executor;
}
// 处理 SimpleAsyncTaskExecutor
// 参考 https://t.zsxq.com/CBoks 增加
- if (bean instanceof SimpleAsyncTaskExecutor) {
- SimpleAsyncTaskExecutor executor = (SimpleAsyncTaskExecutor) bean;
+ if (bean instanceof SimpleAsyncTaskExecutor executor) {
executor.setTaskDecorator(TtlRunnable::get);
return executor;
}
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
index ab2992184f..96872b6438 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.incrementer.*;
import com.baomidou.mybatisplus.extension.parser.JsqlParserGlobal;
import com.baomidou.mybatisplus.extension.parser.cache.JdkSerialCaffeineJsqlParseCache;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
@@ -42,6 +43,7 @@ public class YudaoMybatisAutoConfiguration {
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); // 分页插件
+ mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); // 拦截没有指定条件的 update 和 delete 语句
return mybatisPlusInterceptor;
}
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java
index 3c35999109..6596bb0eef 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java
@@ -19,8 +19,7 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
- if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO) {
- BaseDO baseDO = (BaseDO) metaObject.getOriginalObject();
+ if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO baseDO) {
LocalDateTime current = LocalDateTime.now();
// 创建时间为空,则以当前时间为插入时间
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java
index c62f0a0300..280f8da349 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java
@@ -1,10 +1,10 @@
package cn.iocoder.yudao.framework.jackson.config;
-import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.json.databind.NumberSerializer;
import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeDeserializer;
import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeSerializer;
+import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
@@ -13,39 +13,65 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.context.annotation.Bean;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
-import java.util.List;
-@AutoConfiguration
+@AutoConfiguration(after = JacksonAutoConfiguration.class)
@Slf4j
public class YudaoJacksonAutoConfiguration {
+ /**
+ * 从 Builder 源头定制(关键:使用 *ByType,避免 handledType 要求)
+ */
+ @Bean
+ public Jackson2ObjectMapperBuilderCustomizer ldtEpochMillisCustomizer() {
+ return builder -> builder
+ // Long -> Number
+ .serializerByType(Long.class, NumberSerializer.INSTANCE)
+ .serializerByType(Long.TYPE, NumberSerializer.INSTANCE)
+ // LocalDate / LocalTime
+ .serializerByType(LocalDate.class, LocalDateSerializer.INSTANCE)
+ .deserializerByType(LocalDate.class, LocalDateDeserializer.INSTANCE)
+ .serializerByType(LocalTime.class, LocalTimeSerializer.INSTANCE)
+ .deserializerByType(LocalTime.class, LocalTimeDeserializer.INSTANCE)
+ // LocalDateTime < - > EpochMillis
+ .serializerByType(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE)
+ .deserializerByType(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE);
+ }
+
+ /**
+ * 以 Bean 形式暴露 Module(Boot 会自动注册到所有 ObjectMapper)
+ */
+ @Bean
+ public Module timestampSupportModuleBean() {
+ SimpleModule m = new SimpleModule("TimestampSupportModule");
+ // Long -> Number,避免前端精度丢失
+ m.addSerializer(Long.class, NumberSerializer.INSTANCE);
+ m.addSerializer(Long.TYPE, NumberSerializer.INSTANCE);
+ // LocalDate / LocalTime
+ m.addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE);
+ m.addDeserializer(LocalDate.class, LocalDateDeserializer.INSTANCE);
+ m.addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE);
+ m.addDeserializer(LocalTime.class, LocalTimeDeserializer.INSTANCE);
+ // LocalDateTime < - > EpochMillis
+ m.addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE);
+ m.addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE);
+ return m;
+ }
+
+ /**
+ * 初始化全局 JsonUtils,直接使用主 ObjectMapper
+ */
@Bean
@SuppressWarnings("InstantiationOfUtilityClass")
- public JsonUtils jsonUtils(List objectMappers) {
- // 1.1 创建 SimpleModule 对象
- SimpleModule simpleModule = new SimpleModule();
- simpleModule
- // 新增 Long 类型序列化规则,数值超过 2^53-1,在 JS 会出现精度丢失问题,因此 Long 自动序列化为字符串类型
- .addSerializer(Long.class, NumberSerializer.INSTANCE)
- .addSerializer(Long.TYPE, NumberSerializer.INSTANCE)
- .addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE)
- .addDeserializer(LocalDate.class, LocalDateDeserializer.INSTANCE)
- .addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE)
- .addDeserializer(LocalTime.class, LocalTimeDeserializer.INSTANCE)
- // 新增 LocalDateTime 序列化、反序列化规则,使用 Long 时间戳
- .addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE)
- .addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE);
- // 1.2 注册到 objectMapper
- objectMappers.forEach(objectMapper -> objectMapper.registerModule(simpleModule));
-
- // 2. 设置 objectMapper 到 JsonUtils
- JsonUtils.init(CollUtil.getFirst(objectMappers));
- log.info("[init][初始化 JsonUtils 成功]");
+ public JsonUtils jsonUtils(ObjectMapper objectMapper) {
+ JsonUtils.init(objectMapper);
+ log.debug("[init][初始化 JsonUtils 成功]");
return new JsonUtils();
}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
index dc74078c8f..7b06403fc5 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
@@ -180,8 +180,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(HttpMessageNotReadableException.class)
public CommonResult> methodArgumentTypeInvalidFormatExceptionHandler(HttpMessageNotReadableException ex) {
log.warn("[methodArgumentTypeInvalidFormatExceptionHandler]", ex);
- if (ex.getCause() instanceof InvalidFormatException) {
- InvalidFormatException invalidFormatException = (InvalidFormatException) ex.getCause();
+ if (ex.getCause() instanceof InvalidFormatException invalidFormatException) {
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数类型错误:%s", invalidFormatException.getValue()));
}
if (StrUtil.startWith(ex.getMessage(), "Required request body is missing")) {
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java
index 1acc6b05a6..bdef76ba77 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java
@@ -147,10 +147,9 @@ public class WebFrameworkUtils {
public static HttpServletRequest getRequest() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
- if (!(requestAttributes instanceof ServletRequestAttributes)) {
+ if (!(requestAttributes instanceof ServletRequestAttributes servletRequestAttributes)) {
return null;
}
- ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
return servletRequestAttributes.getRequest();
}
diff --git a/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
index 80c2c79336..0e3296b543 100644
--- a/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
@@ -166,7 +166,7 @@ public class CouponServiceImpl implements CouponService {
public void invalidateCouponsByAdmin(List giveCouponIds, Long userId) {
// 循环收回
for (Long couponId : giveCouponIds) {
- // couponId为空或0则跳过
+ // couponId 为空或 0 则跳过
if (null == couponId || couponId <= 0) {
continue;
}
diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/PictureWordCaptchaServiceImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/PictureWordCaptchaServiceImpl.java
index ed15a0277b..e5f7741907 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/PictureWordCaptchaServiceImpl.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/PictureWordCaptchaServiceImpl.java
@@ -8,8 +8,8 @@ import com.anji.captcha.service.impl.CaptchaServiceFactory;
import com.anji.captcha.util.AESUtil;
import com.anji.captcha.util.ImageUtils;
import com.anji.captcha.util.RandomUtils;
-import org.apache.commons.lang3.StringUtils;
import cn.hutool.core.util.RandomUtil;
+import org.apache.commons.lang3.Strings;
import java.awt.*;
import java.awt.geom.AffineTransform;
@@ -82,7 +82,7 @@ public class PictureWordCaptchaServiceImpl extends AbstractCaptchaService {
// 用户输入的验证码(CaptchaVO 中 没有预留字段,暂时用 pointJson 无需加解密)
String userCode = captchaVO.getPointJson();
- if (!StringUtils.equalsIgnoreCase(code, userCode)) {
+ if (!Strings.CI.equals(code, userCode)) {
afterValidateFail(captchaVO);
return ResponseModel.errorMsg(RepCodeEnum.API_CAPTCHA_COORDINATE_ERROR);
}
@@ -209,4 +209,4 @@ public class PictureWordCaptchaServiceImpl extends AbstractCaptchaService {
return RandomUtil.randomString(CHARACTERS, length);
}
-}
\ No newline at end of file
+}
diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/justauth/core/AuthRequestFactory.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/justauth/core/AuthRequestFactory.java
index 4ae8b78c6c..53ceabcec6 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/justauth/core/AuthRequestFactory.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/justauth/core/AuthRequestFactory.java
@@ -77,8 +77,8 @@ public class AuthRequestFactory {
extendList = extend.getConfig()
.keySet()
.stream()
- .filter(x -> names.contains(x.toUpperCase()))
.map(String::toUpperCase)
+ .filter(names::contains)
.collect(Collectors.toList());
}
@@ -318,4 +318,4 @@ public class AuthRequestFactory {
.proxy(new Proxy(Proxy.Type.valueOf(proxyConfig.getType()), new InetSocketAddress(proxyConfig.getHostname(), proxyConfig.getPort())))
.build());
}
-}
\ No newline at end of file
+}
diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java
index d4ed95d9b2..538efb966b 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClient.java
@@ -114,12 +114,12 @@ public class AliyunSmsClient extends AbstractSmsClient {
@VisibleForTesting
Integer convertSmsTemplateAuditStatus(Integer templateStatus) {
- switch (templateStatus) {
- case 0: return SmsTemplateAuditStatusEnum.CHECKING.getStatus();
- case 1: return SmsTemplateAuditStatusEnum.SUCCESS.getStatus();
- case 2: return SmsTemplateAuditStatusEnum.FAIL.getStatus();
- default: throw new IllegalArgumentException(String.format("未知审核状态(%d)", templateStatus));
- }
+ return switch (templateStatus) {
+ case 0 -> SmsTemplateAuditStatusEnum.CHECKING.getStatus();
+ case 1 -> SmsTemplateAuditStatusEnum.SUCCESS.getStatus();
+ case 2 -> SmsTemplateAuditStatusEnum.FAIL.getStatus();
+ default -> throw new IllegalArgumentException(String.format("未知审核状态(%d)", templateStatus));
+ };
}
/**
@@ -153,8 +153,8 @@ public class AliyunSmsClient extends AbstractSmsClient {
StringBuilder canonicalHeaders = new StringBuilder(); // 构造请求头,多个规范化消息头,按照消息头名称(小写)的字符代码顺序以升序排列后拼接在一起
StringBuilder signedHeadersBuilder = new StringBuilder(); // 已签名消息头列表,多个请求头名称(小写)按首字母升序排列并以英文分号(;)分隔
headers.entrySet().stream().filter(entry -> entry.getKey().toLowerCase().startsWith("x-acs-")
- || entry.getKey().equalsIgnoreCase("host")
- || entry.getKey().equalsIgnoreCase("content-type"))
+ || "host".equalsIgnoreCase(entry.getKey())
+ || "content-type".equalsIgnoreCase(entry.getKey()))
.sorted(Map.Entry.comparingByKey()).forEach(entry -> {
String lowerKey = entry.getKey().toLowerCase();
canonicalHeaders.append(lowerKey).append(":").append(String.valueOf(entry.getValue()).trim()).append("\n");
@@ -189,10 +189,10 @@ public class AliyunSmsClient extends AbstractSmsClient {
@SneakyThrows
private static String percentCode(String str) {
Assert.notNull(str, "str 不能为空");
- return URLEncoder.encode(str, StandardCharsets.UTF_8.name())
+ return URLEncoder.encode(str, StandardCharsets.UTF_8)
.replace("+", "%20") // 加号 "+" 被替换为 "%20"
.replace("*", "%2A") // 星号 "*" 被替换为 "%2A"
.replace("%7E", "~"); // 波浪号 "%7E" 被替换为 "~"
}
-}
\ No newline at end of file
+}