mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 格式化代码结构 统一编码格式
This commit is contained in:
@ -12,6 +12,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 数据脱敏注解
|
||||
*
|
||||
* @author zhujie
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -15,7 +15,7 @@ public class UnsignedMathGenerator implements CodeGenerator {
|
||||
|
||||
private static final long serialVersionUID = -5514819971774091076L;
|
||||
|
||||
private static final String operators = "+-*";
|
||||
private static final String OPERATORS = "+-*";
|
||||
|
||||
/**
|
||||
* 参与计算数字最大长度
|
||||
@ -48,7 +48,7 @@ public class UnsignedMathGenerator implements CodeGenerator {
|
||||
number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE);
|
||||
number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE);
|
||||
|
||||
return number1 + RandomUtil.randomChar(operators) + number2 + '=';
|
||||
return number1 + RandomUtil.randomChar(OPERATORS) + number2 + '=';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,9 +6,9 @@ import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 数据权限类型
|
||||
*
|
||||
* <p>
|
||||
* 语法支持 spel 模板表达式
|
||||
*
|
||||
* <p>
|
||||
* 内置数据 user 当前用户 内容参考 SysUser
|
||||
* 如需扩展数据 可使用 {@link com.ruoyi.common.helper.DataPermissionHelper} 操作
|
||||
* 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService
|
||||
@ -44,7 +44,7 @@ public enum DataScopeType {
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 ");
|
||||
SELF("5", " #{#userName} = #{#user.userId} ", " 1 = 0 ");
|
||||
|
||||
private final String code;
|
||||
|
||||
|
@ -2,7 +2,9 @@ package com.ruoyi.common.exception.base;
|
||||
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 基础异常
|
||||
|
@ -20,10 +20,10 @@ public class RepeatableFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
throws IOException, ServletException {
|
||||
ServletRequest requestWrapper = null;
|
||||
if (request instanceof HttpServletRequest
|
||||
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
|
||||
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
|
||||
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
||||
}
|
||||
if (null == requestWrapper) {
|
||||
|
@ -33,7 +33,7 @@ public class XssFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
if (handleExcludeURL(req, resp)) {
|
||||
|
@ -24,7 +24,6 @@ public class DataPermissionHelper {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void setVariable(String key, Object value) {
|
||||
Map<String, Object> context = getContext();
|
||||
context.put(key, value);
|
||||
|
@ -16,6 +16,7 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 数据脱敏json序列化工具
|
||||
*
|
||||
* @author Yjoioooo
|
||||
*/
|
||||
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
|
||||
@ -25,7 +26,7 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
||||
if (sensitiveService.isSensitive()){
|
||||
if (sensitiveService.isSensitive()) {
|
||||
gen.writeString(value);
|
||||
} else {
|
||||
gen.writeString(strategy.desensitizer().apply(value));
|
||||
@ -36,7 +37,7 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
|
||||
@Override
|
||||
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
|
||||
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
||||
if (Objects.nonNull(annotation)&&Objects.equals(String.class, property.getType().getRawClass())) {
|
||||
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass())) {
|
||||
this.strategy = annotation.strategy();
|
||||
return this;
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"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"};
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
|
@ -6,6 +6,8 @@ import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.DeviceType;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.UtilException;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 登录鉴权工具
|
||||
@ -13,13 +15,15 @@ import com.ruoyi.common.exception.UtilException;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class LoginUtils {
|
||||
|
||||
private final static String LOGIN_USER_KEY = "loginUser";
|
||||
private static final String LOGIN_USER_KEY = "loginUser";
|
||||
|
||||
/**
|
||||
* 登录系统
|
||||
* 针对两套用户体系
|
||||
*
|
||||
* @param loginUser 登录用户信息
|
||||
*/
|
||||
public static void login(LoginUser loginUser, UserType userType) {
|
||||
@ -30,6 +34,7 @@ public class LoginUtils {
|
||||
/**
|
||||
* 登录系统 基于 设备类型
|
||||
* 针对一套用户体系
|
||||
*
|
||||
* @param loginUser 登录用户信息
|
||||
*/
|
||||
public static void loginByDevice(LoginUser loginUser, UserType userType, DeviceType deviceType) {
|
||||
@ -62,7 +67,7 @@ public class LoginUtils {
|
||||
String replace = "";
|
||||
if (StringUtils.contains(loginId, UserType.SYS_USER.getUserType())) {
|
||||
userId = StringUtils.replace(loginId, UserType.SYS_USER.getUserType(), replace);
|
||||
} else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())){
|
||||
} else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())) {
|
||||
userId = StringUtils.replace(loginId, UserType.APP_USER.getUserType(), replace);
|
||||
} else {
|
||||
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
||||
@ -97,7 +102,7 @@ public class LoginUtils {
|
||||
public static UserType getUserType(Object loginId) {
|
||||
if (StringUtils.contains(loginId.toString(), UserType.SYS_USER.getUserType())) {
|
||||
return UserType.SYS_USER;
|
||||
} else if (StringUtils.contains(loginId.toString(), UserType.APP_USER.getUserType())){
|
||||
} else if (StringUtils.contains(loginId.toString(), UserType.APP_USER.getUserType())) {
|
||||
return UserType.APP_USER;
|
||||
} else {
|
||||
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
||||
|
@ -29,11 +29,11 @@ public class FileUtils extends FileUtil {
|
||||
|
||||
StringBuilder contentDispositionValue = new StringBuilder();
|
||||
contentDispositionValue.append("attachment; filename=")
|
||||
.append(percentEncodedFileName)
|
||||
.append(";")
|
||||
.append("filename*=")
|
||||
.append("utf-8''")
|
||||
.append(percentEncodedFileName);
|
||||
.append(percentEncodedFileName)
|
||||
.append(";")
|
||||
.append("filename*=")
|
||||
.append("utf-8''")
|
||||
.append(percentEncodedFileName);
|
||||
|
||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
||||
|
@ -41,9 +41,9 @@ public class AddressUtils {
|
||||
if (RuoYiConfig.isAddressEnabled()) {
|
||||
try {
|
||||
String rspStr = HttpUtil.createGet(IP_URL)
|
||||
.body("ip=" + ip + "&json=true", Constants.GBK)
|
||||
.execute()
|
||||
.body();
|
||||
.body("ip=" + ip + "&json=true", Constants.GBK)
|
||||
.execute()
|
||||
.body();
|
||||
if (StringUtils.isEmpty(rspStr)) {
|
||||
log.error("获取地理位置异常 {}", ip);
|
||||
return UNKNOWN;
|
||||
|
@ -130,7 +130,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 注册对象监听器
|
||||
*
|
||||
* <p>
|
||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
@ -223,7 +223,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 注册List监听器
|
||||
*
|
||||
* <p>
|
||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
@ -259,7 +259,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 注册Set监听器
|
||||
*
|
||||
* <p>
|
||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
@ -296,7 +296,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 注册Map监听器
|
||||
*
|
||||
* <p>
|
||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
|
@ -16,7 +16,7 @@ public class SqlUtil {
|
||||
/**
|
||||
* 定义常用的 sql关键字
|
||||
*/
|
||||
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
|
||||
public static final String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
|
||||
|
||||
/**
|
||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
||||
|
Reference in New Issue
Block a user