update 格式化全部代码
This commit is contained in:
+1
@@ -15,6 +15,7 @@ public interface RemoteConfigService {
|
||||
|
||||
/**
|
||||
* 获取注册开关
|
||||
*
|
||||
* @return true开启,false关闭
|
||||
*/
|
||||
boolean selectRegisterEnabled();
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ public interface RemotePermissionService {
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
Set<String> getRolePermission(Long userId);
|
||||
@@ -20,7 +20,7 @@ public interface RemotePermissionService {
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
Set<String> getMenuPermission(Long userId);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
+4
-5
@@ -1,14 +1,13 @@
|
||||
package org.dromara.system.api.domain.bo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.xss.Xss;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.xss.Xss;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.api.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.api.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package org.dromara.system.api.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@@ -146,7 +147,7 @@ public class LoginUser implements Serializable {
|
||||
if (userId == null) {
|
||||
throw new IllegalArgumentException("用户ID不能为空");
|
||||
}
|
||||
return userType + ":" + userId;
|
||||
return userType + StringUtils.COLON + userId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
package org.dromara.auth.config;
|
||||
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.CircleCaptcha;
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.captcha.ShearCaptcha;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* 验证码配置
|
||||
|
||||
@@ -17,7 +17,10 @@ import org.dromara.auth.service.SysLoginService;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.domain.model.LoginBody;
|
||||
import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
|
||||
@@ -3,11 +3,11 @@ package org.dromara.auth.listener;
|
||||
import cn.dev33.satoken.listener.SaTokenListener;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.auth.event.UserLoginSuccessEvent;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.auth.event.UserLoginSuccessEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.dromara.auth.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -14,7 +14,9 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.auth.form.RegisterBody;
|
||||
import org.dromara.auth.properties.CaptchaProperties;
|
||||
import org.dromara.auth.properties.UserPasswordProperties;
|
||||
import org.dromara.common.core.constant.*;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.enums.LoginType;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.dromara.auth.service.impl;
|
||||
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.dromara.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方授权策略
|
||||
*
|
||||
@@ -45,8 +46,8 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
||||
/**
|
||||
* 登录-第三方授权登录
|
||||
*
|
||||
* @param body 登录信息
|
||||
* @param client 客户端信息
|
||||
* @param body 登录信息
|
||||
* @param client 客户端信息
|
||||
*/
|
||||
@Override
|
||||
public LoginVo login(String body, RemoteClientVo client) {
|
||||
|
||||
+1
-1
@@ -3,10 +3,10 @@ package org.dromara.common.bus.config;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package org.dromara.common.bus.config;
|
||||
|
||||
import org.dromara.common.bus.redis.RedisMessageChannelBinder;
|
||||
import org.dromara.common.bus.redis.RedisBusHealthIndicator;
|
||||
import org.dromara.common.bus.redis.RedisMessageChannelBinder;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
+3
-7
@@ -4,21 +4,17 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.bus.config.RedisBusProperties;
|
||||
import org.redisson.api.RStream;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.api.stream.AutoClaimResult;
|
||||
import org.redisson.api.stream.StreamAddArgs;
|
||||
import org.redisson.api.stream.StreamCreateGroupArgs;
|
||||
import org.redisson.api.stream.StreamMessageId;
|
||||
import org.redisson.api.stream.StreamReadGroupArgs;
|
||||
import org.redisson.api.stream.*;
|
||||
import org.springframework.cloud.stream.binder.AbstractBinder;
|
||||
import org.springframework.cloud.stream.binder.Binding;
|
||||
import org.springframework.cloud.stream.binder.ConsumerProperties;
|
||||
import org.springframework.cloud.stream.binder.ProducerProperties;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -71,7 +67,7 @@ public class RedisMessageChannelBinder extends AbstractBinder<MessageChannel, Co
|
||||
Assert.isInstanceOf(SubscribableChannel.class, outboundBindTarget, "Redis bus producer requires a SubscribableChannel");
|
||||
RStream<String, Object> stream = redissonClient.getStream(buildStreamName(name));
|
||||
MessageHandler handler = message -> stream.add(StreamAddArgs.<String, Object>entry(
|
||||
MESSAGE_FIELD, new RedisBusMessage(message.getPayload(), new HashMap<>(message.getHeaders())))
|
||||
MESSAGE_FIELD, new RedisBusMessage(message.getPayload(), new HashMap<>(message.getHeaders())))
|
||||
.trimNonStrict().maxLen(properties.getStreamMaxLen()).noLimit());
|
||||
((SubscribableChannel) outboundBindTarget).subscribe(handler);
|
||||
log.info("Redis bus producer bound to stream: {}", name);
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public interface SystemConstants {
|
||||
/**
|
||||
* 排除敏感属性字段
|
||||
*/
|
||||
String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
|
||||
String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ public interface PermissionService {
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
Set<String> getRolePermission(Long userId);
|
||||
@@ -20,7 +20,7 @@ public interface PermissionService {
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
Set<String> getMenuPermission(Long userId);
|
||||
|
||||
+14
-12
@@ -2,6 +2,8 @@ package org.dromara.common.core.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.dromara.common.core.enums.FormatsType;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
@@ -19,15 +21,16 @@ import java.util.concurrent.TimeUnit;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
/**
|
||||
* 日期解析格式集合。
|
||||
*/
|
||||
private static final String[] PARSE_PATTERNS = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
|
||||
@Deprecated
|
||||
private DateUtils() {
|
||||
}
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前日期和时间
|
||||
@@ -124,7 +127,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定 LocalDateTime 格式化为 YYYY-MM-DD HH:MM:SS 格式的字符串
|
||||
* 将 LocalDateTime 格式化为 YYYY-MM-DD HH:MM:SS 格式的字符串
|
||||
*
|
||||
* @param dateTime 要格式化的 LocalDateTime 对象
|
||||
* @return 格式化后的日期时间字符串
|
||||
@@ -264,12 +267,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
* @return 时间差字符串,格式为 "x天 x小时 x分钟 x秒",若为 0 则不显示
|
||||
*/
|
||||
public static String getTimeDifference(LocalDateTime endDate, LocalDateTime nowDate) {
|
||||
Duration duration = Duration.between(nowDate, endDate);
|
||||
long day = duration.toDays();
|
||||
long hour = duration.toHours() % 24;
|
||||
long min = duration.toMinutes() % 60;
|
||||
long sec = duration.toSeconds() % 60;
|
||||
// 构建时间差字符串,条件是值不为0才显示
|
||||
long diffInMillis = java.time.Duration.between(nowDate, endDate).toMillis();
|
||||
long day = TimeUnit.MILLISECONDS.toDays(diffInMillis);
|
||||
long hour = TimeUnit.MILLISECONDS.toHours(diffInMillis) % 24;
|
||||
long min = TimeUnit.MILLISECONDS.toMinutes(diffInMillis) % 60;
|
||||
long sec = TimeUnit.MILLISECONDS.toSeconds(diffInMillis) % 60;
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (day > 0) {
|
||||
result.append(String.format("%d天 ", day));
|
||||
|
||||
+2
-2
@@ -86,7 +86,7 @@ public class NetUtils extends NetUtil {
|
||||
/**
|
||||
* 匹配IP规则,支持精确值、通配符与CIDR。
|
||||
*
|
||||
* @param rule IP规则
|
||||
* @param rule IP规则
|
||||
* @param clientIp 客户端IP
|
||||
* @return 是否匹配
|
||||
*/
|
||||
@@ -114,7 +114,7 @@ public class NetUtils extends NetUtil {
|
||||
/**
|
||||
* 匹配CIDR网段。
|
||||
*
|
||||
* @param cidr CIDR规则
|
||||
* @param cidr CIDR规则
|
||||
* @param clientIp 客户端IP
|
||||
* @return 是否命中
|
||||
*/
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class ObjectUtils extends ObjectUtil {
|
||||
/**
|
||||
* 如果对象不为空,则获取对象中的某个字段 ObjectUtils.notNullGetter(user, User::getName);
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param obj 对象
|
||||
* @param func 获取方法
|
||||
* @return 对象字段
|
||||
*/
|
||||
|
||||
+7
-6
@@ -60,7 +60,7 @@ public class StreamUtils {
|
||||
* @return 找到符合条件的第一个元素,没有则返回 null
|
||||
*/
|
||||
public static <E> E findFirstValue(Collection<E> collection, Predicate<E> function) {
|
||||
return findFirst(collection,function).orElse(null);
|
||||
return findFirst(collection, function).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class StreamUtils {
|
||||
* @return 找到符合条件的任意一个元素,没有则返回null
|
||||
*/
|
||||
public static <E> E findAnyValue(Collection<E> collection, Predicate<E> function) {
|
||||
return findAny(collection,function).orElse(null);
|
||||
return findAny(collection, function).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,11 +179,12 @@ public class StreamUtils {
|
||||
|
||||
/**
|
||||
* 获取 map 中的数据作为新 Map 的 value ,key 不变
|
||||
* @param map 需要处理的map
|
||||
*
|
||||
* @param map 需要处理的map
|
||||
* @param take 取值函数
|
||||
* @param <K> map中的key类型
|
||||
* @param <E> map中的value类型
|
||||
* @param <V> 新map中的value类型
|
||||
* @param <K> map中的key类型
|
||||
* @param <E> map中的value类型
|
||||
* @param <V> 新map中的value类型
|
||||
* @return 新的map
|
||||
*/
|
||||
public static <K, E, V> Map<K, V> toMap(Map<K, E> map, BiFunction<K, E, V> take) {
|
||||
|
||||
+14
-5
@@ -23,6 +23,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
|
||||
public static final String SLASH = "/";
|
||||
|
||||
public static final String COLON = ":";
|
||||
|
||||
private static final AntPathMatcher ANT_PATH_MATCHER = new AntPathMatcher();
|
||||
|
||||
@Deprecated
|
||||
@@ -363,6 +365,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将可迭代对象中的元素使用逗号拼接成字符串
|
||||
*
|
||||
@@ -397,7 +400,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
/**
|
||||
* 判断字符串是否在指定的字符串列表中
|
||||
*
|
||||
* @param string 字符串
|
||||
* @param string 字符串
|
||||
* @param searchStrings 字符串列表
|
||||
* @return 是否在列表中
|
||||
*/
|
||||
@@ -408,7 +411,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
/**
|
||||
* 忽略大小写判断字符串是否在指定的字符串列表中
|
||||
*
|
||||
* @param string 字符串
|
||||
* @param string 字符串
|
||||
* @param searchStrings 字符串列表
|
||||
* @return 是否在列表中
|
||||
*/
|
||||
@@ -499,8 +502,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
/**
|
||||
* 移除字符串中的指定字符序列。
|
||||
*
|
||||
* @param str 要处理的字符串,不能为null
|
||||
* @param remove 要移除的字符序列,不能为null
|
||||
* @param str 要处理的字符串,不能为null
|
||||
* @param remove 要移除的字符序列,不能为null
|
||||
* @return 处理后的字符串
|
||||
*/
|
||||
public static String remove(final String str, final String remove) {
|
||||
@@ -548,7 +551,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return Strings.CS.containsAny(cs, searchCharSequences);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将一个字符串替换为较大字符串内的另一个字符串,一次
|
||||
*/
|
||||
@@ -563,4 +565,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return Strings.CS.endsWithAny(sequence, searchStrings);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 CharSequence 是否以指定的后缀结尾。
|
||||
*/
|
||||
public static boolean endsWith(final CharSequence str, final CharSequence suffix) {
|
||||
return Strings.CS.endsWith(str, suffix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -6,7 +6,10 @@ import lombok.NoArgsConstructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
||||
+80
-4
@@ -1,30 +1,65 @@
|
||||
package org.dromara.common.core.utils.file;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 媒体类型工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MimeTypeUtils {
|
||||
|
||||
/**
|
||||
* PNG 图片 MIME 类型
|
||||
*/
|
||||
public static final String IMAGE_PNG = "image/png";
|
||||
|
||||
/**
|
||||
* JPG 图片 MIME 类型
|
||||
*/
|
||||
public static final String IMAGE_JPG = "image/jpg";
|
||||
|
||||
/**
|
||||
* JPEG 图片 MIME 类型
|
||||
*/
|
||||
public static final String IMAGE_JPEG = "image/jpeg";
|
||||
|
||||
/**
|
||||
* BMP 图片 MIME 类型
|
||||
*/
|
||||
public static final String IMAGE_BMP = "image/bmp";
|
||||
|
||||
/**
|
||||
* GIF 图片 MIME 类型
|
||||
*/
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
|
||||
/**
|
||||
* 图片扩展名数组
|
||||
*/
|
||||
public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"};
|
||||
|
||||
/**
|
||||
* Flash 文件扩展名数组
|
||||
*/
|
||||
public static final String[] FLASH_EXTENSION = {"swf", "flv"};
|
||||
|
||||
public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
|
||||
"asf", "rm", "rmvb"};
|
||||
|
||||
/**
|
||||
* 视频文件扩展名数组
|
||||
*/
|
||||
public static final String[] VIDEO_EXTENSION = {"mp4", "avi", "rmvb"};
|
||||
|
||||
/**
|
||||
* 媒体文件扩展名数组(音频+视频+Flash)
|
||||
*/
|
||||
public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", "asf", "rm", "rmvb"};
|
||||
|
||||
/**
|
||||
* 默认允许上传的文件扩展名数组
|
||||
*/
|
||||
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
|
||||
// 图片
|
||||
"bmp", "gif", "jpg", "jpeg", "png",
|
||||
@@ -35,6 +70,47 @@ public class MimeTypeUtils {
|
||||
// 视频格式
|
||||
"mp4", "avi", "rmvb",
|
||||
// pdf
|
||||
"pdf"};
|
||||
"pdf"
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断文件扩展名是否为图片格式(忽略大小写)
|
||||
*
|
||||
* @param extension 文件扩展名
|
||||
* @return 是图片返回 true,否则返回 false
|
||||
*/
|
||||
public static boolean isImage(String extension) {
|
||||
return StrUtil.equalsAnyIgnoreCase(extension, IMAGE_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件扩展名是否为视频格式(忽略大小写)
|
||||
*
|
||||
* @param extension 文件扩展名
|
||||
* @return 是视频返回 true,否则返回 false
|
||||
*/
|
||||
public static boolean isVideo(String extension) {
|
||||
return StrUtil.equalsAnyIgnoreCase(extension, VIDEO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件扩展名是否为媒体格式(忽略大小写)
|
||||
*
|
||||
* @param extension 文件扩展名
|
||||
* @return 是媒体返回 true,否则返回 false
|
||||
*/
|
||||
public static boolean isMedia(String extension) {
|
||||
return StrUtil.equalsAnyIgnoreCase(extension, MEDIA_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件扩展名是否在默认允许上传范围内(忽略大小写)
|
||||
*
|
||||
* @param extension 文件扩展名
|
||||
* @return 允许返回 true,不允许返回 false
|
||||
*/
|
||||
public static boolean isDefaultAllowed(String extension) {
|
||||
return StrUtil.equalsAnyIgnoreCase(extension, DEFAULT_ALLOWED_EXTENSION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class AddressUtils {
|
||||
*/
|
||||
public static String getRealAddressByIP(String ip) {
|
||||
// 处理空串并过滤HTML标签
|
||||
ip = HtmlUtil.cleanHtmlTag(StringUtils.blankToDefault(ip,""));
|
||||
ip = HtmlUtil.cleanHtmlTag(StringUtils.blankToDefault(ip, ""));
|
||||
// 判断是否为IPv4
|
||||
boolean isIPv4 = NetUtils.isIPv4(ip);
|
||||
// 判断是否为IPv6
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ public final class AnnotationUtils extends AnnotationUtil {
|
||||
/**
|
||||
* 获取指定注解
|
||||
*
|
||||
* @param annotationEle {@link AnnotatedElement},可以是Class、Method、Field、Constructor、ReflectPermission
|
||||
* @param annotationEle {@link AnnotatedElement},可以是Class、Method、Field、Constructor、ReflectPermission
|
||||
* @param annotationTypeName 注解类型名称
|
||||
* @return 注解对象
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ public final class AnnotationUtils extends AnnotationUtil {
|
||||
/**
|
||||
* 获取指定注解中所有属性值
|
||||
*
|
||||
* @param annotationEle {@link AnnotatedElement},可以是Class、Method、Field、Constructor、ReflectPermission
|
||||
* @param annotationEle {@link AnnotatedElement},可以是Class、Method、Field、Constructor、ReflectPermission
|
||||
* @param annotationTypeName 注解类型名称
|
||||
* @return 注解对象所有属性键值
|
||||
* @throws UtilException 调用注解中的方法时执行异常
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package org.dromara.common.core.utils.reflect;
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
||||
+4
-1
@@ -2,13 +2,16 @@ package org.dromara.common.core.utils.regex;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.constant.RegexConstants;
|
||||
|
||||
/**
|
||||
* 正则相关工具类
|
||||
*
|
||||
* @author Feng
|
||||
* @author AprilWind
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class RegexUtils extends ReUtil {
|
||||
|
||||
/**
|
||||
|
||||
+4
-1
@@ -2,6 +2,8 @@ package org.dromara.common.core.utils.regex;
|
||||
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.factory.RegexPatternPoolFactory;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
@@ -10,8 +12,9 @@ import java.util.regex.Pattern;
|
||||
* 正则字段校验器
|
||||
* 主要验证字段非空、是否为满足指定格式等
|
||||
*
|
||||
* @author Feng
|
||||
* @author AprilWind
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class RegexValidator extends Validator {
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.dromara.common.core.xss;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ package org.dromara.common.core.xss;
|
||||
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
+4
-1
@@ -29,7 +29,10 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.boot.web.server.autoconfigure.ServerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 接口文档配置
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class SpringDocProperties {
|
||||
* </p>
|
||||
*
|
||||
* @see io.swagger.v3.oas.models.info.Info
|
||||
*
|
||||
* <p>
|
||||
* 为了 springboot 自动生产配置提示信息,所以这里复制一个类出来
|
||||
*/
|
||||
@Data
|
||||
|
||||
+2
-1
@@ -86,7 +86,7 @@ public class SaTokenSecurityMetadata {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
if (!ignore && permissions.isEmpty() && roles.isEmpty()){
|
||||
if (!ignore && permissions.isEmpty() && roles.isEmpty()) {
|
||||
sb.append("> **权限策略**:需要登录<br><br>");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -162,6 +162,7 @@ public class SaTokenSecurityMetadata {
|
||||
|
||||
/**
|
||||
* 重写mode的获取方法,返回符号而非文字
|
||||
*
|
||||
* @return AND→&,OR→|,默认→&
|
||||
*/
|
||||
public String getModeSymbol() {
|
||||
|
||||
+29
-18
@@ -46,76 +46,84 @@ public abstract class AbstractMetadataJavadocResolver<M> implements JavadocResol
|
||||
|
||||
/**
|
||||
* 执行解析并返回解析到的 Javadoc 内容
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param operation Swagger Operation实例
|
||||
* @param metadata 元信息
|
||||
* @param operation Swagger Operation实例
|
||||
* @param metadata 元信息
|
||||
* @return 解析到的 Javadoc 内容
|
||||
*/
|
||||
public abstract String resolve(HandlerMethod handlerMethod, Operation operation, M metadata);
|
||||
|
||||
/**
|
||||
* 检查处理器方法所属的类上是否存在注解
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClass 注解类
|
||||
* @return 是否存在注解
|
||||
*/
|
||||
public boolean hasClassAnnotation(HandlerMethod handlerMethod,Class<? extends Annotation> annotationClass){
|
||||
public boolean hasClassAnnotation(HandlerMethod handlerMethod, Class<? extends Annotation> annotationClass) {
|
||||
return AnnotationUtil.hasAnnotation(handlerMethod.getBeanType(), annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查处理器方法所属的类上是否存在注解
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationTypeName 注解类名称
|
||||
* @return 是否存在注解
|
||||
*/
|
||||
public boolean hasClassAnnotation(HandlerMethod handlerMethod, String annotationTypeName){
|
||||
public boolean hasClassAnnotation(HandlerMethod handlerMethod, String annotationTypeName) {
|
||||
return AnnotationUtil.hasAnnotation(handlerMethod.getBeanType(), annotationTypeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查处理器方法上是否存在注解
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClass 注解类
|
||||
* @return 是否存在注解
|
||||
*/
|
||||
public boolean hasMethodAnnotation(HandlerMethod handlerMethod,Class<? extends Annotation> annotationClass){
|
||||
public boolean hasMethodAnnotation(HandlerMethod handlerMethod, Class<? extends Annotation> annotationClass) {
|
||||
return AnnotationUtil.hasAnnotation(handlerMethod.getMethod(), annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查处理器方法上是否存在注解
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationTypeName 注解类名称
|
||||
* @return 是否存在注解
|
||||
*/
|
||||
public boolean hasMethodAnnotation(HandlerMethod handlerMethod, String annotationTypeName){
|
||||
public boolean hasMethodAnnotation(HandlerMethod handlerMethod, String annotationTypeName) {
|
||||
return AnnotationUtil.hasAnnotation(handlerMethod.getMethod(), annotationTypeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查处理器方法上是否存在注解
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClass 注解类
|
||||
* @return 是否存在注解
|
||||
*/
|
||||
public boolean hasAnnotation(HandlerMethod handlerMethod,Class<? extends Annotation> annotationClass){
|
||||
public boolean hasAnnotation(HandlerMethod handlerMethod, Class<? extends Annotation> annotationClass) {
|
||||
return this.hasClassAnnotation(handlerMethod, annotationClass) || this.hasMethodAnnotation(handlerMethod, annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查处理器方法上是否存在注解
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationTypeName 注解类名称
|
||||
* @return 是否存在注解
|
||||
*/
|
||||
public boolean hasAnnotation(HandlerMethod handlerMethod, String annotationTypeName){
|
||||
public boolean hasAnnotation(HandlerMethod handlerMethod, String annotationTypeName) {
|
||||
return this.hasClassAnnotation(handlerMethod, annotationTypeName) || this.hasMethodAnnotation(handlerMethod, annotationTypeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取处理器方法所属类上的注解的值
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClass 注解类
|
||||
* @return 注解的值
|
||||
*/
|
||||
@@ -125,7 +133,8 @@ public abstract class AbstractMetadataJavadocResolver<M> implements JavadocResol
|
||||
|
||||
/**
|
||||
* 获取处理器方法所属类上的注解的值
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClassName 注解类名称
|
||||
* @return 注解的值
|
||||
*/
|
||||
@@ -137,7 +146,8 @@ public abstract class AbstractMetadataJavadocResolver<M> implements JavadocResol
|
||||
|
||||
/**
|
||||
* 获取处理器方法上的注解的值
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClass 注解类
|
||||
* @return 注解的值
|
||||
*/
|
||||
@@ -147,7 +157,8 @@ public abstract class AbstractMetadataJavadocResolver<M> implements JavadocResol
|
||||
|
||||
/**
|
||||
* 获取处理器方法所属类上的注解的值
|
||||
* @param handlerMethod 处理器方法
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param annotationClassName 注解类名称
|
||||
* @return 注解的值
|
||||
*/
|
||||
|
||||
+3
-1
@@ -15,6 +15,7 @@ public interface JavadocResolver extends Comparable<JavadocResolver>, Ordered {
|
||||
|
||||
/**
|
||||
* 检查解析器是否支持解析 HandlerMethod
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @return 是否支持解析
|
||||
*/
|
||||
@@ -22,8 +23,9 @@ public interface JavadocResolver extends Comparable<JavadocResolver>, Ordered {
|
||||
|
||||
/**
|
||||
* 执行解析并返回解析到的 Javadoc 内容
|
||||
*
|
||||
* @param handlerMethod 处理器方法
|
||||
* @param operation Swagger Operation实例
|
||||
* @param operation Swagger Operation实例
|
||||
* @return 解析到的 Javadoc 内容
|
||||
*/
|
||||
String resolve(HandlerMethod handlerMethod, Operation operation);
|
||||
|
||||
+7
-7
@@ -59,11 +59,11 @@ public class SaTokenAnnotationMetadataJavadocResolver extends AbstractMetadataJa
|
||||
}
|
||||
|
||||
public SaTokenAnnotationMetadataJavadocResolver(int order) {
|
||||
this(DEFAULT_METADATA_PROVIDER,order);
|
||||
this(DEFAULT_METADATA_PROVIDER, order);
|
||||
}
|
||||
|
||||
public SaTokenAnnotationMetadataJavadocResolver(Supplier<SaTokenSecurityMetadata> metadataProvider, int order) {
|
||||
super(metadataProvider,order);
|
||||
super(metadataProvider, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +74,7 @@ public class SaTokenAnnotationMetadataJavadocResolver extends AbstractMetadataJa
|
||||
@Override
|
||||
public String resolve(HandlerMethod handlerMethod, Operation operation, SaTokenSecurityMetadata metadata) {
|
||||
// 检查是否忽略校验
|
||||
if(hasAnnotation(handlerMethod, SA_IGNORE_CLASS_NAME)){
|
||||
if (hasAnnotation(handlerMethod, SA_IGNORE_CLASS_NAME)) {
|
||||
metadata.setIgnore(true);
|
||||
return metadata.toMarkdownString();
|
||||
}
|
||||
@@ -109,10 +109,10 @@ public class SaTokenAnnotationMetadataJavadocResolver extends AbstractMetadataJa
|
||||
private void resolvePermissionAnnotation(SaTokenSecurityMetadata metadata, Map<String, Object> annotationValueMap) {
|
||||
try {
|
||||
// 反射获取注解属性
|
||||
Object value = annotationValueMap.get( "value");
|
||||
Object mode = annotationValueMap.get( "mode");
|
||||
Object type = annotationValueMap.get( "type");
|
||||
Object orRole = annotationValueMap.get( "orRole");
|
||||
Object value = annotationValueMap.get("value");
|
||||
Object mode = annotationValueMap.get("mode");
|
||||
Object type = annotationValueMap.get("type");
|
||||
Object orRole = annotationValueMap.get("orRole");
|
||||
|
||||
String[] values = Convert.toStrArray(value);
|
||||
String modeStr = mode != null ? mode.toString() : "AND";
|
||||
|
||||
+1
-1
@@ -231,7 +231,7 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
if (javadocProvider.isPresent()) {
|
||||
String description = javadocProvider.get().getMethodJavadocDescription(handlerMethod.getMethod());
|
||||
String summary = javadocProvider.get().getFirstSentence(description);
|
||||
if (StringUtils.isNotBlank(description)){
|
||||
if (StringUtils.isNotBlank(description)) {
|
||||
operation.setSummary(summary);
|
||||
}
|
||||
// 调用解析器提取JavaDoc中的权限信息
|
||||
|
||||
+8
-10
@@ -44,23 +44,21 @@ public class RedissonMetadataReport extends AbstractMetadataReport {
|
||||
// Lua script for atomic CAS on a hash field:
|
||||
// If the current value equals ticket (or field is absent, or ticket is empty), update and return 1; else return 0.
|
||||
private static final String CAS_LUA = """
|
||||
local old = redis.call('HGET', KEYS[1], ARGV[1])
|
||||
if old == false or ARGV[3] == '' or old == ARGV[3] then
|
||||
redis.call('HSET', KEYS[1], ARGV[1], ARGV[2])
|
||||
return 1
|
||||
end
|
||||
return 0""";
|
||||
local old = redis.call('HGET', KEYS[1], ARGV[1])
|
||||
if old == false or ARGV[3] == '' or old == ARGV[3] then
|
||||
redis.call('HSET', KEYS[1], ARGV[1], ARGV[2])
|
||||
return 1
|
||||
end
|
||||
return 0""";
|
||||
|
||||
private final String root;
|
||||
private final long ttlMs;
|
||||
|
||||
// Lazily initialized — Dubbo SPI creates this class before Spring is fully ready
|
||||
private volatile RedissonClient redissonClient;
|
||||
|
||||
// topic key → RTopic (keeps the subscription alive)
|
||||
private final ConcurrentHashMap<String, RTopic> topicMap = new ConcurrentHashMap<>();
|
||||
// serviceKey → listeners (for dispatching mapping change events)
|
||||
private final ConcurrentHashMap<String, Set<MappingListener>> listenerMap = new ConcurrentHashMap<>();
|
||||
// Lazily initialized — Dubbo SPI creates this class before Spring is fully ready
|
||||
private volatile RedissonClient redissonClient;
|
||||
|
||||
public RedissonMetadataReport(URL url) {
|
||||
super(url);
|
||||
|
||||
+7
-7
@@ -12,15 +12,15 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
*/
|
||||
public class ActuatorEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
String enable = environment.getProperty("easy-es.enable", "false");
|
||||
System.setProperty("management.health.elasticsearch.enabled", enable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,9 +25,9 @@ public class ApiDecryptAutoConfiguration {
|
||||
/**
|
||||
* 注册 API 加解密过滤器。
|
||||
*
|
||||
* @param properties API 解密配置
|
||||
* @param properties API 解密配置
|
||||
* @param requestMappingHandlerMapping 请求映射处理器
|
||||
* @param handlerExceptionResolver 异常处理器
|
||||
* @param handlerExceptionResolver 异常处理器
|
||||
* @return API 加解密过滤器
|
||||
*/
|
||||
@Bean
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class EncryptorAutoConfiguration {
|
||||
/**
|
||||
* 创建加密字段处理器。
|
||||
*
|
||||
* @param encryptorManager 加解密管理器
|
||||
* @param encryptorManager 加解密管理器
|
||||
* @param encryptContextFactory 加密上下文工厂
|
||||
* @return 加密字段处理器
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package org.dromara.common.encrypt.core;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.encrypt.enums.AlgorithmType;
|
||||
import org.dromara.common.encrypt.enums.EncodeType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 加密上下文 用于encryptor传递必要的参数。
|
||||
|
||||
+2
-10
@@ -6,15 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 加密字段处理器。
|
||||
@@ -31,7 +23,7 @@ public class EncryptedFieldProcessor {
|
||||
* 构造加密字段处理器。
|
||||
*
|
||||
* @param encryptorManager 加解密管理器
|
||||
* @param contextFactory 加密上下文工厂
|
||||
* @param contextFactory 加密上下文工厂
|
||||
*/
|
||||
public EncryptedFieldProcessor(EncryptorManager encryptorManager, EncryptContextFactory contextFactory) {
|
||||
this.encryptorManager = encryptorManager;
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public interface IEncryptor {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param value 待加密字符串
|
||||
* @param value 待加密字符串
|
||||
* @return 解密后的字符串
|
||||
*/
|
||||
String decrypt(String value);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class AesEncryptor extends AbstractEncryptor {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param value 待加密字符串
|
||||
* @param value 待加密字符串
|
||||
*/
|
||||
@Override
|
||||
public String decrypt(String value) {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class Base64Encryptor extends AbstractEncryptor {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param value 待加密字符串
|
||||
* @param value 待加密字符串
|
||||
*/
|
||||
@Override
|
||||
public String decrypt(String value) {
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class RsaEncryptor extends AbstractEncryptor {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param value 待加密字符串
|
||||
* @param value 待加密字符串
|
||||
*/
|
||||
@Override
|
||||
public String decrypt(String value) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class Sm2Encryptor extends AbstractEncryptor {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param value 待加密字符串
|
||||
* @param value 待加密字符串
|
||||
*/
|
||||
@Override
|
||||
public String decrypt(String value) {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class Sm4Encryptor extends AbstractEncryptor {
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param value 待加密字符串
|
||||
* @param value 待加密字符串
|
||||
*/
|
||||
@Override
|
||||
public String decrypt(String value) {
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package org.dromara.common.encrypt.enums;
|
||||
|
||||
import org.dromara.common.encrypt.core.encryptor.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.dromara.common.encrypt.core.encryptor.*;
|
||||
|
||||
/**
|
||||
* 算法名称
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@ public class CryptoFilter implements Filter {
|
||||
/**
|
||||
* 构造加解密过滤器。
|
||||
*
|
||||
* @param properties API 解密配置
|
||||
* @param properties API 解密配置
|
||||
* @param requestMappingHandlerMapping 请求映射处理器
|
||||
* @param handlerExceptionResolver 异常处理器
|
||||
* @param handlerExceptionResolver 异常处理器
|
||||
*/
|
||||
public CryptoFilter(ApiDecryptProperties properties,
|
||||
RequestMappingHandlerMapping requestMappingHandlerMapping,
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class DecryptRequestBodyWrapper extends HttpServletRequestWrapper {
|
||||
/**
|
||||
* 解密请求体并缓存为可重复读取的 JSON 请求体。
|
||||
*
|
||||
* @param request 原始请求
|
||||
* @param request 原始请求
|
||||
* @param privateKey RSA 私钥
|
||||
* @param headerFlag 加密密钥请求头
|
||||
* @throws IOException 读取请求体异常
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* api解密属性配置类
|
||||
*
|
||||
* @author wdhcr
|
||||
*/
|
||||
@Data
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package org.dromara.common.encrypt.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.encrypt.enums.AlgorithmType;
|
||||
import org.dromara.common.encrypt.enums.EncodeType;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -259,9 +259,9 @@ public class EncryptUtils {
|
||||
/**
|
||||
* SM2公钥验签(Hex编码)
|
||||
*
|
||||
* @param dataHex 原文数据(Hex编码)
|
||||
* @param signHex 签名值(Hex编码)
|
||||
* @param publicKey 公钥
|
||||
* @param dataHex 原文数据(Hex编码)
|
||||
* @param signHex 签名值(Hex编码)
|
||||
* @param publicKey 公钥
|
||||
* @return true-验签成功,false-验签失败
|
||||
*/
|
||||
public static boolean verifySm2SignHex(String dataHex, String signHex, String publicKey) {
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@ import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* excel 列单元格合并(合并列相同项)
|
||||
*
|
||||
* <p>
|
||||
* 需搭配 {@link CellMergeStrategy} 策略使用
|
||||
*
|
||||
* @author Lion Li
|
||||
@@ -16,10 +16,10 @@ import java.lang.annotation.*;
|
||||
@Inherited
|
||||
public @interface CellMerge {
|
||||
|
||||
/**
|
||||
* col index
|
||||
*/
|
||||
int index() default -1;
|
||||
/**
|
||||
* col index
|
||||
*/
|
||||
int index() default -1;
|
||||
|
||||
/**
|
||||
* 合并需要依赖的其他字段名称
|
||||
|
||||
+1
@@ -7,6 +7,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 批注
|
||||
*
|
||||
* @author guzhouyanyu
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
*
|
||||
* @author guzhouyanyu
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package org.dromara.common.excel.convert;
|
||||
import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fesod.sheet.converters.Converter;
|
||||
import org.apache.fesod.sheet.enums.CellDataTypeEnum;
|
||||
import org.apache.fesod.sheet.metadata.GlobalConfiguration;
|
||||
@@ -13,7 +13,7 @@ import org.apache.fesod.sheet.metadata.property.ExcelContentProperty;
|
||||
import org.dromara.common.core.service.DictService;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
+1
-1
@@ -3,6 +3,7 @@ package org.dromara.common.excel.convert;
|
||||
import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fesod.sheet.converters.Converter;
|
||||
import org.apache.fesod.sheet.enums.CellDataTypeEnum;
|
||||
import org.apache.fesod.sheet.metadata.GlobalConfiguration;
|
||||
@@ -11,7 +12,6 @@ import org.apache.fesod.sheet.metadata.data.WriteCellData;
|
||||
import org.apache.fesod.sheet.metadata.property.ExcelContentProperty;
|
||||
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||
import org.dromara.common.excel.annotation.ExcelEnumFormat;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
||||
+3
-1
@@ -3,10 +3,10 @@ package org.dromara.common.excel.core;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.fesod.sheet.annotation.ExcelIgnore;
|
||||
import org.apache.fesod.sheet.annotation.ExcelIgnoreUnannotated;
|
||||
import org.apache.fesod.sheet.annotation.ExcelProperty;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||
import org.dromara.common.excel.annotation.CellMerge;
|
||||
@@ -29,6 +29,7 @@ public class CellMergeHandler {
|
||||
// 行合并开始下标
|
||||
this.rowIndex = hasTitle ? 1 : 0;
|
||||
}
|
||||
|
||||
private CellMergeHandler(final boolean hasTitle, final int rowIndex) {
|
||||
this.hasTitle = hasTitle;
|
||||
this.rowIndex = hasTitle ? rowIndex : 0;
|
||||
@@ -187,6 +188,7 @@ public class CellMergeHandler {
|
||||
return new FieldColumnIndex(colIndex, cellMerge);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个单元格合并处理器实例
|
||||
*
|
||||
|
||||
+5
-5
@@ -1,6 +1,10 @@
|
||||
package org.dromara.common.excel.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fesod.sheet.context.AnalysisContext;
|
||||
import org.apache.fesod.sheet.event.AnalysisEventListener;
|
||||
import org.apache.fesod.sheet.exception.ExcelAnalysisException;
|
||||
@@ -8,10 +12,6 @@ import org.apache.fesod.sheet.exception.ExcelDataConvertException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -59,7 +59,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
|
||||
* 构造 Excel 导入监听器。
|
||||
*
|
||||
* @param isValidate 是否执行 Validator 校验
|
||||
* @param failFast 发生异常时是否立即终止读取
|
||||
* @param failFast 发生异常时是否立即终止读取
|
||||
*/
|
||||
public DefaultExcelListener(boolean isValidate, boolean failFast) {
|
||||
this.isValidate = isValidate;
|
||||
|
||||
+5
@@ -25,23 +25,28 @@ import java.util.stream.Collectors;
|
||||
@NoArgsConstructor
|
||||
@SuppressWarnings("unused")
|
||||
public class DropDownOptions {
|
||||
|
||||
/**
|
||||
* 一级下拉所在列index,从0开始算
|
||||
*/
|
||||
private int index = 0;
|
||||
|
||||
/**
|
||||
* 二级下拉所在的index,从0开始算,不能与一级相同
|
||||
*/
|
||||
private int nextIndex = 0;
|
||||
|
||||
/**
|
||||
* 一级下拉所包含的数据
|
||||
*/
|
||||
private List<String> options = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 二级下拉所包含的数据Map
|
||||
* <p>以每一个一级选项值为Key,每个一级选项对应的二级数据为Value</p>
|
||||
*/
|
||||
private Map<String, List<String>> nextOptions = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 分隔符
|
||||
*/
|
||||
|
||||
+1
-1
@@ -6,13 +6,13 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fesod.sheet.metadata.FieldCache;
|
||||
import org.apache.fesod.sheet.metadata.FieldWrapper;
|
||||
import org.apache.fesod.sheet.util.ClassUtils;
|
||||
import org.apache.fesod.sheet.write.handler.SheetWriteHandler;
|
||||
import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder;
|
||||
import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
|
||||
+2
-11
@@ -25,19 +25,10 @@ import org.apache.fesod.sheet.write.style.row.SimpleRowHeightStyleStrategy;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.excel.convert.ExcelBigNumberConvert;
|
||||
import org.dromara.common.excel.core.CellMergeStrategy;
|
||||
import org.dromara.common.excel.core.DefaultExcelListener;
|
||||
import org.dromara.common.excel.core.DropDownOptions;
|
||||
import org.dromara.common.excel.core.ExcelDownHandler;
|
||||
import org.dromara.common.excel.core.ExcelListener;
|
||||
import org.dromara.common.excel.core.ExcelResult;
|
||||
import org.dromara.common.excel.core.*;
|
||||
import org.dromara.common.excel.handler.DataWriteHandler;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-9
@@ -121,12 +121,10 @@ public record ExcelWriterWrapper<T>(ExcelWriter excelWriter) {
|
||||
* @param excelWriter ExcelWriter
|
||||
* @return ExcelWriterWrapper
|
||||
*/
|
||||
public static <T> ExcelWriterWrapper<T> of(ExcelWriter excelWriter) {
|
||||
public static <T> ExcelWriterWrapper<T> of(ExcelWriter excelWriter) {
|
||||
return new ExcelWriterWrapper<>(excelWriter);
|
||||
}
|
||||
|
||||
// -------------------------------- sheet start
|
||||
|
||||
/**
|
||||
* 创建工作表。
|
||||
*
|
||||
@@ -207,10 +205,6 @@ public record ExcelWriterWrapper<T>(ExcelWriter excelWriter) {
|
||||
return FesodSheet.writerSheet();
|
||||
}
|
||||
|
||||
// -------------------------------- sheet end
|
||||
|
||||
// -------------------------------- table start
|
||||
|
||||
/**
|
||||
* 创建表格。
|
||||
*
|
||||
@@ -249,6 +243,4 @@ public record ExcelWriterWrapper<T>(ExcelWriter excelWriter) {
|
||||
return FesodSheet.writerTable();
|
||||
}
|
||||
|
||||
// -------------------------------- table end
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -8,7 +8,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import tools.jackson.databind.ext.javatime.deser.LocalDateTimeDeserializer;
|
||||
import tools.jackson.databind.ext.javatime.ser.LocalDateTimeSerializer;
|
||||
import tools.jackson.databind.module.SimpleModule;
|
||||
import tools.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
+9
-6
@@ -13,16 +13,19 @@ import tools.jackson.databind.ser.jdk.NumberSerializer;
|
||||
@JacksonStdImpl
|
||||
public class BigNumberSerializer extends NumberSerializer {
|
||||
|
||||
/**
|
||||
* 根据 JS Number.MAX_SAFE_INTEGER 与 Number.MIN_SAFE_INTEGER 得来
|
||||
*/
|
||||
private static final long MAX_SAFE_INTEGER = 9007199254740991L;
|
||||
private static final long MIN_SAFE_INTEGER = -9007199254740991L;
|
||||
|
||||
/**
|
||||
* 提供实例
|
||||
*/
|
||||
public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class);
|
||||
/**
|
||||
* 根据 JS Number.MAX_SAFE_INTEGER 与 Number.MIN_SAFE_INTEGER 得来
|
||||
*/
|
||||
private static final long MAX_SAFE_INTEGER = 9007199254740991L;
|
||||
/**
|
||||
* JavaScript 最小安全整数。
|
||||
*/
|
||||
private static final long MIN_SAFE_INTEGER = -9007199254740991L;
|
||||
|
||||
|
||||
public BigNumberSerializer(Class<? extends Number> rawType) {
|
||||
super(rawType);
|
||||
|
||||
+7
-7
@@ -12,14 +12,14 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
*/
|
||||
public class CustomEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
System.setProperty("dubbo.consumer.loadbalance", "customDubboLoadBalancer");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-15
@@ -58,7 +58,7 @@ public class LogAspect {
|
||||
/**
|
||||
* 执行目标方法并记录操作日志。
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param joinPoint 切点
|
||||
* @param controllerLog 日志注解
|
||||
* @return 目标方法返回值
|
||||
* @throws Throwable 目标方法异常
|
||||
@@ -80,11 +80,11 @@ public class LogAspect {
|
||||
/**
|
||||
* 组装并发布操作日志事件。
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param joinPoint 切点
|
||||
* @param controllerLog 日志注解
|
||||
* @param e 异常信息
|
||||
* @param jsonResult 返回结果
|
||||
* @param stopWatch 耗时统计
|
||||
* @param e 异常信息
|
||||
* @param jsonResult 返回结果
|
||||
* @param stopWatch 耗时统计
|
||||
*/
|
||||
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult, StopWatch stopWatch) {
|
||||
try {
|
||||
@@ -138,9 +138,9 @@ public class LogAspect {
|
||||
/**
|
||||
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param log 日志
|
||||
* @param operLog 操作日志
|
||||
* @param joinPoint 切点
|
||||
* @param log 日志
|
||||
* @param operLog 操作日志
|
||||
* @param jsonResult 返回结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@@ -165,8 +165,8 @@ public class LogAspect {
|
||||
/**
|
||||
* 获取请求的参数,放到log中
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param operLog 操作日志
|
||||
* @param joinPoint 切点
|
||||
* @param operLog 操作日志
|
||||
* @param excludeParamNames 排除参数名
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@@ -186,7 +186,7 @@ public class LogAspect {
|
||||
/**
|
||||
* 将方法参数序列化为日志字符串。
|
||||
*
|
||||
* @param paramsArray 参数数组
|
||||
* @param paramsArray 参数数组
|
||||
* @param excludeParamNames 排除字段名
|
||||
* @return 参数字符串
|
||||
*/
|
||||
@@ -207,7 +207,7 @@ public class LogAspect {
|
||||
/**
|
||||
* 序列化单个方法参数,并移除排除字段。
|
||||
*
|
||||
* @param arg 参数对象
|
||||
* @param arg 参数对象
|
||||
* @param exclude 排除字段名
|
||||
* @return 参数日志字符串
|
||||
*/
|
||||
@@ -234,7 +234,7 @@ public class LogAspect {
|
||||
/**
|
||||
* 将参数转为已排除指定字段的字典。
|
||||
*
|
||||
* @param value 参数值
|
||||
* @param value 参数值
|
||||
* @param exclude 排除字段名
|
||||
* @return 已过滤字段的字典
|
||||
*/
|
||||
@@ -250,7 +250,7 @@ public class LogAspect {
|
||||
/**
|
||||
* 限制日志字段长度。
|
||||
*
|
||||
* @param value 原始字符串
|
||||
* @param value 原始字符串
|
||||
* @param maxLength 最大长度
|
||||
* @return 截断后的字符串
|
||||
*/
|
||||
@@ -303,6 +303,6 @@ public class LogAspect {
|
||||
*/
|
||||
private boolean isFilterValue(Object value) {
|
||||
return value instanceof MultipartFile || value instanceof HttpServletRequest || value instanceof HttpServletResponse
|
||||
|| value instanceof BindingResult;
|
||||
|| value instanceof BindingResult;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -59,14 +59,13 @@ public class LogEventListener {
|
||||
}
|
||||
|
||||
String address = AddressUtils.getRealAddressByIP(ip);
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(getBlock(ip));
|
||||
s.append(address);
|
||||
s.append(getBlock(loginInfoEvent.getUsername()));
|
||||
s.append(getBlock(loginInfoEvent.getStatus()));
|
||||
s.append(getBlock(loginInfoEvent.getMessage()));
|
||||
String s = getBlock(ip) +
|
||||
address +
|
||||
getBlock(loginInfoEvent.getUsername()) +
|
||||
getBlock(loginInfoEvent.getStatus()) +
|
||||
getBlock(loginInfoEvent.getMessage());
|
||||
// 打印信息到日志
|
||||
log.info(s.toString(), loginInfoEvent.getArgs());
|
||||
log.info(s, loginInfoEvent.getArgs());
|
||||
// 获取客户端操作系统
|
||||
String os = userAgent.getOs().getName();
|
||||
// 获取客户端浏览器
|
||||
|
||||
+2
-2
@@ -220,7 +220,7 @@ public final class MailBuilder {
|
||||
* 设置正文。
|
||||
*
|
||||
* @param content 正文
|
||||
* @param html 是否 HTML
|
||||
* @param html 是否 HTML
|
||||
* @return 当前构建器
|
||||
*/
|
||||
public MailBuilder content(String content, boolean html) {
|
||||
@@ -232,7 +232,7 @@ public final class MailBuilder {
|
||||
/**
|
||||
* 添加内联图片。
|
||||
*
|
||||
* @param cid 图片 cid
|
||||
* @param cid 图片 cid
|
||||
* @param inputStream 图片输入流
|
||||
* @return 当前构建器
|
||||
*/
|
||||
|
||||
+4
-4
@@ -41,7 +41,7 @@ public class McpClientTemplate {
|
||||
/**
|
||||
* 调用所有 MCP Server 上的同名工具。
|
||||
*
|
||||
* @param toolName 工具名称
|
||||
* @param toolName 工具名称
|
||||
* @param arguments 工具参数
|
||||
* @return 各 Server 的工具调用结果
|
||||
*/
|
||||
@@ -58,8 +58,8 @@ public class McpClientTemplate {
|
||||
* 调用指定 MCP Server 上的工具。
|
||||
*
|
||||
* @param serverName Server 名称
|
||||
* @param toolName 工具名称
|
||||
* @param arguments 工具参数
|
||||
* @param toolName 工具名称
|
||||
* @param arguments 工具参数
|
||||
* @return 工具调用结果
|
||||
*/
|
||||
public Optional<McpToolCallResult> callTool(String serverName, String toolName, Map<String, Object> arguments) {
|
||||
@@ -86,7 +86,7 @@ public class McpClientTemplate {
|
||||
* 读取指定 MCP Server 上的资源。
|
||||
*
|
||||
* @param serverName Server 名称
|
||||
* @param uri 资源地址
|
||||
* @param uri 资源地址
|
||||
* @return 资源内容
|
||||
*/
|
||||
public Optional<McpResourceReadResult> readResource(String serverName, String uri) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class DataPermissionPointcutAdvisor extends AbstractPointcutAdvisor {
|
||||
|
||||
public DataPermissionPointcutAdvisor() {
|
||||
this.advice = new DataPermissionAdvice();
|
||||
this.pointcut = new DataPermissionPointcut();
|
||||
this.pointcut = new DataPermissionPointcut();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -71,6 +71,7 @@ public class MybatisPlusConfiguration {
|
||||
public DataPermissionPointcutAdvisor dataPermissionPointcutAdvisor() {
|
||||
return new DataPermissionPointcutAdvisor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页插件,自动识别数据库类型
|
||||
*/
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class PageQuery implements Serializable {
|
||||
|
||||
/**
|
||||
* 构建排序
|
||||
*
|
||||
* <p>
|
||||
* 支持的用法如下:
|
||||
* {isAsc:"asc",orderByColumn:"id"} order by id asc
|
||||
* {isAsc:"asc",orderByColumn:"id,createTime"} order by id asc,create_time asc
|
||||
|
||||
+6
-3
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.LambdaMeta;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.ibatis.reflection.property.PropertyNamer;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
@@ -14,13 +16,14 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class AggregateSelectUtils {
|
||||
|
||||
/**
|
||||
* 查询别名合法性匹配规则。
|
||||
*/
|
||||
private static final Pattern ALIAS_PATTERN = Pattern.compile("[A-Za-z_][A-Za-z0-9_]*");
|
||||
|
||||
private AggregateSelectUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加查询字段 SQL。
|
||||
*
|
||||
|
||||
+2
-11
@@ -2,22 +2,13 @@ package org.dromara.common.mybatis.core.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.*;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.LambdaMeta;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import org.apache.ibatis.reflection.property.PropertyNamer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
package org.dromara.common.mybatis.filter;
|
||||
|
||||
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.rpc.*;
|
||||
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
+2
-2
@@ -60,8 +60,8 @@ public class PlusDataPermissionHandler {
|
||||
/**
|
||||
* 获取数据过滤条件的 SQL 片段
|
||||
*
|
||||
* @param where 原始的查询条件表达式
|
||||
* @param isSelect 是否为查询语句
|
||||
* @param where 原始的查询条件表达式
|
||||
* @param isSelect 是否为查询语句
|
||||
* @return 数据过滤条件的 SQL 片段
|
||||
*/
|
||||
public Expression getSqlSegment(Expression where, boolean isSelect) {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class DefaultOssClientImpl extends AbstractOssClientImpl {
|
||||
* 构造默认 S3 存储客户端。
|
||||
*
|
||||
* @param clientId 客户端 ID
|
||||
* @param config S3 存储客户端配置
|
||||
* @param config S3 存储客户端配置
|
||||
*/
|
||||
public DefaultOssClientImpl(String clientId, OssClientConfig config) {
|
||||
super(clientId, config);
|
||||
|
||||
+27
-27
@@ -133,9 +133,9 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将本地路径对应的文件上传到指定存储桶。
|
||||
*
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param path 文件路径
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param path 文件路径
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -154,9 +154,9 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将文件上传到指定存储桶。
|
||||
*
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param file 文件对象
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param file 文件对象
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -175,9 +175,9 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将随机访问文件上传到指定存储桶。
|
||||
*
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param file 随机访问文件
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param file 随机访问文件
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -200,7 +200,7 @@ public interface OssClient extends AutoCloseable {
|
||||
* @param key 对象键
|
||||
* @param channel 数据通道
|
||||
* @param contentLength 内容长度
|
||||
* @param options 可选项
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
PutObjectResult bucketUpload(String bucket, String key, ReadableByteChannel channel, long contentLength, Options options);
|
||||
@@ -223,7 +223,7 @@ public interface OssClient extends AutoCloseable {
|
||||
* @param key 对象键
|
||||
* @param in 输入流
|
||||
* @param contentLength 内容长度
|
||||
* @param options 可选项
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
PutObjectResult bucketUpload(String bucket, String key, InputStream in, long contentLength, Options options);
|
||||
@@ -242,9 +242,9 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将字节数组上传到指定存储桶。
|
||||
*
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param data 字节数组
|
||||
* @param bucket 存储桶名称
|
||||
* @param key 对象键
|
||||
* @param data 字节数组
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -374,8 +374,8 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将本地路径对应的文件上传到默认存储桶。
|
||||
*
|
||||
* @param key 对象键
|
||||
* @param path 文件路径
|
||||
* @param key 对象键
|
||||
* @param path 文件路径
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -393,8 +393,8 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将文件上传到默认存储桶。
|
||||
*
|
||||
* @param key 对象键
|
||||
* @param file 文件对象
|
||||
* @param key 对象键
|
||||
* @param file 文件对象
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -412,8 +412,8 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将随机访问文件上传到默认存储桶。
|
||||
*
|
||||
* @param key 对象键
|
||||
* @param file 随机访问文件
|
||||
* @param key 对象键
|
||||
* @param file 随机访问文件
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
@@ -431,10 +431,10 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将可读通道中的数据上传到默认存储桶。
|
||||
*
|
||||
* @param key 对象键
|
||||
* @param channel 数据通道
|
||||
* @param key 对象键
|
||||
* @param channel 数据通道
|
||||
* @param contentLength 内容长度
|
||||
* @param options 可选项
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
PutObjectResult upload(String key, ReadableByteChannel channel, long contentLength, Options options);
|
||||
@@ -452,10 +452,10 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将输入流中的数据上传到默认存储桶。
|
||||
*
|
||||
* @param key 对象键
|
||||
* @param key 对象键
|
||||
* @param in 输入流
|
||||
* @param contentLength 内容长度
|
||||
* @param options 可选项
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
PutObjectResult upload(String key, InputStream in, long contentLength, Options options);
|
||||
@@ -473,8 +473,8 @@ public interface OssClient extends AutoCloseable {
|
||||
/**
|
||||
* 将字节数组上传到默认存储桶。
|
||||
*
|
||||
* @param key 对象键
|
||||
* @param data 字节数组
|
||||
* @param key 对象键
|
||||
* @param data 字节数组
|
||||
* @param options 可选项
|
||||
* @return 上传结果
|
||||
*/
|
||||
|
||||
+3
-2
@@ -5,19 +5,20 @@ package org.dromara.common.oss.config;
|
||||
*
|
||||
* @param <T> 配置类型
|
||||
* @param <B> 配置构建器类型
|
||||
*
|
||||
* @author 秋辞未寒
|
||||
*/
|
||||
public interface Config<T,B> {
|
||||
public interface Config<T, B> {
|
||||
|
||||
/**
|
||||
* 配置对象拷贝
|
||||
*
|
||||
* @return 拷贝后的新配置对象
|
||||
*/
|
||||
T copy();
|
||||
|
||||
/**
|
||||
* 转为构建器对象
|
||||
*
|
||||
* @return 构建器对象
|
||||
*/
|
||||
B toBuilder();
|
||||
|
||||
+1
-1
@@ -35,6 +35,6 @@ public interface OssConstant {
|
||||
/**
|
||||
* 云服务商
|
||||
*/
|
||||
String[] CLOUD_SERVICE = new String[] {"aliyun", "qcloud", "qiniu", "obs"};
|
||||
String[] CLOUD_SERVICE = new String[]{"aliyun", "qcloud", "qiniu", "obs"};
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,17 +20,17 @@ public enum AccessPolicy {
|
||||
/**
|
||||
* 私有
|
||||
*/
|
||||
PRIVATE(0,BucketCannedACL.PRIVATE, ObjectCannedACL.PRIVATE),
|
||||
PRIVATE(0, BucketCannedACL.PRIVATE, ObjectCannedACL.PRIVATE),
|
||||
|
||||
/**
|
||||
* 公有读写
|
||||
*/
|
||||
PUBLIC_READ_WRITE(1,BucketCannedACL.PUBLIC_READ_WRITE, ObjectCannedACL.PUBLIC_READ_WRITE),
|
||||
PUBLIC_READ_WRITE(1, BucketCannedACL.PUBLIC_READ_WRITE, ObjectCannedACL.PUBLIC_READ_WRITE),
|
||||
|
||||
/**
|
||||
* 公有只读
|
||||
*/
|
||||
PUBLIC_READ(2,BucketCannedACL.PUBLIC_READ, ObjectCannedACL.PUBLIC_READ);
|
||||
PUBLIC_READ(2, BucketCannedACL.PUBLIC_READ, ObjectCannedACL.PUBLIC_READ);
|
||||
|
||||
/**
|
||||
* 访问策略类型
|
||||
|
||||
+12
-12
@@ -19,21 +19,21 @@ import java.util.Map;
|
||||
* @author 秋辞未寒
|
||||
*/
|
||||
public record GetObjectResult(
|
||||
String key,
|
||||
String eTag,
|
||||
LocalDateTime lastModified,
|
||||
long size,
|
||||
String contentType,
|
||||
String contentDisposition,
|
||||
String contentRange,
|
||||
String contentEncoding,
|
||||
String contentLanguage,
|
||||
Map<String, String> metadata
|
||||
String key,
|
||||
String eTag,
|
||||
LocalDateTime lastModified,
|
||||
long size,
|
||||
String contentType,
|
||||
String contentDisposition,
|
||||
String contentRange,
|
||||
String contentEncoding,
|
||||
String contentLanguage,
|
||||
Map<String, String> metadata
|
||||
) {
|
||||
|
||||
public static GetObjectResult form(String key, String eTag, LocalDateTime lastModified, long size
|
||||
, String contentType, String contentDisposition, String contentRange, String contentEncoding, String contentLanguage
|
||||
, Map<String, String> metadata) {
|
||||
, String contentType, String contentDisposition, String contentRange, String contentEncoding, String contentLanguage
|
||||
, Map<String, String> metadata) {
|
||||
return new GetObjectResult(key, eTag, lastModified, size, contentType, contentDisposition, contentRange, contentEncoding, contentLanguage, metadata);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import java.util.Optional;
|
||||
* @author 秋辞未寒
|
||||
*/
|
||||
public record HandleAsyncResult<T>(
|
||||
T result,
|
||||
Throwable error
|
||||
T result,
|
||||
Throwable error
|
||||
) {
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -10,10 +10,10 @@ package org.dromara.common.oss.model;
|
||||
* @author 秋辞未寒
|
||||
*/
|
||||
public record PutObjectResult(
|
||||
String url,
|
||||
String key,
|
||||
String eTag,
|
||||
long size
|
||||
String url,
|
||||
String key,
|
||||
String eTag,
|
||||
long size
|
||||
) {
|
||||
|
||||
/**
|
||||
|
||||
+1
-5
@@ -3,11 +3,7 @@ package org.dromara.common.push.annotation;
|
||||
import org.dromara.common.push.condition.MessageTransportCondition;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 按消息推送传输方式启用组件。
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public class MessageTransportCondition implements Condition {
|
||||
/**
|
||||
* 判断当前消息推送配置是否匹配注解声明的传输方式。
|
||||
*
|
||||
* @param context 条件上下文
|
||||
* @param context 条件上下文
|
||||
* @param metadata 注解元数据
|
||||
* @return 是否匹配
|
||||
*/
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ public class SseEmitterSessionManager implements PushSessionManager {
|
||||
* 构造 SSE 会话管理器并启动心跳检测。
|
||||
*
|
||||
* @param scheduledExecutorService 定时任务线程池
|
||||
* @param messageProperties 消息推送配置
|
||||
* @param messageProperties 消息推送配置
|
||||
*/
|
||||
public SseEmitterSessionManager(ScheduledExecutorService scheduledExecutorService, MessageProperties messageProperties) {
|
||||
this.messageProperties = messageProperties;
|
||||
@@ -218,7 +218,7 @@ public class SseEmitterSessionManager implements PushSessionManager {
|
||||
/**
|
||||
* 向指定用户的全部本地 SSE 会话发送统一 JSON 消息。
|
||||
*
|
||||
* @param userId 要发送消息的用户id
|
||||
* @param userId 要发送消息的用户id
|
||||
* @param pushDTO 要发送的消息内容
|
||||
*/
|
||||
public void sendMessage(Long userId, PushDTO pushDTO) {
|
||||
|
||||
+16
-3
@@ -50,6 +50,12 @@ public class RateLimiterAspect {
|
||||
private final ParameterNameDiscoverer pnd = new DefaultParameterNameDiscoverer();
|
||||
|
||||
|
||||
/**
|
||||
* 在限流注解方法执行前扣减令牌,令牌不足时阻断请求。
|
||||
*
|
||||
* @param point 切点信息
|
||||
* @param rateLimiter 限流注解配置
|
||||
*/
|
||||
@Before("@annotation(rateLimiter)")
|
||||
public void doBefore(JoinPoint point, RateLimiter rateLimiter) {
|
||||
int time = rateLimiter.time();
|
||||
@@ -79,6 +85,13 @@ public class RateLimiterAspect {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装限流缓存键。
|
||||
*
|
||||
* @param rateLimiter 限流注解配置
|
||||
* @param point 切点信息
|
||||
* @return 限流缓存键
|
||||
*/
|
||||
private String getCombineKey(RateLimiter rateLimiter, JoinPoint point) {
|
||||
String key = rateLimiter.key();
|
||||
// 判断 key 不为空 和 不是表达式
|
||||
@@ -99,13 +112,13 @@ public class RateLimiterAspect {
|
||||
key = expression.getValue(context, String.class);
|
||||
}
|
||||
StringBuilder stringBuffer = new StringBuilder(GlobalConstants.RATE_LIMIT_KEY);
|
||||
stringBuffer.append(ServletUtils.getRequest().getRequestURI()).append(":");
|
||||
stringBuffer.append(ServletUtils.getRequest().getRequestURI()).append(StringUtils.COLON);
|
||||
if (rateLimiter.limitType() == LimitType.IP) {
|
||||
// 获取请求ip
|
||||
stringBuffer.append(ServletUtils.getClientIP()).append(":");
|
||||
stringBuffer.append(ServletUtils.getClientIP()).append(StringUtils.COLON);
|
||||
} else if (rateLimiter.limitType() == LimitType.CLUSTER) {
|
||||
// 获取客户端实例id
|
||||
stringBuffer.append(RedisUtils.getClient().getId()).append(":");
|
||||
stringBuffer.append(RedisUtils.getClient().getId()).append(StringUtils.COLON);
|
||||
}
|
||||
return stringBuffer.append(key).toString();
|
||||
}
|
||||
|
||||
+9
-3
@@ -11,8 +11,8 @@ import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
@@ -42,7 +42,7 @@ public class RepeatSubmitAspect {
|
||||
/**
|
||||
* 请求进入前校验是否重复提交。
|
||||
*
|
||||
* @param point 切点
|
||||
* @param point 切点
|
||||
* @param repeatSubmit 防重复提交注解
|
||||
*/
|
||||
@Before("@annotation(repeatSubmit)")
|
||||
@@ -62,7 +62,7 @@ public class RepeatSubmitAspect {
|
||||
// 唯一值(没有消息头则使用请求地址)
|
||||
String submitKey = StringUtils.trimToEmpty(request.getHeader(SaManager.getConfig().getTokenName()));
|
||||
|
||||
submitKey = SecureUtil.md5(submitKey + ":" + nowParams);
|
||||
submitKey = SecureUtil.md5(submitKey + StringUtils.COLON + nowParams);
|
||||
// 唯一标识(指定key + url + 消息头)
|
||||
String cacheRepeatKey = GlobalConstants.REPEAT_SUBMIT_KEY + url + submitKey;
|
||||
if (RedisUtils.setObjectIfAbsent(cacheRepeatKey, "", Duration.ofMillis(interval))) {
|
||||
@@ -111,6 +111,9 @@ public class RepeatSubmitAspect {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除当前请求写入的防重键。
|
||||
*/
|
||||
private void deleteRepeatKey() {
|
||||
String key = KEY_CACHE.get();
|
||||
if (StringUtils.isNotBlank(key)) {
|
||||
@@ -120,6 +123,9 @@ public class RepeatSubmitAspect {
|
||||
|
||||
/**
|
||||
* 参数拼装
|
||||
*
|
||||
* @param paramsArray 方法参数数组
|
||||
* @return 拼装后的参数字符串
|
||||
*/
|
||||
private String argsArrayToString(Object[] paramsArray) {
|
||||
StringJoiner params = new StringJoiner(" ");
|
||||
|
||||
+4
-4
@@ -12,9 +12,9 @@ import org.springframework.context.annotation.Bean;
|
||||
@AutoConfiguration(after = RedisConfiguration.class)
|
||||
public class IdempotentAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||
return new RepeatSubmitAspect();
|
||||
}
|
||||
@Bean
|
||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||
return new RepeatSubmitAspect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-2
@@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.redis.config.properties.RedissonProperties;
|
||||
import org.dromara.common.redis.handler.KeyPrefixHandler;
|
||||
import org.dromara.common.redis.handler.RedisExceptionHandler;
|
||||
@@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
||||
import tools.jackson.databind.DefaultTyping;
|
||||
import tools.jackson.databind.ext.javatime.deser.LocalDateTimeDeserializer;
|
||||
import tools.jackson.databind.ext.javatime.ser.LocalDateTimeSerializer;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user