类型修正
This commit is contained in:
@@ -16,11 +16,11 @@ public @interface HttpLogin {
|
||||
|
||||
/**
|
||||
* @description 是否必需,默认为true
|
||||
* @return BOOLEAN
|
||||
* @return boolean
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
BOOLEAN required() default true;
|
||||
boolean required() default true;
|
||||
|
||||
/**
|
||||
* @description 当token无效时的错误消息
|
||||
|
||||
@@ -42,7 +42,7 @@ public class HttpLoginArgumentResolver implements HandlerMethodArgumentResolver
|
||||
private static final String REDIS_LOGIN_PREFIX = "login:token:";
|
||||
|
||||
@Override
|
||||
public BOOLEAN supportsParameter(MethodParameter parameter) {
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return parameter.hasParameterAnnotation(HttpLogin.class)
|
||||
&& LoginDomain.class.isAssignableFrom(parameter.getParameterType());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class AuthProperties {
|
||||
* 是否启用认证过滤器
|
||||
* 默认启用
|
||||
*/
|
||||
private BOOLEAN enabled = true;
|
||||
private Boolean enabled = true;
|
||||
|
||||
/**
|
||||
* 登录接口路径
|
||||
@@ -72,11 +72,11 @@ public class AuthProperties {
|
||||
whitelist.add("/error");
|
||||
}
|
||||
|
||||
public BOOLEAN isEnabled() {
|
||||
public Boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(BOOLEAN enabled) {
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
/**
|
||||
* 检查路径是否在白名单中
|
||||
*/
|
||||
private BOOLEAN isWhitelisted(@NonNull String path) {
|
||||
private Boolean isWhitelisted(@NonNull String path) {
|
||||
// 1. 先检查认证相关接口(login / logout / captcha / refresh)
|
||||
if (authProperties.getAuthPaths() != null) {
|
||||
for (String pattern : authProperties.getAuthPaths()) {
|
||||
|
||||
@@ -34,12 +34,12 @@ public class JwtTokenParser implements TokenParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validateToken(String token, String userId) {
|
||||
public Boolean validateToken(String token, String userId) {
|
||||
return jwtTokenUtil.validateToken(token, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN isTokenExpired(String token) {
|
||||
public Boolean isTokenExpired(String token) {
|
||||
return jwtTokenUtil.isTokenExpired(token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,19 +33,19 @@ public interface TokenParser {
|
||||
* @description 验证令牌
|
||||
* @param token 令牌
|
||||
* @param userId 用户ID
|
||||
* @return BOOLEAN 是否有效
|
||||
* @return Boolean 是否有效
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
BOOLEAN validateToken(String token, String userId);
|
||||
Boolean validateToken(String token, String userId);
|
||||
|
||||
/**
|
||||
* @description 检查令牌是否过期
|
||||
* @param token 令牌
|
||||
* @return BOOLEAN 是否过期
|
||||
* @return Boolean 是否过期
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
BOOLEAN isTokenExpired(String token);
|
||||
Boolean isTokenExpired(String token);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,11 +114,11 @@ public class JwtTokenUtil {
|
||||
* @description 验证令牌
|
||||
* @param token JWT令牌
|
||||
* @param userId 用户ID
|
||||
* @return BOOLEAN 是否有效
|
||||
* @return Boolean 是否有效
|
||||
* @author yslg
|
||||
* @since 2025-11-07
|
||||
*/
|
||||
public BOOLEAN validateToken(String token, String userId) {
|
||||
public Boolean validateToken(String token, String userId) {
|
||||
try {
|
||||
final String tokenUserId = getUserIdFromToken(token);
|
||||
return (userId.equals(tokenUserId) && !isTokenExpired(token));
|
||||
@@ -130,11 +130,11 @@ public class JwtTokenUtil {
|
||||
/**
|
||||
* @description 检查令牌是否过期
|
||||
* @param token JWT令牌
|
||||
* @return BOOLEAN 是否过期
|
||||
* @return Boolean 是否过期
|
||||
* @author yslg
|
||||
* @since 2025-11-07
|
||||
*/
|
||||
public BOOLEAN isTokenExpired(String token) {
|
||||
public Boolean isTokenExpired(String token) {
|
||||
final Date expiration = getExpirationDateFromToken(token);
|
||||
return expiration.before(new Date());
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class LoginParam implements Serializable {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private BOOLEAN rememberMe;
|
||||
private Boolean rememberMe;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ import lombok.Data;
|
||||
public class ResultDomain<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private INTEGER code;
|
||||
private BOOLEAN success;
|
||||
private Integer code;
|
||||
private Boolean success;
|
||||
private String message;
|
||||
private T data;
|
||||
private List<T> dataList;
|
||||
|
||||
@@ -40,5 +40,5 @@ public class BaseDTO implements Serializable {
|
||||
private Date deleteTime;
|
||||
|
||||
@Schema(description = "是否已删除", defaultValue = "false")
|
||||
private BOOLEAN deleted = false;
|
||||
private Boolean deleted = false;
|
||||
}
|
||||
@@ -35,11 +35,11 @@ public class TbSysAclDTO extends BaseDTO {
|
||||
private String principalDeptId;
|
||||
|
||||
@Schema(description = "权限位:1读 2写 4执行")
|
||||
private INTEGER permission;
|
||||
private Integer permission;
|
||||
|
||||
@Schema(description = "允许或显式拒绝", defaultValue = "true")
|
||||
private BOOLEAN allow = true;
|
||||
private Boolean allow = true;
|
||||
|
||||
@Schema(description = "是否包含子级(对dept/role生效)", defaultValue = "false")
|
||||
private BOOLEAN includeDescendants = false;
|
||||
private Boolean includeDescendants = false;
|
||||
}
|
||||
@@ -33,11 +33,11 @@ public class TbSysAclPolicyDTO extends BaseDTO {
|
||||
private String viewHierarchyRule;
|
||||
|
||||
@Schema(description = "默认权限(无显式ACL时应用)", defaultValue = "0")
|
||||
private INTEGER defaultPermission=0;
|
||||
private Integer defaultPermission=0;
|
||||
|
||||
@Schema(description = "默认是否允许", defaultValue = "true")
|
||||
private BOOLEAN defaultAllow=true;
|
||||
private Boolean defaultAllow=true;
|
||||
|
||||
@Schema(description = "是否默认应用到子级", defaultValue = "true")
|
||||
private BOOLEAN applyToChildren=true;
|
||||
private Boolean applyToChildren=true;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class TbSysConfigDTO extends BaseDTO {
|
||||
@Schema(description = "配置值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "数据类型(String, INTEGER, BOOLEAN, Float, Double)")
|
||||
@Schema(description = "数据类型(String, Integer, Boolean, Float, Double)")
|
||||
private String configType;
|
||||
|
||||
@Schema(description = "配置渲染类型(select, input, textarea, checkbox, radio, switch)")
|
||||
@@ -53,9 +53,9 @@ public class TbSysConfigDTO extends BaseDTO {
|
||||
private String moduleId;
|
||||
|
||||
@Schema(description = "配置顺序")
|
||||
private INTEGER orderNum;
|
||||
private Integer orderNum;
|
||||
|
||||
@Schema(description = "配置状态 0:启用 1:禁用", defaultValue = "0")
|
||||
private INTEGER status = 0;
|
||||
private Integer status = 0;
|
||||
|
||||
}
|
||||
@@ -33,5 +33,5 @@ public class TbSysRoleDTO extends BaseDTO {
|
||||
private String ownerDeptId;
|
||||
|
||||
@Schema(description = "角色状态 true 有效, false 无效")
|
||||
private BOOLEAN status;
|
||||
private Boolean status;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class TbSysUserInfoDTO extends BaseDTO {
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private INTEGER gender;
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "姓")
|
||||
private String familyName;
|
||||
@@ -36,7 +36,7 @@ public class TbSysUserInfoDTO extends BaseDTO {
|
||||
private String fullName;
|
||||
|
||||
@Schema(description = "等级")
|
||||
private INTEGER level;
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "身份证号")
|
||||
private String idCard;
|
||||
|
||||
@@ -37,13 +37,13 @@ public class TbSysViewDTO extends BaseDTO {
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private INTEGER type;
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "布局")
|
||||
private String layout;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private INTEGER orderNum;
|
||||
private Integer orderNum;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
@@ -47,6 +47,6 @@ public class BaseVO implements Serializable {
|
||||
private Date deleteTime;
|
||||
|
||||
@Schema(description = "是否已删除", defaultValue = "false")
|
||||
private BOOLEAN deleted = false;
|
||||
private Boolean deleted = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,11 +79,11 @@ public class RedisService {
|
||||
/**
|
||||
* @description 判断key是否存在
|
||||
* @param key String 键
|
||||
* @return BOOLEAN 是否存在
|
||||
* @return Boolean 是否存在
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public BOOLEAN hasKey(String key) {
|
||||
public Boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class NonUtils {
|
||||
* @param obj 待判断的对象
|
||||
* @return true-对象为null,false-对象不为null
|
||||
*/
|
||||
public static BOOLEAN isNull(Object obj) {
|
||||
public static Boolean isNull(Object obj) {
|
||||
return obj == null;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class NonUtils {
|
||||
* @param obj 待判断的对象
|
||||
* @return true-对象不为null,false-对象为null
|
||||
*/
|
||||
public static BOOLEAN isNotNull(Object obj) {
|
||||
public static Boolean isNotNull(Object obj) {
|
||||
return obj != null;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class NonUtils {
|
||||
* @param objects 待判断的对象数组
|
||||
* @return true-所有对象都为null,false-至少有一个对象不为null
|
||||
*/
|
||||
public static BOOLEAN isAllNull(Object... objects) {
|
||||
public static Boolean isAllNull(Object... objects) {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class NonUtils {
|
||||
* @param objects 待判断的对象数组
|
||||
* @return true-所有对象都不为null,false-至少有一个对象为null
|
||||
*/
|
||||
public static BOOLEAN isAllNotNull(Object... objects) {
|
||||
public static Boolean isAllNotNull(Object... objects) {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class NonUtils {
|
||||
* @param objects 待判断的对象数组
|
||||
* @return true-存在null对象,false-不存在null对象
|
||||
*/
|
||||
public static BOOLEAN hasNull(Object... objects) {
|
||||
public static Boolean hasNull(Object... objects) {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class NonUtils {
|
||||
* @param obj 待判断的对象
|
||||
* @return true-对象为空,false-对象不为空
|
||||
*/
|
||||
public static BOOLEAN isEmpty(Object obj) {
|
||||
public static Boolean isEmpty(Object obj) {
|
||||
if (isNull(obj)) {
|
||||
return true;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class NonUtils {
|
||||
* @param obj 待判断的对象
|
||||
* @return true-对象不为空,false-对象为空
|
||||
*/
|
||||
public static BOOLEAN isNotEmpty(Object obj) {
|
||||
public static Boolean isNotEmpty(Object obj) {
|
||||
return !isEmpty(obj);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class NonUtils {
|
||||
* @param objects 待判断的对象数组
|
||||
* @return true-所有对象都为空,false-至少有一个对象不为空
|
||||
*/
|
||||
public static BOOLEAN isAllEmpty(Object... objects) {
|
||||
public static Boolean isAllEmpty(Object... objects) {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class NonUtils {
|
||||
* @param objects 待判断的对象数组
|
||||
* @return true-所有对象都不为空,false-至少有一个对象为空
|
||||
*/
|
||||
public static BOOLEAN isAllNotEmpty(Object... objects) {
|
||||
public static Boolean isAllNotEmpty(Object... objects) {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class NonUtils {
|
||||
* @param objects 待判断的对象数组
|
||||
* @return true-存在空值,false-不存在空值
|
||||
*/
|
||||
public static BOOLEAN hasEmpty(Object... objects) {
|
||||
public static Boolean hasEmpty(Object... objects) {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class NonUtils {
|
||||
* @param obj 待判断的对象
|
||||
* @return true-对象为空(包括递归检查),false-对象不为空
|
||||
*/
|
||||
public static BOOLEAN isDeepEmpty(Object obj) {
|
||||
public static Boolean isDeepEmpty(Object obj) {
|
||||
return isDeepEmpty(obj, new HashSet<>());
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class NonUtils {
|
||||
* @param visited 已访问对象集合,用于防止循环引用
|
||||
* @return true-对象为空(包括递归检查),false-对象不为空
|
||||
*/
|
||||
private static BOOLEAN isDeepEmpty(Object obj, Set<Object> visited) {
|
||||
private static Boolean isDeepEmpty(Object obj, Set<Object> visited) {
|
||||
if (isEmpty(obj)) {
|
||||
return true;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public class NonUtils {
|
||||
* @param obj 待判断的对象
|
||||
* @return true-对象不为空(包括递归检查),false-对象为空
|
||||
*/
|
||||
public static BOOLEAN isDeepNotEmpty(Object obj) {
|
||||
public static Boolean isDeepNotEmpty(Object obj) {
|
||||
return !isDeepEmpty(obj);
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ public class NonUtils {
|
||||
* @param collection 待判断的集合
|
||||
* @return true-集合为null或空,false-集合不为空
|
||||
*/
|
||||
public static BOOLEAN isEmptyCollection(Collection<?> collection) {
|
||||
public static Boolean isEmptyCollection(Collection<?> collection) {
|
||||
return collection == null || collection.isEmpty();
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class NonUtils {
|
||||
* @param collection 待判断的集合
|
||||
* @return true-集合不为null且不为空,false-集合为null或空
|
||||
*/
|
||||
public static BOOLEAN isNotEmptyCollection(Collection<?> collection) {
|
||||
public static Boolean isNotEmptyCollection(Collection<?> collection) {
|
||||
return collection != null && !collection.isEmpty();
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ public class NonUtils {
|
||||
* @param collection 待判断的集合
|
||||
* @return true-集合包含有效元素,false-集合为空或只包含null/空元素
|
||||
*/
|
||||
public static BOOLEAN hasValidElements(Collection<?> collection) {
|
||||
public static Boolean hasValidElements(Collection<?> collection) {
|
||||
if (isEmptyCollection(collection)) {
|
||||
return false;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public class NonUtils {
|
||||
* @param collection 待判断的集合
|
||||
* @return true-集合所有元素都有效,false-集合为空或包含null/空元素
|
||||
*/
|
||||
public static BOOLEAN allValidElements(Collection<?> collection) {
|
||||
public static Boolean allValidElements(Collection<?> collection) {
|
||||
if (isEmptyCollection(collection)) {
|
||||
return false;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ public class NonUtils {
|
||||
* @param map 待判断的Map
|
||||
* @return true-Map为null或空,false-Map不为空
|
||||
*/
|
||||
public static BOOLEAN isEmptyMap(Map<?, ?> map) {
|
||||
public static Boolean isEmptyMap(Map<?, ?> map) {
|
||||
return map == null || map.isEmpty();
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ public class NonUtils {
|
||||
* @param map 待判断的Map
|
||||
* @return true-Map不为null且不为空,false-Map为null或空
|
||||
*/
|
||||
public static BOOLEAN isNotEmptyMap(Map<?, ?> map) {
|
||||
public static Boolean isNotEmptyMap(Map<?, ?> map) {
|
||||
return map != null && !map.isEmpty();
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ public class NonUtils {
|
||||
* @param array 待判断的数组
|
||||
* @return true-数组为null或空,false-数组不为空
|
||||
*/
|
||||
public static BOOLEAN isEmptyArray(Object array) {
|
||||
public static Boolean isEmptyArray(Object array) {
|
||||
return array == null || !array.getClass().isArray() || Array.getLength(array) == 0;
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class NonUtils {
|
||||
* @param array 待判断的数组
|
||||
* @return true-数组不为null且不为空,false-数组为null或空
|
||||
*/
|
||||
public static BOOLEAN isNotEmptyArray(Object array) {
|
||||
public static Boolean isNotEmptyArray(Object array) {
|
||||
return array != null && array.getClass().isArray() && Array.getLength(array) > 0;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public class NonUtils {
|
||||
* @param str 待判断的字符串
|
||||
* @return true-字符串为null、空或只包含空白字符,false-字符串有有效内容
|
||||
*/
|
||||
public static BOOLEAN isEmptyString(String str) {
|
||||
public static Boolean isEmptyString(String str) {
|
||||
return str == null || str.trim().isEmpty();
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ public class NonUtils {
|
||||
* @param str 待判断的字符串
|
||||
* @return true-字符串不为null且有有效内容,false-字符串为null、空或只包含空白字符
|
||||
*/
|
||||
public static BOOLEAN isNotEmptyString(String str) {
|
||||
public static Boolean isNotEmptyString(String str) {
|
||||
return str != null && !str.trim().isEmpty();
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ public class NonUtils {
|
||||
* @param <T> 目标类型
|
||||
* @return true-对象不为null且为指定类型,false-否则
|
||||
*/
|
||||
public static <T> BOOLEAN isInstanceAndNotNull(Object obj, Class<T> clazz) {
|
||||
public static <T> Boolean isInstanceAndNotNull(Object obj, Class<T> clazz) {
|
||||
return isNotNull(obj) && clazz.isInstance(obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isAjaxRequest(HttpServletRequest request) {
|
||||
public static Boolean isAjaxRequest(HttpServletRequest request) {
|
||||
String header = request.getHeader("X-Requested-With");
|
||||
return "XMLHttpRequest".equalsIgnoreCase(header);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isGet(HttpServletRequest request) {
|
||||
public static Boolean isGet(HttpServletRequest request) {
|
||||
return "GET".equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isPost(HttpServletRequest request) {
|
||||
public static Boolean isPost(HttpServletRequest request) {
|
||||
return "POST".equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isPut(HttpServletRequest request) {
|
||||
public static Boolean isPut(HttpServletRequest request) {
|
||||
return "PUT".equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isDelete(HttpServletRequest request) {
|
||||
public static Boolean isDelete(HttpServletRequest request) {
|
||||
return "DELETE".equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isHttps(HttpServletRequest request) {
|
||||
public static Boolean isHttps(HttpServletRequest request) {
|
||||
return "https".equals(request.getScheme()) || request.isSecure() ||
|
||||
"443".equals(request.getHeader("X-Forwarded-Port")) ||
|
||||
"https".equals(request.getHeader("X-Forwarded-Proto"));
|
||||
@@ -311,7 +311,7 @@ public class ServletUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN hasParameter(HttpServletRequest request, String paramName) {
|
||||
public static Boolean hasParameter(HttpServletRequest request, String paramName) {
|
||||
return request.getParameter(paramName) != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isEmpty(String str) {
|
||||
public static Boolean isEmpty(String str) {
|
||||
return str == null || str.isEmpty();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isNotEmpty(String str) {
|
||||
public static Boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN equals(String a, String b) {
|
||||
public static Boolean equals(String a, String b) {
|
||||
return a == null ? b == null : a.equals(b);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN contains(String str, String sub) {
|
||||
public static Boolean contains(String str, String sub) {
|
||||
return str != null && sub != null && str.contains(sub);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN startsWith(String str, String prefix) {
|
||||
public static Boolean startsWith(String str, String prefix) {
|
||||
return str != null && prefix != null && str.startsWith(prefix);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN endsWith(String str, String suffix) {
|
||||
public static Boolean endsWith(String str, String suffix) {
|
||||
return str != null && suffix != null && str.endsWith(suffix);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isNumeric(String str) {
|
||||
public static Boolean isNumeric(String str) {
|
||||
if (isEmpty(str)) return false;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (!Character.isDigit(str.charAt(i))) return false;
|
||||
@@ -218,7 +218,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isBlank(String str) {
|
||||
public static Boolean isBlank(String str) {
|
||||
return str == null || str.isBlank();
|
||||
}
|
||||
/**
|
||||
@@ -228,7 +228,7 @@ public class StringUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isNotBlank(String str) {
|
||||
public static Boolean isNotBlank(String str) {
|
||||
return !isBlank(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ public class TimeUtils {
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static BOOLEAN isNowBetween(String startTime, String endTime) {
|
||||
public static Boolean isNowBetween(String startTime, String endTime) {
|
||||
LocalTime now = LocalTime.now();
|
||||
LocalTime start = LocalTime.parse(startTime, DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
LocalTime end = LocalTime.parse(endTime, DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ExcelColumnMapping {
|
||||
/**
|
||||
* @description Excel列索引(从0开始,优先级高于列名)
|
||||
*/
|
||||
private INTEGER columnIndex;
|
||||
private Integer columnIndex;
|
||||
|
||||
/**
|
||||
* @description 对象字段名
|
||||
@@ -37,7 +37,7 @@ public class ExcelColumnMapping {
|
||||
/**
|
||||
* @description 是否必填
|
||||
*/
|
||||
private BOOLEAN required = false;
|
||||
private Boolean required = false;
|
||||
|
||||
/**
|
||||
* @description 默认值
|
||||
@@ -62,7 +62,7 @@ public class ExcelColumnMapping {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public INTEGER getColumnIndex() {
|
||||
public Integer getColumnIndex() {
|
||||
return columnIndex;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ExcelColumnMapping {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
public BOOLEAN isRequired() {
|
||||
public Boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ExcelColumnMapping {
|
||||
/**
|
||||
* 设置是否必填
|
||||
*/
|
||||
public Builder required(BOOLEAN required) {
|
||||
public Builder required(Boolean required) {
|
||||
mapping.required = required;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ExcelReadResult<T> {
|
||||
/**
|
||||
* @description 是否成功
|
||||
*/
|
||||
private BOOLEAN success;
|
||||
private Boolean success;
|
||||
|
||||
/**
|
||||
* @description 成功读取的数据列表
|
||||
@@ -27,7 +27,7 @@ public class ExcelReadResult<T> {
|
||||
/**
|
||||
* @description 失败的行数据(行号 -> 错误信息)
|
||||
*/
|
||||
private Map<INTEGER, String> errorRowsMap;
|
||||
private Map<Integer, String> errorRowsMap;
|
||||
|
||||
/**
|
||||
* @description 总行数(不包括表头)
|
||||
@@ -58,11 +58,11 @@ public class ExcelReadResult<T> {
|
||||
this.errorRowsCount = 0;
|
||||
}
|
||||
|
||||
public BOOLEAN isSuccess() {
|
||||
public Boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(BOOLEAN success) {
|
||||
public void setSuccess(Boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ public class ExcelReadResult<T> {
|
||||
this.dataList = dataList;
|
||||
}
|
||||
|
||||
public Map<INTEGER, String> getErrorRows() {
|
||||
public Map<Integer, String> getErrorRows() {
|
||||
return errorRowsMap;
|
||||
}
|
||||
|
||||
public void setErrorRows(Map<INTEGER, String> errorRowsMap) {
|
||||
public void setErrorRows(Map<Integer, String> errorRowsMap) {
|
||||
this.errorRowsMap = errorRowsMap;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ExcelReadResult<T> {
|
||||
this.errorRowsCount++;
|
||||
}
|
||||
|
||||
public BOOLEAN hasErrors() {
|
||||
public Boolean hasErrors() {
|
||||
return this.errorRowsCount > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ public class ExcelReaderUtils {
|
||||
int dataStartRowIndex = (int) options.getOrDefault("dataStartRowIndex", 1);
|
||||
int sheetIndex = (int) options.getOrDefault("sheetIndex", 0);
|
||||
String sheetName = (String) options.get("sheetName");
|
||||
BOOLEAN skipEmptyRow = (BOOLEAN) options.getOrDefault("skipEmptyRow", true);
|
||||
Boolean skipEmptyRow = (Boolean) options.getOrDefault("skipEmptyRow", true);
|
||||
int maxRows = (int) options.getOrDefault("maxRows", 0);
|
||||
BOOLEAN continueOnError = (BOOLEAN) options.getOrDefault("continueOnError", true);
|
||||
Boolean continueOnError = (Boolean) options.getOrDefault("continueOnError", true);
|
||||
|
||||
// 创建Workbook
|
||||
Workbook workbook = createWorkbook(inputStream, fileName);
|
||||
@@ -113,7 +113,7 @@ public class ExcelReaderUtils {
|
||||
}
|
||||
|
||||
// 解析表头
|
||||
Map<String, INTEGER> headerMap = parseHeader(sheet, headerRowIndex);
|
||||
Map<String, Integer> headerMap = parseHeader(sheet, headerRowIndex);
|
||||
|
||||
// 读取数据
|
||||
readData(sheet, headerMap, targetClass, columnMappings, dataStartRowIndex,
|
||||
@@ -156,8 +156,8 @@ public class ExcelReaderUtils {
|
||||
/**
|
||||
* @description 解析表头
|
||||
*/
|
||||
private static Map<String, INTEGER> parseHeader(Sheet sheet, int headerRowIndex) {
|
||||
Map<String, INTEGER> headerMap = new HashMap<>();
|
||||
private static Map<String, Integer> parseHeader(Sheet sheet, int headerRowIndex) {
|
||||
Map<String, Integer> headerMap = new HashMap<>();
|
||||
Row headerRow = sheet.getRow(headerRowIndex);
|
||||
|
||||
if (headerRow != null) {
|
||||
@@ -175,10 +175,10 @@ public class ExcelReaderUtils {
|
||||
/**
|
||||
* @description 读取数据
|
||||
*/
|
||||
private static void readData(Sheet sheet, Map<String, INTEGER> headerMap,
|
||||
private static void readData(Sheet sheet, Map<String, Integer> headerMap,
|
||||
Class<?> targetClass, List<ExcelColumnMapping> columnMappings,
|
||||
int startRow, BOOLEAN skipEmptyRow, int maxRows,
|
||||
BOOLEAN continueOnError, ExcelReadResult<Object> result) {
|
||||
int startRow, Boolean skipEmptyRow, int maxRows,
|
||||
Boolean continueOnError, ExcelReadResult<Object> result) {
|
||||
int lastRowNum = sheet.getLastRowNum();
|
||||
int endRow = maxRows > 0 ? Math.min(startRow + maxRows, lastRowNum + 1) : lastRowNum + 1;
|
||||
|
||||
@@ -229,7 +229,7 @@ public class ExcelReaderUtils {
|
||||
/**
|
||||
* @description 判断是否为空行
|
||||
*/
|
||||
private static BOOLEAN isEmptyRow(Row row) {
|
||||
private static Boolean isEmptyRow(Row row) {
|
||||
if (row == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public class ExcelReaderUtils {
|
||||
/**
|
||||
* @description 将行数据转换为对象
|
||||
*/
|
||||
private static Object convertRowToObject(Row row, Map<String, INTEGER> headerMap,
|
||||
private static Object convertRowToObject(Row row, Map<String, Integer> headerMap,
|
||||
Class<?> targetClass, List<ExcelColumnMapping> columnMappings,
|
||||
int rowNum) throws Exception {
|
||||
Object obj = targetClass.getDeclaredConstructor().newInstance();
|
||||
@@ -307,7 +307,7 @@ public class ExcelReaderUtils {
|
||||
/**
|
||||
* @description 获取单元格
|
||||
*/
|
||||
private static Cell getCell(Row row, ExcelColumnMapping mapping, Map<String, INTEGER> headerMap) {
|
||||
private static Cell getCell(Row row, ExcelColumnMapping mapping, Map<String, Integer> headerMap) {
|
||||
if (row == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public class ExcelReaderUtils {
|
||||
}
|
||||
|
||||
// 使用列名
|
||||
INTEGER columnIndex = headerMap.get(mapping.getColumnName());
|
||||
Integer columnIndex = headerMap.get(mapping.getColumnName());
|
||||
if (columnIndex != null) {
|
||||
return row.getCell(columnIndex);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ public class ExcelReaderUtils {
|
||||
return cell.getNumericCellValue();
|
||||
}
|
||||
case BOOLEAN:
|
||||
return cell.getBOOLEANCellValue();
|
||||
return cell.getBooleanCellValue();
|
||||
case FORMULA:
|
||||
return cell.getCellFormula();
|
||||
case BLANK:
|
||||
@@ -370,11 +370,11 @@ public class ExcelReaderUtils {
|
||||
}
|
||||
|
||||
// INTEGER类型
|
||||
if (targetType == INTEGER.class || targetType == int.class) {
|
||||
if (targetType == Integer.class || targetType == int.class) {
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
return INTEGER.parseInt(strValue);
|
||||
return Integer.parseInt(strValue);
|
||||
}
|
||||
|
||||
// Long类型
|
||||
@@ -402,11 +402,11 @@ public class ExcelReaderUtils {
|
||||
}
|
||||
|
||||
// BOOLEAN类型
|
||||
if (targetType == BOOLEAN.class || targetType == BOOLEAN.class) {
|
||||
if (value instanceof BOOLEAN) {
|
||||
if (targetType == Boolean.class || targetType == boolean.class) {
|
||||
if (value instanceof Boolean) {
|
||||
return value;
|
||||
}
|
||||
return BOOLEAN.parseBOOLEAN(strValue) || "1".equals(strValue) ||
|
||||
return Boolean.parseBoolean(strValue) || "1".equals(strValue) ||
|
||||
"是".equals(strValue) || "true".equalsIgnoreCase(strValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,19 +20,19 @@ public class ExcelUtilsExample {
|
||||
*/
|
||||
public static class UserInfo {
|
||||
private String name;
|
||||
private INTEGER age;
|
||||
private Integer age;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String idCard;
|
||||
private Date joinDate;
|
||||
private BOOLEAN active;
|
||||
private Boolean active;
|
||||
|
||||
// Getters and Setters
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public INTEGER getAge() { return age; }
|
||||
public void setAge(INTEGER age) { this.age = age; }
|
||||
public Integer getAge() { return age; }
|
||||
public void setAge(Integer age) { this.age = age; }
|
||||
|
||||
public String getPhone() { return phone; }
|
||||
public void setPhone(String phone) { this.phone = phone; }
|
||||
@@ -46,8 +46,8 @@ public class ExcelUtilsExample {
|
||||
public Date getJoinDate() { return joinDate; }
|
||||
public void setJoinDate(Date joinDate) { this.joinDate = joinDate; }
|
||||
|
||||
public BOOLEAN getActive() { return active; }
|
||||
public void setActive(BOOLEAN active) { this.active = active; }
|
||||
public Boolean getActive() { return active; }
|
||||
public void setActive(Boolean active) { this.active = active; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -81,7 +81,7 @@ public class ExcelUtilsExample {
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("年龄")
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.build(),
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ExcelUtilsExample {
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("是否在职")
|
||||
.fieldName("active")
|
||||
.fieldType(BOOLEAN.class)
|
||||
.fieldType(Boolean.class)
|
||||
.defaultValue("true")
|
||||
.build()
|
||||
);
|
||||
@@ -172,7 +172,7 @@ public class ExcelUtilsExample {
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("年龄")
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.addValidation(
|
||||
ValidationParam.builder()
|
||||
@@ -180,7 +180,7 @@ public class ExcelUtilsExample {
|
||||
.fieldLabel("年龄")
|
||||
.required()
|
||||
.customValidator(value -> {
|
||||
INTEGER age = (INTEGER) value;
|
||||
Integer age = (Integer) value;
|
||||
return age >= 18 && age <= 65;
|
||||
})
|
||||
.customErrorMessage("年龄必须在18-65岁之间")
|
||||
@@ -277,7 +277,7 @@ public class ExcelUtilsExample {
|
||||
ExcelColumnMapping.builder()
|
||||
.columnIndex(1) // 第2列
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.build(),
|
||||
|
||||
@@ -316,7 +316,7 @@ public class ExcelUtilsExample {
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("年龄")
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.build()
|
||||
);
|
||||
|
||||
@@ -37,11 +37,11 @@
|
||||
```java
|
||||
public class UserInfo {
|
||||
private String name;
|
||||
private INTEGER age;
|
||||
private Integer age;
|
||||
private String phone;
|
||||
private String email;
|
||||
private Date joinDate;
|
||||
private BOOLEAN active;
|
||||
private Boolean active;
|
||||
|
||||
// Getters and Setters...
|
||||
}
|
||||
@@ -61,7 +61,7 @@ List<ExcelColumnMapping> columnMappings = Arrays.asList(
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("年龄")
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.build(),
|
||||
|
||||
@@ -88,7 +88,7 @@ List<ExcelColumnMapping> columnMappings = Arrays.asList(
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("是否在职")
|
||||
.fieldName("active")
|
||||
.fieldType(BOOLEAN.class)
|
||||
.fieldType(Boolean.class)
|
||||
.defaultValue("true")
|
||||
.build()
|
||||
);
|
||||
@@ -140,7 +140,7 @@ List<ExcelColumnMapping> columnMappings = Arrays.asList(
|
||||
ExcelColumnMapping.builder()
|
||||
.columnName("年龄")
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.addValidation(
|
||||
ValidationParam.builder()
|
||||
@@ -148,7 +148,7 @@ List<ExcelColumnMapping> columnMappings = Arrays.asList(
|
||||
.fieldLabel("年龄")
|
||||
.required()
|
||||
.customValidator(value -> {
|
||||
INTEGER age = (INTEGER) value;
|
||||
Integer age = (Integer) value;
|
||||
return age >= 18 && age <= 65;
|
||||
})
|
||||
.customErrorMessage("年龄必须在18-65岁之间")
|
||||
@@ -227,7 +227,7 @@ List<ExcelColumnMapping> columnMappings = Arrays.asList(
|
||||
ExcelColumnMapping.builder()
|
||||
.columnIndex(1) // 第2列
|
||||
.fieldName("age")
|
||||
.fieldType(INTEGER.class)
|
||||
.fieldType(Integer.class)
|
||||
.required()
|
||||
.build(),
|
||||
|
||||
@@ -282,7 +282,7 @@ List<ValidationParam> validationParams = Arrays.asList(
|
||||
.fieldLabel("年龄")
|
||||
.required()
|
||||
.customValidator(value -> {
|
||||
INTEGER age = (INTEGER) value;
|
||||
Integer age = (Integer) value;
|
||||
return age >= 18 && age <= 65;
|
||||
})
|
||||
.customErrorMessage("年龄必须在18-65岁之间")
|
||||
@@ -422,11 +422,11 @@ public ResultDomain<String> importUsers(@RequestParam("file") MultipartFile file
|
||||
## 支持的数据类型
|
||||
|
||||
- **String** - 字符串
|
||||
- **INTEGER/int** - 整数
|
||||
- **Integer/int** - 整数
|
||||
- **Long/long** - 长整数
|
||||
- **Double/double** - 双精度浮点数
|
||||
- **Float/float** - 单精度浮点数
|
||||
- **BOOLEAN/BOOLEAN** - 布尔值(支持:true/false、1/0、是/否)
|
||||
- **Boolean/Boolean** - 布尔值(支持:true/false、1/0、是/否)
|
||||
- **Date** - 日期(需指定dateFormat)
|
||||
|
||||
## 配置选项
|
||||
@@ -439,7 +439,7 @@ public ResultDomain<String> importUsers(@RequestParam("file") MultipartFile file
|
||||
| columnIndex(int) | 设置Excel列索引(从0开始,优先级高于columnName) | columnName和columnIndex至少一个 |
|
||||
| fieldName(String) | 设置对象字段名 | 是 |
|
||||
| fieldType(Class<?>) | 设置字段类型 | 否(默认String.class) |
|
||||
| required() / required(BOOLEAN) | 设置是否必填 | 否(默认false) |
|
||||
| required() / required(Boolean) | 设置是否必填 | 否(默认false) |
|
||||
| defaultValue(String) | 设置默认值 | 否 |
|
||||
| dateFormat(String) | 设置日期格式 | 否(默认"yyyy-MM-dd") |
|
||||
| addValidation(ValidationParam) | 添加校验参数 | 否 |
|
||||
@@ -455,9 +455,9 @@ public ResultDomain<String> importUsers(@RequestParam("file") MultipartFile file
|
||||
| dataStartRowIndex | int | 数据起始行(从0开始) | 1 |
|
||||
| sheetIndex | int | Sheet索引(从0开始) | 0 |
|
||||
| sheetName | String | Sheet名称(优先级高于sheetIndex) | null |
|
||||
| skipEmptyRow | BOOLEAN | 跳过空行 | true |
|
||||
| skipEmptyRow | Boolean | 跳过空行 | true |
|
||||
| maxRows | int | 最大读取行数(0=不限制) | 0 |
|
||||
| continueOnError | BOOLEAN | 遇到错误继续读取 | true |
|
||||
| continueOnError | Boolean | 遇到错误继续读取 | true |
|
||||
|
||||
## 核心特性
|
||||
|
||||
@@ -480,7 +480,7 @@ public ResultDomain<String> importUsers(@RequestParam("file") MultipartFile file
|
||||
5. **布尔类型**:支持多种格式(true/false、1/0、是/否)
|
||||
6. **错误处理**:根据continueOnError选项决定遇到错误时是否继续
|
||||
7. **文件格式**:支持.xls和.xlsx两种格式
|
||||
8. **类型转换**:自动转换支持String、INTEGER、Long、Double、Float、BOOLEAN、Date
|
||||
8. **类型转换**:自动转换支持String、Interge、Long、Double、Float、Boolean、Date
|
||||
|
||||
## 依赖
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ ValidationParam param = ValidationParam.builder()
|
||||
.fieldLabel("年龄")
|
||||
.required()
|
||||
.customValidator(value -> {
|
||||
INTEGER age = (INTEGER) value;
|
||||
Integer age = (Integer) value;
|
||||
return age >= 18 && age <= 60;
|
||||
})
|
||||
.customErrorMessage("年龄必须在18-60岁之间")
|
||||
@@ -342,7 +342,7 @@ public ResultDomain<User> register(@RequestBody Map<String, Object> params) {
|
||||
public class CustomValidateMethod implements ValidateMethod {
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
// 实现校验逻辑
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ValidationParam {
|
||||
/**
|
||||
* @description 是否必传
|
||||
*/
|
||||
private BOOLEAN required;
|
||||
private Boolean required;
|
||||
|
||||
/**
|
||||
* @description 字段类型
|
||||
@@ -37,12 +37,12 @@ public class ValidationParam {
|
||||
/**
|
||||
* @description 最小长度(字符串)
|
||||
*/
|
||||
private INTEGER minLength;
|
||||
private Integer minLength;
|
||||
|
||||
/**
|
||||
* @description 最大长度(字符串)
|
||||
*/
|
||||
private INTEGER maxLength;
|
||||
private Integer maxLength;
|
||||
|
||||
/**
|
||||
* @description 最小值(数字)
|
||||
@@ -77,7 +77,7 @@ public class ValidationParam {
|
||||
/**
|
||||
* @description 是否允许为空字符串(默认不允许)
|
||||
*/
|
||||
private BOOLEAN allowEmpty = false;
|
||||
private Boolean allowEmpty = false;
|
||||
|
||||
/**
|
||||
* @description 校验方法(使用预定义的校验方法)
|
||||
@@ -106,7 +106,7 @@ public class ValidationParam {
|
||||
return fieldLabel;
|
||||
}
|
||||
|
||||
public BOOLEAN isRequired() {
|
||||
public Boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
@@ -114,11 +114,11 @@ public class ValidationParam {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
public INTEGER getMinLength() {
|
||||
public Integer getMinLength() {
|
||||
return minLength;
|
||||
}
|
||||
|
||||
public INTEGER getMaxLength() {
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class ValidationParam {
|
||||
return customErrorMessage;
|
||||
}
|
||||
|
||||
public BOOLEAN isAllowEmpty() {
|
||||
public Boolean isAllowEmpty() {
|
||||
return allowEmpty;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class ValidationParam {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder required(BOOLEAN required) {
|
||||
public Builder required(Boolean required) {
|
||||
param.required = required;
|
||||
return this;
|
||||
}
|
||||
@@ -193,12 +193,12 @@ public class ValidationParam {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder minLength(INTEGER minLength) {
|
||||
public Builder minLength(Integer minLength) {
|
||||
param.minLength = minLength;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder maxLength(INTEGER maxLength) {
|
||||
public Builder maxLength(Integer maxLength) {
|
||||
param.maxLength = maxLength;
|
||||
return this;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class ValidationParam {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder allowEmpty(BOOLEAN allowEmpty) {
|
||||
public Builder allowEmpty(Boolean allowEmpty) {
|
||||
param.allowEmpty = allowEmpty;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ValidationResult {
|
||||
/**
|
||||
* @description 是否校验通过
|
||||
*/
|
||||
private BOOLEAN valid;
|
||||
private Boolean valid;
|
||||
|
||||
/**
|
||||
* @description 错误信息列表
|
||||
@@ -32,11 +32,11 @@ public class ValidationResult {
|
||||
this.errors = new ArrayList<>();
|
||||
}
|
||||
|
||||
public BOOLEAN isValid() {
|
||||
public Boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void setValid(BOOLEAN valid) {
|
||||
public void setValid(Boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ public class ValidationResult {
|
||||
|
||||
/**
|
||||
* @description 是否有错误
|
||||
* @return BOOLEAN
|
||||
* @return Boolean
|
||||
*/
|
||||
public BOOLEAN hasErrors() {
|
||||
public Boolean hasErrors() {
|
||||
return !valid;
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ public class ValidationUtils {
|
||||
* @param required 是否必填
|
||||
* @return ValidationParam
|
||||
*/
|
||||
public static ValidationParam email(String fieldName, String fieldLabel, BOOLEAN required) {
|
||||
public static ValidationParam email(String fieldName, String fieldLabel, Boolean required) {
|
||||
return ValidationParam.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldLabel(fieldLabel)
|
||||
@@ -307,7 +307,7 @@ public class ValidationUtils {
|
||||
* @param required 是否必填
|
||||
* @return ValidationParam
|
||||
*/
|
||||
public static ValidationParam phone(String fieldName, String fieldLabel, BOOLEAN required) {
|
||||
public static ValidationParam phone(String fieldName, String fieldLabel, Boolean required) {
|
||||
return ValidationParam.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldLabel(fieldLabel)
|
||||
|
||||
@@ -10,7 +10,7 @@ package org.xyzh.common.utils.validation.method;
|
||||
public class BankCardValidateMethod implements ValidateMethod {
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
@@ -34,11 +34,11 @@ public class BankCardValidateMethod implements ValidateMethod {
|
||||
/**
|
||||
* @description Luhn算法校验(银行卡校验算法)
|
||||
* @param cardNumber 银行卡号
|
||||
* @return BOOLEAN 是否通过校验
|
||||
* @return Boolean 是否通过校验
|
||||
*/
|
||||
private BOOLEAN luhnCheck(String cardNumber) {
|
||||
private Boolean luhnCheck(String cardNumber) {
|
||||
int sum = 0;
|
||||
BOOLEAN alternate = false;
|
||||
Boolean alternate = false;
|
||||
|
||||
// 从右向左遍历
|
||||
for (int i = cardNumber.length() - 1; i >= 0; i--) {
|
||||
|
||||
@@ -14,18 +14,18 @@ public class ChineseValidateMethod implements ValidateMethod {
|
||||
// 中文字符正则(包括中文标点符号)
|
||||
private static final Pattern CHINESE_PATTERN = Pattern.compile("^[\u4e00-\u9fa5]+$");
|
||||
|
||||
private final BOOLEAN allowPunctuation; // 是否允许中文标点符号
|
||||
private final Boolean allowPunctuation; // 是否允许中文标点符号
|
||||
|
||||
public ChineseValidateMethod() {
|
||||
this.allowPunctuation = false;
|
||||
}
|
||||
|
||||
public ChineseValidateMethod(BOOLEAN allowPunctuation) {
|
||||
public ChineseValidateMethod(Boolean allowPunctuation) {
|
||||
this.allowPunctuation = allowPunctuation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EmailValidateMethod implements ValidateMethod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class EmailValidateMethod implements ValidateMethod {
|
||||
|
||||
// 域名限制校验
|
||||
if (allowedDomains != null && allowedDomains.length > 0) {
|
||||
BOOLEAN domainMatched = false;
|
||||
Boolean domainMatched = false;
|
||||
for (String domain : allowedDomains) {
|
||||
if (email.endsWith("@" + domain.toLowerCase())) {
|
||||
domainMatched = true;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class IdCardValidateMethod implements ValidateMethod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class IdCardValidateMethod implements ValidateMethod {
|
||||
/**
|
||||
* @description 校验15位身份证
|
||||
*/
|
||||
private BOOLEAN validate15IdCard(String idCard) {
|
||||
private Boolean validate15IdCard(String idCard) {
|
||||
// 15位身份证格式:省(2位)市(2位)县(2位)年(2位)月(2位)日(2位)顺序号(3位)
|
||||
if (!Pattern.matches("^\\d{15}$", idCard)) {
|
||||
return false;
|
||||
@@ -106,7 +106,7 @@ public class IdCardValidateMethod implements ValidateMethod {
|
||||
/**
|
||||
* @description 校验18位身份证
|
||||
*/
|
||||
private BOOLEAN validate18IdCard(String idCard) {
|
||||
private Boolean validate18IdCard(String idCard) {
|
||||
// 18位身份证格式:省(2位)市(2位)县(2位)年(4位)月(2位)日(2位)顺序号(3位)校验码(1位)
|
||||
if (!Pattern.matches("^\\d{17}[0-9Xx]$", idCard)) {
|
||||
return false;
|
||||
@@ -134,11 +134,11 @@ public class IdCardValidateMethod implements ValidateMethod {
|
||||
/**
|
||||
* @description 校验日期是否合法
|
||||
*/
|
||||
private BOOLEAN validateDate(String year, String month, String day) {
|
||||
private Boolean validateDate(String year, String month, String day) {
|
||||
try {
|
||||
int y = INTEGER.parseInt(year);
|
||||
int m = INTEGER.parseInt(month);
|
||||
int d = INTEGER.parseInt(day);
|
||||
int y = Integer.parseInt(year);
|
||||
int m = Integer.parseInt(month);
|
||||
int d = Integer.parseInt(day);
|
||||
|
||||
// 年份范围:1900-当前年份
|
||||
int currentYear = java.time.Year.now().getValue();
|
||||
@@ -168,14 +168,14 @@ public class IdCardValidateMethod implements ValidateMethod {
|
||||
/**
|
||||
* @description 判断是否为闰年
|
||||
*/
|
||||
private BOOLEAN isLeapYear(int year) {
|
||||
private Boolean isLeapYear(int year) {
|
||||
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 校验18位身份证的校验码
|
||||
*/
|
||||
private BOOLEAN validateCheckCode(String idCard) {
|
||||
private Boolean validateCheckCode(String idCard) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 17; i++) {
|
||||
sum += (idCard.charAt(i) - '0') * WEIGHT[i];
|
||||
|
||||
@@ -13,10 +13,10 @@ public class PasswordValidateMethod implements ValidateMethod {
|
||||
|
||||
private final int minLength;
|
||||
private final int maxLength;
|
||||
private final BOOLEAN requireUpperCase;
|
||||
private final BOOLEAN requireLowerCase;
|
||||
private final BOOLEAN requireDigit;
|
||||
private final BOOLEAN requireSpecialChar;
|
||||
private final Boolean requireUpperCase;
|
||||
private final Boolean requireLowerCase;
|
||||
private final Boolean requireDigit;
|
||||
private final Boolean requireSpecialChar;
|
||||
|
||||
/**
|
||||
* @description 默认密码规则:6-20位,必须包含字母和数字
|
||||
@@ -35,8 +35,8 @@ public class PasswordValidateMethod implements ValidateMethod {
|
||||
* @param requireSpecialChar 是否需要特殊字符
|
||||
*/
|
||||
public PasswordValidateMethod(int minLength, int maxLength,
|
||||
BOOLEAN requireUpperCase, BOOLEAN requireLowerCase,
|
||||
BOOLEAN requireDigit, BOOLEAN requireSpecialChar) {
|
||||
Boolean requireUpperCase, Boolean requireLowerCase,
|
||||
Boolean requireDigit, Boolean requireSpecialChar) {
|
||||
this.minLength = minLength;
|
||||
this.maxLength = maxLength;
|
||||
this.requireUpperCase = requireUpperCase;
|
||||
@@ -46,7 +46,7 @@ public class PasswordValidateMethod implements ValidateMethod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class PasswordValidateMethod implements ValidateMethod {
|
||||
|
||||
if (requireUpperCase || requireLowerCase || requireDigit || requireSpecialChar) {
|
||||
msg.append(",且包含");
|
||||
BOOLEAN first = true;
|
||||
Boolean first = true;
|
||||
|
||||
if (requireUpperCase) {
|
||||
msg.append("大写字母");
|
||||
|
||||
@@ -20,18 +20,18 @@ public class PhoneValidateMethod implements ValidateMethod {
|
||||
// 台湾手机号正则
|
||||
private static final Pattern TW_PHONE_PATTERN = Pattern.compile("^09\\d{8}$");
|
||||
|
||||
private final BOOLEAN strictMode; // 严格模式,只验证中国大陆手机号
|
||||
private final Boolean strictMode; // 严格模式,只验证中国大陆手机号
|
||||
|
||||
public PhoneValidateMethod() {
|
||||
this.strictMode = true;
|
||||
}
|
||||
|
||||
public PhoneValidateMethod(BOOLEAN strictMode) {
|
||||
public PhoneValidateMethod(Boolean strictMode) {
|
||||
this.strictMode = strictMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@ public class UrlValidateMethod implements ValidateMethod {
|
||||
"^(https?|ftp)://[a-zA-Z0-9+&@#/%?=~_|!:,.;-]*[a-zA-Z0-9+&@#/%=~_|-]$"
|
||||
);
|
||||
|
||||
private final BOOLEAN requireHttps; // 是否要求HTTPS
|
||||
private final Boolean requireHttps; // 是否要求HTTPS
|
||||
|
||||
public UrlValidateMethod() {
|
||||
this.requireHttps = false;
|
||||
}
|
||||
|
||||
public UrlValidateMethod(BOOLEAN requireHttps) {
|
||||
public UrlValidateMethod(Boolean requireHttps) {
|
||||
this.requireHttps = requireHttps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOOLEAN validate(Object value) {
|
||||
public Boolean validate(Object value) {
|
||||
if (value == null || !(value instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ public interface ValidateMethod {
|
||||
/**
|
||||
* @description 校验方法
|
||||
* @param value 待校验的值
|
||||
* @return BOOLEAN 是否校验通过
|
||||
* @return Boolean 是否校验通过
|
||||
*/
|
||||
BOOLEAN validate(Object value);
|
||||
Boolean validate(Object value);
|
||||
|
||||
/**
|
||||
* @description 获取校验失败的错误提示信息
|
||||
|
||||
Reference in New Issue
Block a user