update 格式化全部代码
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ public interface SystemConstants {
|
||||
/**
|
||||
* 排除敏感属性字段
|
||||
*/
|
||||
String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
|
||||
String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ public final class ServiceException extends RuntimeException {
|
||||
* 使用错误消息和错误码构造业务异常。
|
||||
*
|
||||
* @param message 错误消息
|
||||
* @param code 错误码
|
||||
* @param code 错误码
|
||||
*/
|
||||
public ServiceException(String message, Integer code) {
|
||||
this.message = message;
|
||||
@@ -61,7 +61,7 @@ public final class ServiceException extends RuntimeException {
|
||||
* 使用错误消息和根因构造业务异常。
|
||||
*
|
||||
* @param message 错误消息
|
||||
* @param cause 根因
|
||||
* @param cause 根因
|
||||
*/
|
||||
public ServiceException(String message, Throwable cause) {
|
||||
super(cause);
|
||||
@@ -72,7 +72,7 @@ public final class ServiceException extends RuntimeException {
|
||||
* 使用占位符参数格式化错误消息。
|
||||
*
|
||||
* @param message 模板消息
|
||||
* @param args 参数
|
||||
* @param args 参数
|
||||
*/
|
||||
public ServiceException(String message, Object... args) {
|
||||
this.message = StrFormatter.format(message, args);
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public final class SseException extends RuntimeException {
|
||||
* 使用错误消息和错误码构造 SSE 异常。
|
||||
*
|
||||
* @param message 错误消息
|
||||
* @param code 错误码
|
||||
* @param code 错误码
|
||||
*/
|
||||
public SseException(String message, Integer code) {
|
||||
this.message = message;
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
package org.dromara.common.core.exception.base;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -47,8 +47,8 @@ public class BaseException extends RuntimeException {
|
||||
* 使用模块、错误码和参数构造异常。
|
||||
*
|
||||
* @param module 所属模块
|
||||
* @param code 错误码
|
||||
* @param args 参数
|
||||
* @param code 错误码
|
||||
* @param args 参数
|
||||
*/
|
||||
public BaseException(String module, String code, Object[] args) {
|
||||
this(module, code, args, null);
|
||||
@@ -57,7 +57,7 @@ public class BaseException extends RuntimeException {
|
||||
/**
|
||||
* 使用模块和默认消息构造异常。
|
||||
*
|
||||
* @param module 所属模块
|
||||
* @param module 所属模块
|
||||
* @param defaultMessage 默认消息
|
||||
*/
|
||||
public BaseException(String module, String defaultMessage) {
|
||||
|
||||
+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);
|
||||
|
||||
+4
-4
@@ -27,9 +27,9 @@ 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"
|
||||
"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"
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -411,7 +411,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
// 本周
|
||||
if (DateUtil.isSameWeek(date, now, true)) {
|
||||
return DateUtil.dayOfWeekEnum(date).toChinese("周")
|
||||
+ " " + DateUtil.format(date, "HH:mm");
|
||||
+ " " + DateUtil.format(date, "HH:mm");
|
||||
}
|
||||
|
||||
// 今年内其它时间
|
||||
|
||||
-1
@@ -14,7 +14,6 @@ import java.util.Map;
|
||||
* Mapstruct 工具类
|
||||
* <p>参考文档:<a href="https://mapstruct.plus/introduction/quick-start.html">mapstruct-plus</a></p>
|
||||
*
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
|
||||
+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) {
|
||||
|
||||
+5
-5
@@ -320,11 +320,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
return StrUtil.split(str, separator)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(mapper)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(mapper)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+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;
|
||||
|
||||
/**
|
||||
|
||||
+10
-10
@@ -61,16 +61,16 @@ public class MimeTypeUtils {
|
||||
* 默认允许上传的文件扩展名数组
|
||||
*/
|
||||
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
|
||||
// 图片
|
||||
"bmp", "gif", "jpg", "jpeg", "png",
|
||||
// word excel powerpoint
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
|
||||
// 压缩文件
|
||||
"rar", "zip", "gz", "bz2",
|
||||
// 视频格式
|
||||
"mp4", "avi", "rmvb",
|
||||
// pdf
|
||||
"pdf"
|
||||
// 图片
|
||||
"bmp", "gif", "jpg", "jpeg", "png",
|
||||
// word excel powerpoint
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
|
||||
// 压缩文件
|
||||
"rar", "zip", "gz", "bz2",
|
||||
// 视频格式
|
||||
"mp4", "avi", "rmvb",
|
||||
// pdf
|
||||
"pdf"
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+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
|
||||
|
||||
+11
-11
@@ -55,12 +55,12 @@ public class RegionUtils {
|
||||
|
||||
// IPv4配置
|
||||
Config v4Config = Config.custom()
|
||||
.setCachePolicy(Config.BufferCache)
|
||||
//.setXdbFile(v4TempXdb)
|
||||
.setXdbInputStream(v4InputStream)
|
||||
//
|
||||
.setCacheSliceBytes(DEFAULT_CACHE_SLICE_BYTES)
|
||||
.asV4();
|
||||
.setCachePolicy(Config.BufferCache)
|
||||
//.setXdbFile(v4TempXdb)
|
||||
.setXdbInputStream(v4InputStream)
|
||||
//
|
||||
.setCacheSliceBytes(DEFAULT_CACHE_SLICE_BYTES)
|
||||
.asV4();
|
||||
|
||||
// IPv6配置
|
||||
Config v6Config = null;
|
||||
@@ -69,11 +69,11 @@ public class RegionUtils {
|
||||
log.warn("未加载 IPv6 地址库:未在类路径下找到文件 {}。当前仅启用 IPv4 查询。如需启用 IPv6,请将 ip2region_v6.xdb 放置到 resources 目录", DEFAULT_IPV6_XDB_PATH);
|
||||
} else {
|
||||
v6Config = Config.custom()
|
||||
.setCachePolicy(Config.BufferCache)
|
||||
//.setXdbFile(v6TempXdb)
|
||||
.setXdbInputStream(v6XdbInputStream)
|
||||
.setCacheSliceBytes(DEFAULT_CACHE_SLICE_BYTES)
|
||||
.asV6();
|
||||
.setCachePolicy(Config.BufferCache)
|
||||
//.setXdbFile(v6TempXdb)
|
||||
.setXdbInputStream(v6XdbInputStream)
|
||||
.setCacheSliceBytes(DEFAULT_CACHE_SLICE_BYTES)
|
||||
.asV6();
|
||||
}
|
||||
|
||||
// 初始化Ip2Region实例
|
||||
|
||||
+4
-4
@@ -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 注解对象
|
||||
*/
|
||||
@@ -34,7 +34,7 @@ public final class AnnotationUtils extends AnnotationUtil {
|
||||
} catch (final ClassNotFoundException | ClassCastException e) {
|
||||
// ignore
|
||||
log.error("AnnotationUtils.getAnnotation(AnnotatedElement, String) error.", e);
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class AnnotationUtils extends AnnotationUtil {
|
||||
* 获取指定注解中所有属性值<br>
|
||||
* 如果无指定的属性方法返回null
|
||||
*
|
||||
* @param annotationEle {@link AnnotatedElement},可以是Class、Method、Field、Constructor、ReflectPermission
|
||||
* @param annotationEle {@link AnnotatedElement},可以是Class、Method、Field、Constructor、ReflectPermission
|
||||
* @param annotationTypeName 注解类型名称
|
||||
* @return 注解对象所有属性键值
|
||||
* @throws UtilException 调用注解中的方法时执行异常
|
||||
@@ -55,7 +55,7 @@ public final class AnnotationUtils extends AnnotationUtil {
|
||||
} catch (final ClassNotFoundException | ClassCastException e) {
|
||||
// ignore
|
||||
log.error("AnnotationUtils.getAnnotationValueMap(AnnotatedElement, String) error.", e);
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+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
@@ -3,7 +3,10 @@ package org.dromara.common.core.validate.enums;
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Repeatable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user