mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-13 13:01:41 +08:00
refactor: 根据 Sonar 建议调整,StrUtil => CharSequenceUtil
工具层调整以减少 Sonar 建议,应用层则可忽略,怎么用方便怎么来
This commit is contained in:
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.cache.redisson.autoconfigure;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.redisson.codec.JsonJacksonCodec;
|
import org.redisson.codec.JsonJacksonCodec;
|
||||||
import org.redisson.config.ClusterServersConfig;
|
import org.redisson.config.ClusterServersConfig;
|
||||||
@@ -101,7 +101,7 @@ public class RedissonAutoConfiguration {
|
|||||||
List<String> nodeList = redisProperties.getCluster().getNodes();
|
List<String> nodeList = redisProperties.getCluster().getNodes();
|
||||||
nodeList.stream().map(node -> protocolPrefix + node).forEach(clusterServersConfig::addNodeAddress);
|
nodeList.stream().map(node -> protocolPrefix + node).forEach(clusterServersConfig::addNodeAddress);
|
||||||
}
|
}
|
||||||
if (StrUtil.isBlank(clusterServersConfig.getPassword())) {
|
if (CharSequenceUtil.isBlank(clusterServersConfig.getPassword())) {
|
||||||
clusterServersConfig.setPassword(redisProperties.getPassword());
|
clusterServersConfig.setPassword(redisProperties.getPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,10 +124,10 @@ public class RedissonAutoConfiguration {
|
|||||||
List<String> nodeList = redisProperties.getSentinel().getNodes();
|
List<String> nodeList = redisProperties.getSentinel().getNodes();
|
||||||
nodeList.stream().map(node -> protocolPrefix + node).forEach(sentinelServersConfig::addSentinelAddress);
|
nodeList.stream().map(node -> protocolPrefix + node).forEach(sentinelServersConfig::addSentinelAddress);
|
||||||
}
|
}
|
||||||
if (StrUtil.isBlank(sentinelServersConfig.getPassword())) {
|
if (CharSequenceUtil.isBlank(sentinelServersConfig.getPassword())) {
|
||||||
sentinelServersConfig.setPassword(redisProperties.getPassword());
|
sentinelServersConfig.setPassword(redisProperties.getPassword());
|
||||||
}
|
}
|
||||||
if (StrUtil.isBlank(sentinelServersConfig.getMasterName())) {
|
if (CharSequenceUtil.isBlank(sentinelServersConfig.getMasterName())) {
|
||||||
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
|
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,10 +146,10 @@ public class RedissonAutoConfiguration {
|
|||||||
}
|
}
|
||||||
// 下方配置如果为空,则使用 Redis 的配置
|
// 下方配置如果为空,则使用 Redis 的配置
|
||||||
singleServerConfig.setDatabase(redisProperties.getDatabase());
|
singleServerConfig.setDatabase(redisProperties.getDatabase());
|
||||||
if (StrUtil.isBlank(singleServerConfig.getPassword())) {
|
if (CharSequenceUtil.isBlank(singleServerConfig.getPassword())) {
|
||||||
singleServerConfig.setPassword(redisProperties.getPassword());
|
singleServerConfig.setPassword(redisProperties.getPassword());
|
||||||
}
|
}
|
||||||
if (StrUtil.isBlank(singleServerConfig.getAddress())) {
|
if (CharSequenceUtil.isBlank(singleServerConfig.getAddress())) {
|
||||||
singleServerConfig.setAddress(protocolPrefix + redisProperties
|
singleServerConfig.setAddress(protocolPrefix + redisProperties
|
||||||
.getHost() + StringConstants.COLON + redisProperties.getPort());
|
.getHost() + StringConstants.COLON + redisProperties.getPort());
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.cache.springcache.autoconfigure;
|
package top.charles7c.continew.starter.cache.springcache.autoconfigure;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
@@ -92,7 +92,7 @@ public class SpringCacheAutoConfiguration implements CachingConfigurer {
|
|||||||
@Override
|
@Override
|
||||||
public KeyGenerator keyGenerator() {
|
public KeyGenerator keyGenerator() {
|
||||||
return (target, method, params) -> {
|
return (target, method, params) -> {
|
||||||
String key = StrUtil.toUnderlineCase(method.getName()).toUpperCase();
|
String key = CharSequenceUtil.toUnderlineCase(method.getName()).toUpperCase();
|
||||||
Map<String, Object> paramMap = MapUtil.newHashMap(params.length);
|
Map<String, Object> paramMap = MapUtil.newHashMap(params.length);
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
paramMap.put(String.valueOf(i), params[i]);
|
paramMap.put(String.valueOf(i), params[i]);
|
||||||
|
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.captcha.behavior.autoconfigure;
|
|||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.anji.captcha.model.common.Const;
|
import com.anji.captcha.model.common.Const;
|
||||||
import com.anji.captcha.service.CaptchaService;
|
import com.anji.captcha.service.CaptchaService;
|
||||||
import com.anji.captcha.service.impl.CaptchaServiceFactory;
|
import com.anji.captcha.service.impl.CaptchaServiceFactory;
|
||||||
@@ -81,8 +81,8 @@ public class BehaviorCaptchaAutoConfiguration {
|
|||||||
config.put(Const.CAPTCHA_FONT_TYPE, properties.getFontType());
|
config.put(Const.CAPTCHA_FONT_TYPE, properties.getFontType());
|
||||||
config.put(Const.CAPTCHA_TYPE, properties.getType().getCodeValue());
|
config.put(Const.CAPTCHA_TYPE, properties.getType().getCodeValue());
|
||||||
config.put(Const.CAPTCHA_INTERFERENCE_OPTIONS, properties.getInterferenceOptions());
|
config.put(Const.CAPTCHA_INTERFERENCE_OPTIONS, properties.getInterferenceOptions());
|
||||||
config.put(Const.ORIGINAL_PATH_JIGSAW, StrUtil.emptyIfNull(properties.getJigsawBaseMapPath()));
|
config.put(Const.ORIGINAL_PATH_JIGSAW, CharSequenceUtil.emptyIfNull(properties.getJigsawBaseMapPath()));
|
||||||
config.put(Const.ORIGINAL_PATH_PIC_CLICK, StrUtil.emptyIfNull(properties.getPicClickBaseMapPath()));
|
config.put(Const.ORIGINAL_PATH_PIC_CLICK, CharSequenceUtil.emptyIfNull(properties.getPicClickBaseMapPath()));
|
||||||
config.put(Const.CAPTCHA_SLIP_OFFSET, properties.getSlipOffset());
|
config.put(Const.CAPTCHA_SLIP_OFFSET, properties.getSlipOffset());
|
||||||
config.put(Const.CAPTCHA_AES_STATUS, String.valueOf(properties.getEnableAes()));
|
config.put(Const.CAPTCHA_AES_STATUS, String.valueOf(properties.getEnableAes()));
|
||||||
config.put(Const.CAPTCHA_WATER_FONT, properties.getWaterFont());
|
config.put(Const.CAPTCHA_WATER_FONT, properties.getWaterFont());
|
||||||
@@ -98,8 +98,8 @@ public class BehaviorCaptchaAutoConfiguration {
|
|||||||
config.put(Const.CAPTCHA_FONT_SIZE, properties.getFontSize());
|
config.put(Const.CAPTCHA_FONT_SIZE, properties.getFontSize());
|
||||||
config.put(Const.CAPTCHA_FONT_STYLE, properties.getFontStyle());
|
config.put(Const.CAPTCHA_FONT_STYLE, properties.getFontStyle());
|
||||||
config.put(Const.CAPTCHA_WORD_COUNT, 4);
|
config.put(Const.CAPTCHA_WORD_COUNT, 4);
|
||||||
if (StrUtil.startWith(properties.getJigsawBaseMapPath(), "classpath:") || StrUtil.startWith(properties
|
if (CharSequenceUtil.startWith(properties.getJigsawBaseMapPath(), "classpath:") || CharSequenceUtil
|
||||||
.getPicClickBaseMapPath(), "classpath:")) {
|
.startWith(properties.getPicClickBaseMapPath(), "classpath:")) {
|
||||||
// 自定义 resources 目录下初始化底图
|
// 自定义 resources 目录下初始化底图
|
||||||
config.put(Const.CAPTCHA_INIT_ORIGINAL, true);
|
config.put(Const.CAPTCHA_INIT_ORIGINAL, true);
|
||||||
initializeBaseMap(properties.getJigsawBaseMapPath(), properties.getPicClickBaseMapPath());
|
initializeBaseMap(properties.getJigsawBaseMapPath(), properties.getPicClickBaseMapPath());
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.captcha.graphic.core;
|
package top.charles7c.continew.starter.captcha.graphic.core;
|
||||||
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import top.charles7c.continew.starter.captcha.graphic.autoconfigure.GraphicCaptchaProperties;
|
import top.charles7c.continew.starter.captcha.graphic.autoconfigure.GraphicCaptchaProperties;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class GraphicCaptchaService {
|
|||||||
Captcha captcha = ReflectUtil.newInstance(properties.getType().getCaptchaImpl(), properties
|
Captcha captcha = ReflectUtil.newInstance(properties.getType().getCaptchaImpl(), properties
|
||||||
.getWidth(), properties.getHeight());
|
.getWidth(), properties.getHeight());
|
||||||
captcha.setLen(properties.getLength());
|
captcha.setLen(properties.getLength());
|
||||||
if (StrUtil.isNotBlank(properties.getFontName())) {
|
if (CharSequenceUtil.isNotBlank(properties.getFontName())) {
|
||||||
captcha.setFont(new Font(properties.getFontName(), Font.PLAIN, properties.getFontSize()));
|
captcha.setFont(new Font(properties.getFontName(), Font.PLAIN, properties.getFontSize()));
|
||||||
}
|
}
|
||||||
return captcha;
|
return captcha;
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.core.util;
|
package top.charles7c.continew.starter.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||||
import org.springframework.core.env.PropertySource;
|
import org.springframework.core.env.PropertySource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@@ -43,7 +43,7 @@ public class GeneralPropertySourceFactory extends DefaultPropertySourceFactory {
|
|||||||
EncodedResource encodedResource) throws IOException {
|
EncodedResource encodedResource) throws IOException {
|
||||||
Resource resource = encodedResource.getResource();
|
Resource resource = encodedResource.getResource();
|
||||||
String resourceName = resource.getFilename();
|
String resourceName = resource.getFilename();
|
||||||
if (StrUtil.isNotBlank(resourceName) && StrUtil.endWithAny(resourceName, ".yml", ".yaml")) {
|
if (CharSequenceUtil.isNotBlank(resourceName) && CharSequenceUtil.endWithAny(resourceName, ".yml", ".yaml")) {
|
||||||
return new YamlPropertySourceLoader().load(resourceName, resource).get(0);
|
return new YamlPropertySourceLoader().load(resourceName, resource).get(0);
|
||||||
}
|
}
|
||||||
return super.createPropertySource(name, encodedResource);
|
return super.createPropertySource(name, encodedResource);
|
||||||
|
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.core.util;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.net.NetUtil;
|
import cn.hutool.core.net.NetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||||
@@ -52,7 +52,7 @@ public class IpUtils {
|
|||||||
IpInfo ipInfo = ip2regionSearcher.memorySearch(ip);
|
IpInfo ipInfo = ip2regionSearcher.memorySearch(ip);
|
||||||
if (null != ipInfo) {
|
if (null != ipInfo) {
|
||||||
Set<String> regionSet = CollUtil.newLinkedHashSet(ipInfo.getAddress(), ipInfo.getIsp());
|
Set<String> regionSet = CollUtil.newLinkedHashSet(ipInfo.getAddress(), ipInfo.getIsp());
|
||||||
regionSet.removeIf(StrUtil::isBlank);
|
regionSet.removeIf(CharSequenceUtil::isBlank);
|
||||||
return String.join(StringConstants.SPACE, regionSet);
|
return String.join(StringConstants.SPACE, regionSet);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.core.util.db;
|
package top.charles7c.continew.starter.core.util.db;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.db.Db;
|
import cn.hutool.db.Db;
|
||||||
import cn.hutool.db.Entity;
|
import cn.hutool.db.Entity;
|
||||||
import cn.hutool.db.meta.Column;
|
import cn.hutool.db.meta.Column;
|
||||||
@@ -61,7 +61,7 @@ public class MetaUtils {
|
|||||||
String querySql = "SHOW TABLE STATUS";
|
String querySql = "SHOW TABLE STATUS";
|
||||||
List<Entity> tableEntityList;
|
List<Entity> tableEntityList;
|
||||||
Db db = Db.use(dataSource);
|
Db db = Db.use(dataSource);
|
||||||
if (StrUtil.isNotBlank(tableName)) {
|
if (CharSequenceUtil.isNotBlank(tableName)) {
|
||||||
tableEntityList = db.query(String.format("%s WHERE NAME = ?", querySql), tableName);
|
tableEntityList = db.query(String.format("%s WHERE NAME = ?", querySql), tableName);
|
||||||
} else {
|
} else {
|
||||||
tableEntityList = db.query(querySql);
|
tableEntityList = db.query(querySql);
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.core.util.validate;
|
package top.charles7c.continew.starter.core.util.validate;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
import top.charles7c.continew.starter.core.exception.BusinessException;
|
import top.charles7c.continew.starter.core.exception.BusinessException;
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param fieldValue 字段值
|
* @param fieldValue 字段值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
||||||
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil
|
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, CharSequenceUtil
|
||||||
.replace(entityName, "DO", StringConstants.EMPTY));
|
.replace(entityName, "DO", StringConstants.EMPTY));
|
||||||
throwIfNull(obj, message, EXCEPTION_TYPE);
|
throwIfNull(obj, message, EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNull(Object obj, String template, Object... params) {
|
public static void throwIfNull(Object obj, String template, Object... params) {
|
||||||
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +69,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
||||||
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +93,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
||||||
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +104,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
||||||
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,7 +115,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
||||||
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +126,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
||||||
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,7 +138,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||||
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +150,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||||
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +162,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
||||||
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,7 +177,7 @@ public class CheckUtils extends Validator {
|
|||||||
CharSequence str2,
|
CharSequence str2,
|
||||||
String template,
|
String template,
|
||||||
Object... params) {
|
Object... params) {
|
||||||
throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,7 +188,7 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIf(boolean condition, String template, Object... params) {
|
public static void throwIf(boolean condition, String template, Object... params) {
|
||||||
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIf(condition, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,6 +199,6 @@ public class CheckUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
||||||
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIf(conditionSupplier, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.core.util.validate;
|
package top.charles7c.continew.starter.core.util.validate;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
@@ -43,7 +43,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNull(Object obj, String template, Object... params) {
|
public static void throwIfNull(Object obj, String template, Object... params) {
|
||||||
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +54,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
||||||
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +65,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
||||||
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
||||||
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +87,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
||||||
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
||||||
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +110,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||||
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +122,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||||
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
||||||
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,7 +149,7 @@ public class ValidationUtils extends Validator {
|
|||||||
CharSequence str2,
|
CharSequence str2,
|
||||||
String template,
|
String template,
|
||||||
Object... params) {
|
Object... params) {
|
||||||
throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIfNotEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +160,7 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIf(boolean condition, String template, Object... params) {
|
public static void throwIf(boolean condition, String template, Object... params) {
|
||||||
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIf(condition, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,6 +171,6 @@ public class ValidationUtils extends Validator {
|
|||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
*/
|
*/
|
||||||
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
||||||
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);
|
throwIf(conditionSupplier, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.core.util.validate;
|
package top.charles7c.continew.starter.core.util.validate;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public class Validator {
|
|||||||
protected static void throwIfBlank(CharSequence str,
|
protected static void throwIfBlank(CharSequence str,
|
||||||
String message,
|
String message,
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
Class<? extends RuntimeException> exceptionType) {
|
||||||
throwIf(StrUtil.isBlank(str), message, exceptionType);
|
throwIf(CharSequenceUtil.isBlank(str), message, exceptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +103,7 @@ public class Validator {
|
|||||||
protected static void throwIfNotBlank(CharSequence str,
|
protected static void throwIfNotBlank(CharSequence str,
|
||||||
String message,
|
String message,
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
Class<? extends RuntimeException> exceptionType) {
|
||||||
throwIf(StrUtil.isNotBlank(str), message, exceptionType);
|
throwIf(CharSequenceUtil.isNotBlank(str), message, exceptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +148,7 @@ public class Validator {
|
|||||||
CharSequence str2,
|
CharSequence str2,
|
||||||
String message,
|
String message,
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
Class<? extends RuntimeException> exceptionType) {
|
||||||
throwIf(StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
throwIf(CharSequenceUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,7 +163,7 @@ public class Validator {
|
|||||||
CharSequence str2,
|
CharSequence str2,
|
||||||
String message,
|
String message,
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
Class<? extends RuntimeException> exceptionType) {
|
||||||
throwIf(!StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
throwIf(!CharSequenceUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,18 +16,9 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.data.mybatis.plus.datapermission;
|
package top.charles7c.continew.starter.data.mybatis.plus.datapermission;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
|
||||||
|
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
import net.sf.jsqlparser.expression.Function;
|
import net.sf.jsqlparser.expression.Function;
|
||||||
import net.sf.jsqlparser.expression.LongValue;
|
import net.sf.jsqlparser.expression.LongValue;
|
||||||
@@ -42,6 +33,13 @@ import net.sf.jsqlparser.schema.Table;
|
|||||||
import net.sf.jsqlparser.statement.select.PlainSelect;
|
import net.sf.jsqlparser.statement.select.PlainSelect;
|
||||||
import net.sf.jsqlparser.statement.select.SelectExpressionItem;
|
import net.sf.jsqlparser.statement.select.SelectExpressionItem;
|
||||||
import net.sf.jsqlparser.statement.select.SubSelect;
|
import net.sf.jsqlparser.statement.select.SubSelect;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限处理器实现类
|
* 数据权限处理器实现类
|
||||||
@@ -69,7 +67,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
|||||||
for (Method method : methodArr) {
|
for (Method method : methodArr) {
|
||||||
DataPermission dataPermission = method.getAnnotation(DataPermission.class);
|
DataPermission dataPermission = method.getAnnotation(DataPermission.class);
|
||||||
String name = method.getName();
|
String name = method.getName();
|
||||||
if (null == dataPermission || !StrUtil.equalsAny(methodName, name, name + "_COUNT")) {
|
if (null == dataPermission || !CharSequenceUtil.equalsAny(methodName, name, name + "_COUNT")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (dataPermissionFilter.isFilter()) {
|
if (dataPermissionFilter.isFilter()) {
|
||||||
|
@@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
||||||
import top.charles7c.continew.starter.core.util.ReflectUtils;
|
import top.charles7c.continew.starter.core.util.ReflectUtils;
|
||||||
@@ -117,7 +117,7 @@ public class QueryWrapperHelper {
|
|||||||
// 没有 @Query 注解,默认等值查询
|
// 没有 @Query 注解,默认等值查询
|
||||||
Query queryAnnotation = field.getAnnotation(Query.class);
|
Query queryAnnotation = field.getAnnotation(Query.class);
|
||||||
if (null == queryAnnotation) {
|
if (null == queryAnnotation) {
|
||||||
return Collections.singletonList(q -> q.eq(StrUtil.toUnderlineCase(fieldName), fieldValue));
|
return Collections.singletonList(q -> q.eq(CharSequenceUtil.toUnderlineCase(fieldName), fieldValue));
|
||||||
}
|
}
|
||||||
// 解析单列查询
|
// 解析单列查询
|
||||||
QueryType queryType = queryAnnotation.type();
|
QueryType queryType = queryAnnotation.type();
|
||||||
@@ -125,7 +125,7 @@ public class QueryWrapperHelper {
|
|||||||
final int columnLength = ArrayUtil.length(columns);
|
final int columnLength = ArrayUtil.length(columns);
|
||||||
List<Consumer<QueryWrapper<R>>> consumers = new ArrayList<>(columnLength);
|
List<Consumer<QueryWrapper<R>>> consumers = new ArrayList<>(columnLength);
|
||||||
if (columnLength <= 1) {
|
if (columnLength <= 1) {
|
||||||
String columnName = columnLength == 1 ? columns[0] : StrUtil.toUnderlineCase(fieldName);
|
String columnName = columnLength == 1 ? columns[0] : CharSequenceUtil.toUnderlineCase(fieldName);
|
||||||
parse(queryType, columnName, fieldValue, consumers);
|
parse(queryType, columnName, fieldValue, consumers);
|
||||||
return consumers;
|
return consumers;
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.extension.crud.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
@@ -184,7 +184,8 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
|
|||||||
private void checkPermission(Api api) {
|
private void checkPermission(Api api) {
|
||||||
CrudRequestMapping crudRequestMapping = this.getClass().getDeclaredAnnotation(CrudRequestMapping.class);
|
CrudRequestMapping crudRequestMapping = this.getClass().getDeclaredAnnotation(CrudRequestMapping.class);
|
||||||
String path = crudRequestMapping.value();
|
String path = crudRequestMapping.value();
|
||||||
String permissionPrefix = String.join(StringConstants.COLON, StrUtil.splitTrim(path, StringConstants.SLASH));
|
String permissionPrefix = String.join(StringConstants.COLON, CharSequenceUtil
|
||||||
|
.splitTrim(path, StringConstants.SLASH));
|
||||||
StpUtil.checkPermission(String.format("%s:%s", permissionPrefix, api.name().toLowerCase()));
|
StpUtil.checkPermission(String.format("%s:%s", permissionPrefix, api.name().toLowerCase()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.extension.crud.model.query;
|
package top.charles7c.continew.starter.extension.crud.model.query;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -77,7 +77,7 @@ public class PageQuery extends SortQuery {
|
|||||||
for (Sort.Order order : pageSort) {
|
for (Sort.Order order : pageSort) {
|
||||||
OrderItem orderItem = new OrderItem();
|
OrderItem orderItem = new OrderItem();
|
||||||
orderItem.setAsc(order.isAscending());
|
orderItem.setAsc(order.isAscending());
|
||||||
orderItem.setColumn(StrUtil.toUnderlineCase(order.getProperty()));
|
orderItem.setColumn(CharSequenceUtil.toUnderlineCase(order.getProperty()));
|
||||||
mybatisPage.addOrder(orderItem);
|
mybatisPage.addOrder(orderItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.extension.crud.model.query;
|
package top.charles7c.continew.starter.extension.crud.model.query;
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
@@ -56,10 +56,10 @@ public class SortQuery implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Sort.Order> orders = new ArrayList<>(sort.length);
|
List<Sort.Order> orders = new ArrayList<>(sort.length);
|
||||||
if (StrUtil.contains(sort[0], StringConstants.COMMA)) {
|
if (CharSequenceUtil.contains(sort[0], StringConstants.COMMA)) {
|
||||||
// e.g "sort=createTime,desc&sort=name,asc"
|
// e.g "sort=createTime,desc&sort=name,asc"
|
||||||
for (String s : sort) {
|
for (String s : sort) {
|
||||||
List<String> sortList = StrUtil.splitTrim(s, StringConstants.COMMA);
|
List<String> sortList = CharSequenceUtil.splitTrim(s, StringConstants.COMMA);
|
||||||
Sort.Order order = new Sort.Order(Sort.Direction.valueOf(sortList.get(1).toUpperCase()), sortList
|
Sort.Order order = new Sort.Order(Sort.Direction.valueOf(sortList.get(1).toUpperCase()), sortList
|
||||||
.get(0));
|
.get(0));
|
||||||
orders.add(order);
|
orders.add(order);
|
||||||
|
@@ -25,7 +25,7 @@ import cn.hutool.core.lang.tree.Tree;
|
|||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||||
import cn.hutool.core.util.ClassUtil;
|
import cn.hutool.core.util.ClassUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -107,15 +107,15 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
|
|||||||
// 构建树
|
// 构建树
|
||||||
return TreeUtils.build(list, treeNodeConfig, (node, tree) -> {
|
return TreeUtils.build(list, treeNodeConfig, (node, tree) -> {
|
||||||
// 转换器
|
// 转换器
|
||||||
tree.setId(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.value())));
|
tree.setId(ReflectUtil.invoke(node, CharSequenceUtil.genGetter(treeField.value())));
|
||||||
tree.setParentId(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.parentIdKey())));
|
tree.setParentId(ReflectUtil.invoke(node, CharSequenceUtil.genGetter(treeField.parentIdKey())));
|
||||||
tree.setName(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.nameKey())));
|
tree.setName(ReflectUtil.invoke(node, CharSequenceUtil.genGetter(treeField.nameKey())));
|
||||||
tree.setWeight(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.weightKey())));
|
tree.setWeight(ReflectUtil.invoke(node, CharSequenceUtil.genGetter(treeField.weightKey())));
|
||||||
if (!isSimple) {
|
if (!isSimple) {
|
||||||
List<Field> fieldList = ReflectUtils.getNonStaticFields(listClass);
|
List<Field> fieldList = ReflectUtils.getNonStaticFields(listClass);
|
||||||
fieldList.removeIf(f -> StrUtil.containsAnyIgnoreCase(f.getName(), treeField.value(), treeField
|
fieldList.removeIf(f -> CharSequenceUtil.containsAnyIgnoreCase(f.getName(), treeField.value(), treeField
|
||||||
.parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey()));
|
.parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey()));
|
||||||
fieldList.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, StrUtil.genGetter(f
|
fieldList.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, CharSequenceUtil.genGetter(f
|
||||||
.getName()))));
|
.getName()))));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -224,7 +224,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
|
|||||||
String checkProperty;
|
String checkProperty;
|
||||||
// 携带表别名则获取 . 后面的字段名
|
// 携带表别名则获取 . 后面的字段名
|
||||||
if (property.contains(StringConstants.DOT)) {
|
if (property.contains(StringConstants.DOT)) {
|
||||||
checkProperty = CollUtil.getLast(StrUtil.split(property, StringConstants.DOT));
|
checkProperty = CollUtil.getLast(CharSequenceUtil.split(property, StringConstants.DOT));
|
||||||
} else {
|
} else {
|
||||||
checkProperty = property;
|
checkProperty = property;
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
|
|||||||
.filter(field -> checkProperty.equals(field.getName()))
|
.filter(field -> checkProperty.equals(field.getName()))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
ValidationUtils.throwIf(optional.isEmpty(), "无效的排序字段 [{}]", property);
|
ValidationUtils.throwIf(optional.isEmpty(), "无效的排序字段 [{}]", property);
|
||||||
queryWrapper.orderBy(true, order.isAscending(), StrUtil.toUnderlineCase(property));
|
queryWrapper.orderBy(true, order.isAscending(), CharSequenceUtil.toUnderlineCase(property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.log.common.model;
|
package top.charles7c.continew.starter.log.common.model;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import top.charles7c.continew.starter.core.util.IpUtils;
|
import top.charles7c.continew.starter.core.util.IpUtils;
|
||||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||||
@@ -99,7 +99,7 @@ public class LogRequest {
|
|||||||
.map(Map.Entry::getValue)
|
.map(Map.Entry::getValue)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (StrUtil.isNotBlank(userAgentString)) {
|
if (CharSequenceUtil.isNotBlank(userAgentString)) {
|
||||||
this.browser = (includes.contains(Include.BROWSER)) ? ServletUtils.getBrowser(userAgentString) : null;
|
this.browser = (includes.contains(Include.BROWSER)) ? ServletUtils.getBrowser(userAgentString) : null;
|
||||||
this.os = (includes.contains(Include.OS)) ? ServletUtils.getOs(userAgentString) : null;
|
this.os = (includes.contains(Include.OS)) ? ServletUtils.getOs(userAgentString) : null;
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.log.httptracepro.handler;
|
package top.charles7c.continew.starter.log.httptracepro.handler;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||||
import io.swagger.v3.oas.annotations.Hidden;
|
import io.swagger.v3.oas.annotations.Hidden;
|
||||||
@@ -153,14 +153,14 @@ public class LogInterceptor implements HandlerInterceptor {
|
|||||||
*/
|
*/
|
||||||
private void logDescription(LogRecord logRecord, Log methodLog, HandlerMethod handlerMethod) {
|
private void logDescription(LogRecord logRecord, Log methodLog, HandlerMethod handlerMethod) {
|
||||||
// 例如:@Log("新增部门") -> 新增部门
|
// 例如:@Log("新增部门") -> 新增部门
|
||||||
if (null != methodLog && StrUtil.isNotBlank(methodLog.value())) {
|
if (null != methodLog && CharSequenceUtil.isNotBlank(methodLog.value())) {
|
||||||
logRecord.setDescription(methodLog.value());
|
logRecord.setDescription(methodLog.value());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 例如:@Operation(summary="新增部门") -> 新增部门
|
// 例如:@Operation(summary="新增部门") -> 新增部门
|
||||||
Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class);
|
Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class);
|
||||||
if (null != methodOperation) {
|
if (null != methodOperation) {
|
||||||
logRecord.setDescription(StrUtil.blankToDefault(methodOperation.summary(), "请在该接口方法上指定日志描述"));
|
logRecord.setDescription(CharSequenceUtil.blankToDefault(methodOperation.summary(), "请在该接口方法上指定日志描述"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,11 +174,11 @@ public class LogInterceptor implements HandlerInterceptor {
|
|||||||
*/
|
*/
|
||||||
private void logModule(LogRecord logRecord, Log methodLog, Log classLog, HandlerMethod handlerMethod) {
|
private void logModule(LogRecord logRecord, Log methodLog, Log classLog, HandlerMethod handlerMethod) {
|
||||||
// 例如:@Log(module = "部门管理") -> 部门管理
|
// 例如:@Log(module = "部门管理") -> 部门管理
|
||||||
if (null != methodLog && StrUtil.isNotBlank(methodLog.module())) {
|
if (null != methodLog && CharSequenceUtil.isNotBlank(methodLog.module())) {
|
||||||
logRecord.setModule(methodLog.module());
|
logRecord.setModule(methodLog.module());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (null != classLog && StrUtil.isNotBlank(classLog.module())) {
|
if (null != classLog && CharSequenceUtil.isNotBlank(classLog.module())) {
|
||||||
logRecord.setModule(classLog.module());
|
logRecord.setModule(classLog.module());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ public class LogInterceptor implements HandlerInterceptor {
|
|||||||
Tag classTag = handlerMethod.getBeanType().getDeclaredAnnotation(Tag.class);
|
Tag classTag = handlerMethod.getBeanType().getDeclaredAnnotation(Tag.class);
|
||||||
if (null != classTag) {
|
if (null != classTag) {
|
||||||
String name = classTag.name();
|
String name = classTag.name();
|
||||||
logRecord.setModule(StrUtil.blankToDefault(name, "请在该接口类上指定所属模块"));
|
logRecord.setModule(CharSequenceUtil.blankToDefault(name, "请在该接口类上指定所属模块"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.log.httptracepro.handler;
|
package top.charles7c.continew.starter.log.httptracepro.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.JakartaServletUtil;
|
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -53,7 +54,7 @@ public final class RecordableServletHttpRequest implements RecordableHttpRequest
|
|||||||
@Override
|
@Override
|
||||||
public URI getUrl() {
|
public URI getUrl() {
|
||||||
String queryString = request.getQueryString();
|
String queryString = request.getQueryString();
|
||||||
if (StrUtil.isBlank(queryString)) {
|
if (CharSequenceUtil.isBlank(queryString)) {
|
||||||
return URI.create(request.getRequestURL().toString());
|
return URI.create(request.getRequestURL().toString());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -89,7 +90,7 @@ public final class RecordableServletHttpRequest implements RecordableHttpRequest
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getParam() {
|
public Map<String, Object> getParam() {
|
||||||
String body = this.getBody();
|
String body = this.getBody();
|
||||||
return StrUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body)
|
return CharSequenceUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body)
|
||||||
? JSONUtil.toBean(body, Map.class)
|
? JSONUtil.toBean(body, Map.class)
|
||||||
: Collections.unmodifiableMap(request.getParameterMap());
|
: Collections.unmodifiableMap(request.getParameterMap());
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.log.httptracepro.handler;
|
package top.charles7c.continew.starter.log.httptracepro.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@@ -67,6 +68,6 @@ public final class RecordableServletHttpResponse implements RecordableHttpRespon
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getParam() {
|
public Map<String, Object> getParam() {
|
||||||
String body = this.getBody();
|
String body = this.getBody();
|
||||||
return StrUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body) ? JSONUtil.toBean(body, Map.class) : null;
|
return CharSequenceUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body) ? JSONUtil.toBean(body, Map.class) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ package top.charles7c.continew.starter.messaging.mail.util;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import jakarta.mail.MessagingException;
|
import jakarta.mail.MessagingException;
|
||||||
import jakarta.mail.internet.MimeMessage;
|
import jakarta.mail.internet.MimeMessage;
|
||||||
@@ -192,14 +192,14 @@ public class MailUtils {
|
|||||||
* @return 联系人列表
|
* @return 联系人列表
|
||||||
*/
|
*/
|
||||||
private static List<String> splitAddress(String addresses) {
|
private static List<String> splitAddress(String addresses) {
|
||||||
if (StrUtil.isBlank(addresses)) {
|
if (CharSequenceUtil.isBlank(addresses)) {
|
||||||
return new ArrayList<>(0);
|
return new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
List<String> result;
|
List<String> result;
|
||||||
if (StrUtil.contains(addresses, StringConstants.COMMA)) {
|
if (CharSequenceUtil.contains(addresses, StringConstants.COMMA)) {
|
||||||
result = StrUtil.splitTrim(addresses, StringConstants.COMMA);
|
result = CharSequenceUtil.splitTrim(addresses, StringConstants.COMMA);
|
||||||
} else if (StrUtil.contains(addresses, StringConstants.SEMICOLON)) {
|
} else if (CharSequenceUtil.contains(addresses, StringConstants.SEMICOLON)) {
|
||||||
result = StrUtil.splitTrim(addresses, StringConstants.SEMICOLON);
|
result = CharSequenceUtil.splitTrim(addresses, StringConstants.SEMICOLON);
|
||||||
} else {
|
} else {
|
||||||
result = CollUtil.newArrayList(addresses);
|
result = CollUtil.newArrayList(addresses);
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.security.password.autoconfigure;
|
package top.charles7c.continew.starter.security.password.autoconfigure;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -80,7 +80,8 @@ public class PasswordEncoderAutoConfiguration {
|
|||||||
if (CollUtil.isNotEmpty(passwordEncoderList)) {
|
if (CollUtil.isNotEmpty(passwordEncoderList)) {
|
||||||
passwordEncoderList.forEach(passwordEncoder -> {
|
passwordEncoderList.forEach(passwordEncoder -> {
|
||||||
String simpleName = passwordEncoder.getClass().getSimpleName();
|
String simpleName = passwordEncoder.getClass().getSimpleName();
|
||||||
encoders.put(StrUtil.removeSuffix(simpleName, "PasswordEncoder").toLowerCase(), passwordEncoder);
|
encoders.put(CharSequenceUtil.removeSuffix(simpleName, "PasswordEncoder")
|
||||||
|
.toLowerCase(), passwordEncoder);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
String encodingId = properties.getEncodingId();
|
String encodingId = properties.getEncodingId();
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.storage.local.autoconfigure;
|
package top.charles7c.continew.starter.storage.local.autoconfigure;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -57,10 +57,10 @@ public class LocalStorageAutoConfiguration implements WebMvcConfigurer {
|
|||||||
LocalStorageProperties.LocalStorageMapping mapping = mappingEntry.getValue();
|
LocalStorageProperties.LocalStorageMapping mapping = mappingEntry.getValue();
|
||||||
String pathPattern = mapping.getPathPattern();
|
String pathPattern = mapping.getPathPattern();
|
||||||
String location = mapping.getLocation();
|
String location = mapping.getLocation();
|
||||||
if (StrUtil.isBlank(location)) {
|
if (CharSequenceUtil.isBlank(location)) {
|
||||||
throw new IllegalArgumentException(String.format("Path pattern [%s] location is null.", pathPattern));
|
throw new IllegalArgumentException(String.format("Path pattern [%s] location is null.", pathPattern));
|
||||||
}
|
}
|
||||||
registry.addResourceHandler(StrUtil.appendIfMissing(pathPattern, StringConstants.PATH_PATTERN))
|
registry.addResourceHandler(CharSequenceUtil.appendIfMissing(pathPattern, StringConstants.PATH_PATTERN))
|
||||||
.addResourceLocations(!location.startsWith("file:")
|
.addResourceLocations(!location.startsWith("file:")
|
||||||
? String.format("file:%s", this.format(location))
|
? String.format("file:%s", this.format(location))
|
||||||
: this.format(location))
|
: this.format(location))
|
||||||
|
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.web.autoconfigure.exception;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.ConstraintViolation;
|
import jakarta.validation.ConstraintViolation;
|
||||||
import jakarta.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
@@ -99,7 +99,8 @@ public class GlobalExceptionHandler {
|
|||||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||||
public R<Void> handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e,
|
public R<Void> handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
String errorMsg = StrUtil.format("参数名:[{}],期望参数类型:[{}]", e.getName(), e.getParameter().getParameterType());
|
String errorMsg = CharSequenceUtil.format("参数名:[{}],期望参数类型:[{}]", e.getName(), e.getParameter()
|
||||||
|
.getParameterType());
|
||||||
log.warn("请求地址 [{}],参数转换失败,{}。", request.getRequestURI(), errorMsg, e);
|
log.warn("请求地址 [{}],参数转换失败,{}。", request.getRequestURI(), errorMsg, e);
|
||||||
return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg);
|
return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg);
|
||||||
}
|
}
|
||||||
@@ -110,7 +111,7 @@ public class GlobalExceptionHandler {
|
|||||||
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
||||||
public R<Void> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e, HttpServletRequest request) {
|
public R<Void> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e, HttpServletRequest request) {
|
||||||
log.warn("请求地址 [{}],上传文件失败,文件大小超过限制。", request.getRequestURI(), e);
|
log.warn("请求地址 [{}],上传文件失败,文件大小超过限制。", request.getRequestURI(), e);
|
||||||
String sizeLimit = StrUtil.subBetween(e.getMessage(), "The maximum size ", " for");
|
String sizeLimit = CharSequenceUtil.subBetween(e.getMessage(), "The maximum size ", " for");
|
||||||
String errorMsg = String.format("请上传小于 %sMB 的文件", NumberUtil.parseLong(sizeLimit) / 1024 / 1024);
|
String errorMsg = String.format("请上传小于 %sMB 的文件", NumberUtil.parseLong(sizeLimit) / 1024 / 1024);
|
||||||
return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg);
|
return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg);
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.starter.web.autoconfigure.trace;
|
package top.charles7c.continew.starter.web.autoconfigure.trace;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.yomahub.tlog.context.TLogContext;
|
import com.yomahub.tlog.context.TLogContext;
|
||||||
import jakarta.servlet.*;
|
import jakarta.servlet.*;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@@ -53,7 +53,7 @@ public class TLogServletFilter implements Filter {
|
|||||||
TLogWebCommon.loadInstance().preHandle(httpServletRequest);
|
TLogWebCommon.loadInstance().preHandle(httpServletRequest);
|
||||||
// 把 traceId 放入 response 的 header,为了方便有些人有这样的需求,从前端拿整条链路的 traceId
|
// 把 traceId 放入 response 的 header,为了方便有些人有这样的需求,从前端拿整条链路的 traceId
|
||||||
String headerName = traceProperties.getHeaderName();
|
String headerName = traceProperties.getHeaderName();
|
||||||
if (StrUtil.isNotBlank(headerName)) {
|
if (CharSequenceUtil.isNotBlank(headerName)) {
|
||||||
httpServletResponse.addHeader(headerName, TLogContext.getTraceId());
|
httpServletResponse.addHeader(headerName, TLogContext.getTraceId());
|
||||||
}
|
}
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.web.util;
|
package top.charles7c.continew.starter.web.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import jakarta.servlet.ServletContext;
|
import jakarta.servlet.ServletContext;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -55,7 +55,7 @@ public class SpringWebUtils {
|
|||||||
.getFieldValue(resourceHandlerMapping, "handlerMap");
|
.getFieldValue(resourceHandlerMapping, "handlerMap");
|
||||||
// 移除之前注册的映射
|
// 移除之前注册的映射
|
||||||
for (Map.Entry<String, String> entry : handlerMap.entrySet()) {
|
for (Map.Entry<String, String> entry : handlerMap.entrySet()) {
|
||||||
String pathPattern = StrUtil.appendIfMissing(entry.getKey(), StringConstants.PATH_PATTERN);
|
String pathPattern = CharSequenceUtil.appendIfMissing(entry.getKey(), StringConstants.PATH_PATTERN);
|
||||||
oldHandlerMap.remove(pathPattern);
|
oldHandlerMap.remove(pathPattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,10 +80,10 @@ public class SpringWebUtils {
|
|||||||
final ResourceHandlerRegistry resourceHandlerRegistry = new ResourceHandlerRegistry(applicationContext, servletContext, contentNegotiationManager, urlPathHelper);
|
final ResourceHandlerRegistry resourceHandlerRegistry = new ResourceHandlerRegistry(applicationContext, servletContext, contentNegotiationManager, urlPathHelper);
|
||||||
for (Map.Entry<String, String> entry : handlerMap.entrySet()) {
|
for (Map.Entry<String, String> entry : handlerMap.entrySet()) {
|
||||||
// 移除之前注册的映射
|
// 移除之前注册的映射
|
||||||
String pathPattern = StrUtil.appendIfMissing(entry.getKey(), StringConstants.PATH_PATTERN);
|
String pathPattern = CharSequenceUtil.appendIfMissing(entry.getKey(), StringConstants.PATH_PATTERN);
|
||||||
oldHandlerMap.remove(pathPattern);
|
oldHandlerMap.remove(pathPattern);
|
||||||
// 重新注册映射
|
// 重新注册映射
|
||||||
String resourceLocations = StrUtil.appendIfMissing(entry.getValue(), StringConstants.SLASH);
|
String resourceLocations = CharSequenceUtil.appendIfMissing(entry.getValue(), StringConstants.SLASH);
|
||||||
resourceHandlerRegistry.addResourceHandler(pathPattern).addResourceLocations("file:" + resourceLocations);
|
resourceHandlerRegistry.addResourceHandler(pathPattern).addResourceLocations("file:" + resourceLocations);
|
||||||
}
|
}
|
||||||
final Map<String, ?> additionalUrlMap = ReflectUtil
|
final Map<String, ?> additionalUrlMap = ReflectUtil
|
||||||
|
Reference in New Issue
Block a user