sonarqube质量修复

This commit is contained in:
gaoqr
2024-10-09 12:04:54 +08:00
parent 2e96dd8173
commit 220d0ff28a
36 changed files with 242 additions and 513 deletions
@@ -12,38 +12,32 @@ import com.cf.imes.framework.common.exception.ErrorCode;
*
* @author 晨丰科技
*/
public interface GlobalErrorCodeConstants {
public class GlobalErrorCodeConstants {
ErrorCode SUCCESS = new ErrorCode(0, "成功");
public static final ErrorCode SUCCESS = new ErrorCode(0, "成功");
// ========== 客户端错误段 ==========
ErrorCode BAD_REQUEST = new ErrorCode(400, "请求参数不正确");
ErrorCode UNAUTHORIZED = new ErrorCode(401, "账号未登录");
ErrorCode FORBIDDEN = new ErrorCode(403, "没有该操作权限");
ErrorCode NOT_FOUND = new ErrorCode(404, "请求未找到");
ErrorCode METHOD_NOT_ALLOWED = new ErrorCode(405, "请求方法不正确");
ErrorCode LOCKED = new ErrorCode(423, "请求失败,请稍后重试"); // 并发请求,不允许
ErrorCode TOO_MANY_REQUESTS = new ErrorCode(429, "请求过于频繁,请稍后重试");
ErrorCode DATA_SOURCE_CODE_NOT_FOUND = new ErrorCode(430, "未传递数据源标识");
ErrorCode ORGAN_ID_NOT_FOUND = new ErrorCode(431, "未传组织标识");
public static final ErrorCode BAD_REQUEST = new ErrorCode(400, "请求参数不正确");
public static final ErrorCode UNAUTHORIZED = new ErrorCode(401, "账号未登录");
public static final ErrorCode FORBIDDEN = new ErrorCode(403, "没有该操作权限");
public static final ErrorCode NOT_FOUND = new ErrorCode(404, "请求未找到");
public static final ErrorCode METHOD_NOT_ALLOWED = new ErrorCode(405, "请求方法不正确");
public static final ErrorCode LOCKED = new ErrorCode(423, "请求失败,请稍后重试"); // 并发请求,不允许
public static final ErrorCode TOO_MANY_REQUESTS = new ErrorCode(429, "请求过于频繁,请稍后重试");
// ========== 服务端错误段 ==========
ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "系统异常,请联系客服处理");
ErrorCode NOT_IMPLEMENTED = new ErrorCode(501, "功能未实现/未开启");
ErrorCode ERROR_CONFIGURATION = new ErrorCode(502, "错误的配置项");
public static final ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "系统异常,请联系客服处理");
public static final ErrorCode NOT_IMPLEMENTED = new ErrorCode(501, "功能未实现/未开启");
// ES文档更新失败
ErrorCode ES_ERROR_UPDATE = new ErrorCode(503, "数据异常,请勿点击过快,请稍等再试");
public static final ErrorCode ES_ERROR_UPDATE = new ErrorCode(503, "数据异常,请勿点击过快,请稍等再试");
// ES文档删除失败
ErrorCode ES_ERROR_DELETE = new ErrorCode(504, "数据异常,请勿点击过快,请稍等再试");
ErrorCode DATA_EXCEPTION_ERROR = new ErrorCode(505, "数据异常,请联系客服处理");
public static final ErrorCode ES_ERROR_DELETE = new ErrorCode(504, "数据异常,请勿点击过快,请稍等再试");
public static final ErrorCode DATA_EXCEPTION_ERROR = new ErrorCode(505, "数据异常,请联系客服处理");
// ========== 自定义错误段 ==========
ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求
ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式,禁止写操作");
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
public static final ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求
public static final ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式,禁止写操作");
}
@@ -34,6 +34,8 @@ public class JsonUtils {
private static ObjectMapper objectMapper = new ObjectMapper();
private static final String JSON_PARSE_ERROR_NOTIFICATION = "json parse err,json:{}";
static {
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -74,7 +76,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, clazz);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -88,7 +90,7 @@ public class JsonUtils {
JsonNode pathNode = treeNode.path(path);
return objectMapper.readValue(pathNode.toString(), clazz);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -100,7 +102,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructType(type));
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -128,7 +130,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(bytes, clazz);
} catch (IOException e) {
log.error("json parse err,json:{}", bytes, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, bytes, e);
throw new RuntimeException(e);
}
}
@@ -137,7 +139,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, typeReference);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -149,7 +151,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -163,7 +165,7 @@ public class JsonUtils {
JsonNode pathNode = treeNode.path(path);
return objectMapper.readValue(pathNode.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -172,7 +174,7 @@ public class JsonUtils {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -181,7 +183,7 @@ public class JsonUtils {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -246,23 +248,26 @@ public class JsonUtils {
//设置解压缩的输入数据。
inflater.setInput(decode);
final byte[] bytes = new byte[256];
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
try {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256)) {
//finished() 如果已到达压缩数据流的末尾,则返回true。
while (!inflater.finished()) {
//将字节解压缩到指定的缓冲区中。
int length = inflater.inflate(bytes);
outputStream.write(bytes, 0, length);
}
return outputStream.toString();
} catch (DataFormatException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
//关闭解压缩器并丢弃任何未处理的输入。
inflater.end();
}
return outputStream.toString();
}
@@ -34,14 +34,17 @@ public class OrganKafkaProducerInterceptor implements ProducerInterceptor<Object
@Override
public void onAcknowledgement(RecordMetadata metadata, Exception exception) {
// onAcknowledgement
}
@Override
public void close() {
// close
}
@Override
public void configure(Map<String, ?> configs) {
// configure
}
}
@@ -31,6 +31,7 @@ public class OrganRocketMQSendMessageHook implements SendMessageHook {
@Override
public void sendMessageAfter(SendMessageContext sendMessageContext) {
// sendMessageAfter
}
}
@@ -4,6 +4,7 @@ import com.cf.imes.framework.pay.core.client.exception.PayException;
import com.cf.imes.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
import com.cf.imes.framework.pay.core.enums.order.PayOrderStatusRespEnum;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@@ -13,6 +14,7 @@ import java.time.LocalDateTime;
* @author 晨丰科技
*/
@Data
@NoArgsConstructor
public class PayOrderRespDTO {
/**
@@ -73,9 +75,6 @@ public class PayOrderRespDTO {
*/
private String channelErrorMsg;
public PayOrderRespDTO() {
}
/**
* 创建【WAITING】状态的订单返回
*/
@@ -1,8 +1,8 @@
package com.cf.imes.framework.pay.core.client.impl.weixin;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderRespDTO;
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
@@ -77,7 +77,7 @@ public class WxBarPayClient extends AbstractWxPayClient {
// 1. SYSTEMERROR:接口返回错误:请立即调用被扫订单结果查询API,查询当前订单状态,并根据订单的状态决定下一步的操作。
// 2. USERPAYING:用户支付中,需要输入密码:等待 5 秒,然后调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。
// 3. BANKERROR:银行系统异常:请立即调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。
if (!StrUtil.equalsAny(ex.getErrCode(), "SYSTEMERROR", "USERPAYING", "BANKERROR")) {
if (!CharSequenceUtil.equalsAny(ex.getErrCode(), "SYSTEMERROR", "USERPAYING", "BANKERROR")) {
throw ex;
}
// 等待 5 秒,继续下一轮重新发起支付
@@ -98,7 +98,7 @@ public class WxBarPayClient extends AbstractWxPayClient {
static String getAuthCode(PayOrderUnifiedReqDTO reqDTO) {
String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "authCode");
if (StrUtil.isEmpty(authCode)) {
if (CharSequenceUtil.isEmpty(authCode)) {
throw invalidParamException("支付请求的 authCode 不能为空!");
}
return authCode;
@@ -1,7 +1,7 @@
package com.cf.imes.framework.pay.core.client.impl.weixin;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderRespDTO;
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
import com.cf.imes.framework.pay.core.enums.channel.PayChannelEnum;
@@ -71,7 +71,7 @@ public class WxPubPayClient extends AbstractWxPayClient {
static String getOpenid(PayOrderUnifiedReqDTO reqDTO) {
String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid");
if (StrUtil.isEmpty(openid)) {
if (CharSequenceUtil.isEmpty(openid)) {
throw invalidParamException("支付请求的 openid 不能为空!");
}
return openid;
@@ -1,50 +0,0 @@
package com.cf.imes.framework.sms.core.enums;
import com.cf.imes.framework.common.exception.ErrorCode;
/**
* 短信框架的错误码枚举
*
* 短信框架,使用 2-001-000-000 段
*
* @author 晨丰科技
*/
public interface SmsFrameworkErrorCodeConstants {
ErrorCode SMS_UNKNOWN = new ErrorCode(2_001_000_000, "未知错误,需要解析");
// ========== 权限 / 限流等相关 2-001-000-100 ==========
ErrorCode SMS_PERMISSION_DENY = new ErrorCode(2_001_000_100, "没有发送短信的权限");
ErrorCode SMS_IP_DENY = new ErrorCode(2_001_000_100, "IP 不允许发送短信");
// 阿里云:将短信发送频率限制在正常的业务限流范围内。默认短信验证码:使用同一签名,对同一个手机号验证码,支持 1 条 / 分钟,5 条 / 小时,累计 10 条 / 天。
ErrorCode SMS_SEND_BUSINESS_LIMIT_CONTROL = new ErrorCode(2_001_000_102, "指定手机的发送限流");
// 阿里云:已经达到您在控制台设置的短信日发送量限额值。在国内消息设置 > 安全设置,修改发送总量阈值。
ErrorCode SMS_SEND_DAY_LIMIT_CONTROL = new ErrorCode(2_001_000_103, "每天的发送限流");
ErrorCode SMS_SEND_CONTENT_INVALID = new ErrorCode(2_001_000_104, "短信内容有敏感词");
// 腾讯云:为避免骚扰用户,营销短信只允许在8点到22点发送。
ErrorCode SMS_SEND_MARKET_LIMIT_CONTROL = new ErrorCode(2_001_000_105, "营销短信发送时间限制");
// ========== 模板相关 2-001-000-200 ==========
ErrorCode SMS_TEMPLATE_INVALID = new ErrorCode(2_001_000_200, "短信模板不合法"); // 包括短信模板不存在
ErrorCode SMS_TEMPLATE_PARAM_ERROR = new ErrorCode(2_001_000_201, "模板参数不正确");
// ========== 签名相关 2-001-000-300 ==========
ErrorCode SMS_SIGN_INVALID = new ErrorCode(2_001_000_300, "短信签名不可用");
// ========== 账户相关 2-001-000-400 ==========
ErrorCode SMS_ACCOUNT_MONEY_NOT_ENOUGH = new ErrorCode(2_001_000_400, "账户余额不足");
ErrorCode SMS_ACCOUNT_INVALID = new ErrorCode(2_001_000_401, "apiKey 不存在");
// ========== 其它相关 2-001-000-900 开头 ==========
ErrorCode SMS_API_PARAM_ERROR = new ErrorCode(2_001_000_900, "请求参数缺失");
ErrorCode SMS_MOBILE_INVALID = new ErrorCode(2_001_000_901, "手机格式不正确");
ErrorCode SMS_MOBILE_BLACK = new ErrorCode(2_001_000_902, "手机号在黑名单中");
ErrorCode SMS_APP_ID_INVALID = new ErrorCode(2_001_000_903, "SdkAppId不合法");
ErrorCode EXCEPTION = new ErrorCode(2_001_000_999, "调用异常");
}
@@ -1,28 +0,0 @@
package com.cf.imes.framework.captcha.core.enums;
/**
* 验证码 Redis Key 枚举类
*
* @author 晨丰科技
*/
public interface CaptchaRedisKeyConstants {
/**
* 验证码的请求限流
*
* KEY 格式:AJ.CAPTCHA.REQ.LIMIT-%s-%s
* VALUE 数据类型:String // 例如说:验证失败 5 次,get 接口锁定
* 过期时间:60 秒
*/
String AJ_CAPTCHA_REQ_LIMIT = "AJ.CAPTCHA.REQ.LIMIT-%s-%s";
/**
* 验证码的坐标
*
* KEY 格式:RUNNING:CAPTCHA:%s // AbstractCaptchaService.REDIS_CAPTCHA_KEY
* VALUE 数据类型:String // PointVO.class {"secretKey":"PP1w2Frr2KEejD2m","x":162,"y":5}
* 过期时间:120 秒
*/
String AJ_CAPTCHA_RUNNING = "RUNNING:CAPTCHA:%s";
}
@@ -2,9 +2,9 @@ package com.cf.imes.framework.desensitize.core.base.serializer;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.lang.Singleton;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.cf.imes.framework.desensitize.core.base.annotation.DesensitizeBy;
import com.cf.imes.framework.desensitize.core.base.handler.DesensitizationHandler;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -53,7 +53,7 @@ public class StringDesensitizeSerializer extends StdSerializer<String> implement
@Override
@SuppressWarnings("unchecked")
public void serialize(String value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException {
if (StrUtil.isBlank(value)) {
if (CharSequenceUtil.isBlank(value)) {
gen.writeNull();
return;
}
@@ -1,7 +1,7 @@
package com.cf.imes.framework.file.core.client.s3;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.http.HttpUtil;
import com.cf.imes.framework.file.core.client.AbstractFileClient;
import io.minio.*;
@@ -29,7 +29,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
@Override
protected void doInit() {
// 补全 domain
if (StrUtil.isEmpty(config.getDomain())) {
if (CharSequenceUtil.isEmpty(config.getDomain())) {
config.setDomain(buildDomain());
}
// 初始化客户端
@@ -50,7 +50,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) {
return config.getEndpoint();
}
return StrUtil.format("https://{}", config.getEndpoint());
return CharSequenceUtil.format("https://{}", config.getEndpoint());
}
/**
@@ -61,10 +61,10 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
private String buildDomain() {
// 如果已经是 http 或者 https,则不进行拼接.主要适配 MinIO
if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) {
return StrUtil.format("{}/{}", config.getEndpoint(), config.getBucket());
return CharSequenceUtil.format("{}/{}", config.getEndpoint(), config.getBucket());
}
// 阿里云、腾讯云、华为云都适合。七牛云比较特殊,必须有自定义域名
return StrUtil.format("https://{}.{}", config.getBucket(), config.getEndpoint());
return CharSequenceUtil.format("https://{}.{}", config.getBucket(), config.getEndpoint());
}
/**
@@ -75,13 +75,13 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
private String buildRegion() {
// 阿里云必须有 region,否则会报错
if (config.getEndpoint().contains(ENDPOINT_ALIYUN)) {
return StrUtil.subBefore(config.getEndpoint(), '.', false)
.replaceAll("-internal", "")// 去除内网 Endpoint 的后缀
.replaceAll("https://", "");
return CharSequenceUtil.subBefore(config.getEndpoint(), '.', false)
.replace("-internal", "")// 去除内网 Endpoint 的后缀
.replace("https://", "");
}
// 腾讯云必须有 region,否则会报错
if (config.getEndpoint().contains(ENDPOINT_TENCENT)) {
return StrUtil.subAfter(config.getEndpoint(), "cos.", false)
return CharSequenceUtil.subAfter(config.getEndpoint(), "cos.", false)
.replaceAll("." + ENDPOINT_TENCENT, ""); // 去除 Endpoint
}
return null;
@@ -1,6 +1,6 @@
package com.cf.imes.framework.file.core.client.s3;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
@@ -68,7 +68,7 @@ public class S3FileClientConfig implements FileClientConfig {
@JsonIgnore
public boolean isDomainValid() {
// 如果是七牛,必须带有 domain
if (StrUtil.contains(endpoint, ENDPOINT_QINIU) && StrUtil.isEmpty(domain)) {
if (CharSequenceUtil.contains(endpoint, ENDPOINT_QINIU) && CharSequenceUtil.isEmpty(domain)) {
return false;
}
return true;
@@ -1,22 +0,0 @@
package com.cf.imes.framework.datasource.core.enums;
/**
* 对应于多数据源中不同数据源配置
*
* 通过在方法上,使用 {@link com.baomidou.dynamic.datasource.annotation.DS} 注解,设置使用的数据源。
* 注意,默认是 {@link #MASTER} 数据源
*
* 对应官方文档为 http://dynamic-datasource.com/guide/customize/Annotation.html
*/
public interface DataSourceEnum {
/**
* 主库,推荐使用 {@link com.baomidou.dynamic.datasource.annotation.Master} 注解
*/
String MASTER = "master";
/**
* 从库,推荐使用 {@link com.baomidou.dynamic.datasource.annotation.Slave} 注解
*/
String SLAVE = "slave";
}
@@ -67,6 +67,8 @@ public class ChenfengMybatisAutoConfiguration {
return new KingbaseKeyGenerator();
case DM:
return new DmKeyGenerator();
default:
throw new IllegalArgumentException(CharSequenceUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
}
}
// 找不到合适的 IKeyGenerator 实现类
@@ -86,6 +86,7 @@ public class IdTypeEnvironmentPostProcessor implements EnvironmentPostProcessor
case SQL_SERVER2005:
driverClass = "org.quartz.impl.jdbcjobstore.MSSQLDelegate";
break;
default:
}
// 设置 driverClass 变量
if (CharSequenceUtil.isNotEmpty(driverClass)) {
@@ -1,7 +1,7 @@
package com.cf.imes.framework.mybatis.core.type;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@@ -53,6 +53,6 @@ public class StringListTypeHandler implements TypeHandler<List<String>> {
if (value == null) {
return null;
}
return StrUtil.splitTrim(value, COMMA);
return CharSequenceUtil.splitTrim(value, COMMA);
}
}
@@ -1,19 +0,0 @@
package com.cf.imes.framework.lock4j.core;
/**
* Lock4j Redis Key 枚举类
*
* @author 晨丰科技
*/
public interface Lock4jRedisKeyConstants {
/**
* 分布式锁
*
* KEY 格式:lock4j:%s // 参数来自 DefaultLockKeyBuilder 类
* VALUE 数据格式:HASH // RLock.classRedisson 的 Lock 锁,使用 Hash 数据结构
* 过期时间:不固定
*/
String LOCK4J = "lock4j:%s";
}
@@ -1,7 +1,8 @@
package com.cf.imes.framework.redis.core;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.cache.RedisCache;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
@@ -28,11 +29,11 @@ public class TimeoutRedisCacheManager extends RedisCacheManager {
@Override
protected RedisCache createRedisCache(String name, RedisCacheConfiguration cacheConfig) {
if (StrUtil.isEmpty(name)) {
if (CharSequenceUtil.isEmpty(name)) {
return super.createRedisCache(name, cacheConfig);
}
// 如果使用 # 分隔,大小不为 2,则说明不使用自定义过期时间
String[] names = StrUtil.splitToArray(name, SPLIT);
String[] names = CharSequenceUtil.splitToArray(name, SPLIT);
if (names.length != 2) {
return super.createRedisCache(name, cacheConfig);
}
@@ -40,7 +41,7 @@ public class TimeoutRedisCacheManager extends RedisCacheManager {
// 核心:通过修改 cacheConfig 的过期时间,实现自定义过期时间
if (cacheConfig != null) {
// 移除 # 后面的 : 以及后面的内容,避免影响解析
names[1] = StrUtil.subBefore(names[1], StrUtil.COLON, false);
names[1] = CharSequenceUtil.subBefore(names[1], StrPool.COLON, false);
// 解析时间
Duration duration = parseDuration(names[1]);
cacheConfig = cacheConfig.entryTtl(duration);
@@ -55,7 +56,7 @@ public class TimeoutRedisCacheManager extends RedisCacheManager {
* @return 过期时间 Duration
*/
private Duration parseDuration(String ttlStr) {
String timeUnit = StrUtil.subSuf(ttlStr, -1);
String timeUnit = CharSequenceUtil.subSuf(ttlStr, -1);
switch (timeUnit) {
case "d":
return Duration.ofDays(removeDurationSuffix(ttlStr));
@@ -77,7 +78,7 @@ public class TimeoutRedisCacheManager extends RedisCacheManager {
* @return 时间
*/
private Long removeDurationSuffix(String ttlStr) {
return NumberUtil.parseLong(StrUtil.sub(ttlStr, 0, ttlStr.length() - 1));
return NumberUtil.parseLong(CharSequenceUtil.sub(ttlStr, 0, ttlStr.length() - 1));
}
}
@@ -186,6 +186,7 @@ public class ChenfengWebSecurityConfigurerAdapter {
case DELETE:
result.putAll(HttpMethod.DELETE, urls);
break;
default:
}
});
}
@@ -1,7 +1,7 @@
package com.cf.imes.framework.security.core.filter;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.json.JsonUtils;
@@ -58,7 +58,7 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
if (loginUser == null) {
String token = SecurityFrameworkUtils.obtainAuthorization(request,
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
if (StrUtil.isNotEmpty(token)) {
if (CharSequenceUtil.isNotEmpty(token)) {
Integer userType = WebFrameworkUtils.getLoginUserType(request);
try {
// 1.1 基于 token 构建登录用户
@@ -135,7 +135,7 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
@SneakyThrows
private LoginUser buildLoginUserByHeader(HttpServletRequest request) {
String loginUserStr = request.getHeader(SecurityFrameworkUtils.LOGIN_USER_HEADER);
if(StrUtil.isNotEmpty(loginUserStr)) {
if(CharSequenceUtil.isNotEmpty(loginUserStr)) {
try {
loginUserStr = URLDecoder.decode(loginUserStr, StandardCharsets.UTF_8.name()); // 解码,解决中文乱码问题
return JsonUtils.parseObject(loginUserStr, LoginUser.class);
@@ -1,9 +1,9 @@
package com.cf.imes.framework.test.core.util;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.cf.imes.framework.common.enums.CommonStatusEnum;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;
@@ -46,7 +46,7 @@ public class RandomUtils {
return RandomUtil.randomEle(CommonStatusEnum.values()).getStatus();
}
// 如果是 type、status 结尾的字段,返回 tinyint 范围
if (StrUtil.endWithAnyIgnoreCase(attributeMetadata.getAttributeName(),
if (CharSequenceUtil.endWithAnyIgnoreCase(attributeMetadata.getAttributeName(),
"type", "status", "category", "scope", "result")) {
return RandomUtil.randomInt(0, TINYINT_MAX + 1);
}
@@ -55,7 +55,9 @@ public class CacheRequestBodyWrapper extends HttpServletRequestWrapper {
}
@Override
public void setReadListener(ReadListener readListener) {}
public void setReadListener(ReadListener readListener) {
// setReadListener
}
@Override
public int available() {
@@ -2,7 +2,7 @@ package com.cf.imes.framework.web.core.handler;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.cf.imes.framework.apilog.core.service.ApiErrorLog;
import com.cf.imes.framework.apilog.core.service.ApiErrorLogFrameworkService;
@@ -330,7 +330,7 @@ public class GlobalExceptionHandler {
"[微信公众号 cf-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]");
}
// 4. 商城系统
if (StrUtil.containsAny(message, "product_", "promotion_", "trade_")) {
if (CharSequenceUtil.containsAny(message, "product_", "promotion_", "trade_")) {
log.error("[商城系统 cf-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]");
return CommonResult.error(NOT_IMPLEMENTED.getCode(),
"[商城系统 cf-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]");