update 优化 与 vue 版本同步代码结构
parent
e388a8ed44
commit
4e590b155a
11
pom.xml
11
pom.xml
|
|
@ -254,17 +254,6 @@
|
||||||
<groupId>org.redisson</groupId>
|
<groupId>org.redisson</groupId>
|
||||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
<version>${redisson.version}</version>
|
<version>${redisson.version}</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson-spring-data-30</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson-spring-data-27</artifactId>
|
|
||||||
<version>${redisson.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package org.dromara.system.api.model;
|
package org.dromara.system.api.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import org.dromara.common.core.constant.CacheConstants;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
|
@ -122,7 +120,7 @@ public class LoginUser implements Serializable {
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
throw new IllegalArgumentException("用户ID不能为空");
|
throw new IllegalArgumentException("用户ID不能为空");
|
||||||
}
|
}
|
||||||
return userType + CacheConstants.LOGINID_JOIN_CODE + userId;
|
return userType + ":" + userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -12,18 +12,17 @@
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common-core核心模块
|
ruoyi-common-core 核心模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Spring框架基本的核心工具 -->
|
||||||
<!-- Spring Context Support -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-support</artifactId>
|
<artifactId>spring-context-support</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring Web -->
|
<!-- SpringWeb模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
|
|
@ -50,7 +49,7 @@
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Apache Lang3 -->
|
<!--常用工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
|
@ -67,17 +66,6 @@
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 离线IP地址定位库 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-core</artifactId>
|
||||||
|
|
@ -93,17 +81,40 @@
|
||||||
<artifactId>hutool-extra</artifactId>
|
<artifactId>hutool-extra</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-json</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 自动生成YML配置关联JSON文件 -->
|
<!-- 自动生成YML配置关联JSON文件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.linpeilie</groupId>
|
<groupId>io.github.linpeilie</groupId>
|
||||||
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
|
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 离线IP地址定位库 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lionsoul</groupId>
|
||||||
|
<artifactId>ip2region</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package org.dromara.common.core.config;
|
||||||
|
|
||||||
import jakarta.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
import org.hibernate.validator.HibernateValidator;
|
import org.hibernate.validator.HibernateValidator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
@ -18,14 +17,11 @@ import java.util.Properties;
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
public class ValidatorConfig {
|
public class ValidatorConfig {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MessageSource messageSource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置校验框架 快速返回模式
|
* 配置校验框架 快速返回模式
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Validator validator() {
|
public Validator validator(MessageSource messageSource) {
|
||||||
try (LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean()) {
|
try (LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean()) {
|
||||||
// 国际化
|
// 国际化
|
||||||
factoryBean.setValidationMessageSource(messageSource);
|
factoryBean.setValidationMessageSource(messageSource);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package org.dromara.common.core.constant;
|
package org.dromara.common.core.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存常量信息
|
* 缓存的key 常量
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
@ -12,16 +12,6 @@ public interface CacheConstants {
|
||||||
*/
|
*/
|
||||||
String ONLINE_TOKEN_KEY = "online_tokens:";
|
String ONLINE_TOKEN_KEY = "online_tokens:";
|
||||||
|
|
||||||
/**
|
|
||||||
* loginid构造拼接字符串
|
|
||||||
*/
|
|
||||||
String LOGINID_JOIN_CODE = ":";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码 redis key
|
|
||||||
*/
|
|
||||||
String CAPTCHA_CODE_KEY = "captcha_codes:";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数管理 cache key
|
* 参数管理 cache key
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,8 +22,4 @@ public interface CacheConstants {
|
||||||
*/
|
*/
|
||||||
String SYS_DICT_KEY = "sys_dict:";
|
String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录账户密码错误次数 redis key
|
|
||||||
*/
|
|
||||||
String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,6 @@ public interface GlobalConstants {
|
||||||
*/
|
*/
|
||||||
String GLOBAL_REDIS_KEY = "global:";
|
String GLOBAL_REDIS_KEY = "global:";
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户 redis key
|
|
||||||
*/
|
|
||||||
String LOGIN_TOKEN_KEY = GLOBAL_REDIS_KEY + "Authorization:login:token:";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码 redis key
|
* 验证码 redis key
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ package org.dromara.common.core.constant;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface UserConstants {
|
public interface UserConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台内系统用户的唯一标志
|
* 平台内系统用户的唯一标志
|
||||||
*/
|
*/
|
||||||
|
|
@ -115,18 +116,17 @@ public interface UserConstants {
|
||||||
* 用户名长度限制
|
* 用户名长度限制
|
||||||
*/
|
*/
|
||||||
int USERNAME_MIN_LENGTH = 2;
|
int USERNAME_MIN_LENGTH = 2;
|
||||||
|
|
||||||
int USERNAME_MAX_LENGTH = 20;
|
int USERNAME_MAX_LENGTH = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码长度限制
|
* 密码长度限制
|
||||||
*/
|
*/
|
||||||
int PASSWORD_MIN_LENGTH = 5;
|
int PASSWORD_MIN_LENGTH = 5;
|
||||||
|
|
||||||
int PASSWORD_MAX_LENGTH = 20;
|
int PASSWORD_MAX_LENGTH = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员ID
|
* 超级管理员ID
|
||||||
*/
|
*/
|
||||||
Long SUPER_ADMIN_ID = 1L;
|
Long SUPER_ADMIN_ID = 1L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,18 @@ import lombok.Getter;
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum UserStatus {
|
public enum UserStatus {
|
||||||
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
|
/**
|
||||||
|
* 正常
|
||||||
|
*/
|
||||||
|
OK("0", "正常"),
|
||||||
|
/**
|
||||||
|
* 停用
|
||||||
|
*/
|
||||||
|
DISABLE("1", "停用"),
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
DELETED("2", "删除");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
private final String info;
|
private final String info;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class DemoModeException extends RuntimeException {
|
public class DemoModeException extends RuntimeException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public final class ServiceException extends RuntimeException {
|
public final class ServiceException extends RuntimeException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
@ -64,4 +65,3 @@ public final class ServiceException extends RuntimeException {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UtilException extends RuntimeException {
|
public class UtilException extends RuntimeException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 8247610319171014183L;
|
private static final long serialVersionUID = 8247610319171014183L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileException extends BaseException {
|
public class FileException extends BaseException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileNameLengthLimitExceededException extends FileException {
|
public class FileNameLengthLimitExceededException extends FileException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileSizeLimitExceededException extends FileException {
|
public class FileSizeLimitExceededException extends FileException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class CaptchaExpireException extends UserException {
|
public class CaptchaExpireException extends UserException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,10 @@ import java.io.Serial;
|
||||||
/**
|
/**
|
||||||
* 用户信息异常类
|
* 用户信息异常类
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserException extends BaseException {
|
public class UserException extends BaseException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serial;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserPasswordNotMatchException extends UserException {
|
public class UserPasswordNotMatchException extends UserException {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算相差天数
|
||||||
|
*/
|
||||||
|
public static int differentDaysByMillisecond(Date date1, Date date2) {
|
||||||
|
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个时间差
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ public final class SpringUtils extends SpringUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
|
* 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
public static boolean containsBean(String name) {
|
public static boolean containsBean(String name) {
|
||||||
return getBeanFactory().containsBean(name);
|
return getBeanFactory().containsBean(name);
|
||||||
|
|
@ -25,16 +22,12 @@ public final class SpringUtils extends SpringUtil {
|
||||||
/**
|
/**
|
||||||
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。
|
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。
|
||||||
* 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
|
* 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
|
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
|
||||||
return getBeanFactory().isSingleton(name);
|
return getBeanFactory().isSingleton(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
|
||||||
* @return Class 注册对象的类型
|
* @return Class 注册对象的类型
|
||||||
*/
|
*/
|
||||||
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
|
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
|
||||||
|
|
@ -43,8 +36,6 @@ public final class SpringUtils extends SpringUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果给定的bean名字在bean定义中有别名,则返回这些别名
|
* 如果给定的bean名字在bean定义中有别名,则返回这些别名
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
*/
|
||||||
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
|
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
|
||||||
return getBeanFactory().getAliases(name);
|
return getBeanFactory().getAliases(name);
|
||||||
|
|
@ -52,15 +43,13 @@ public final class SpringUtils extends SpringUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取aop代理对象
|
* 获取aop代理对象
|
||||||
*
|
|
||||||
* @param invoker
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T getAopProxy(T invoker) {
|
public static <T> T getAopProxy(T invoker) {
|
||||||
return (T) AopContext.currentProxy();
|
return (T) AopContext.currentProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取spring上下文
|
* 获取spring上下文
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package org.dromara.common.core.utils;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
|
@ -31,6 +30,7 @@ public class StreamUtils {
|
||||||
if (CollUtil.isEmpty(collection)) {
|
if (CollUtil.isEmpty(collection)) {
|
||||||
return CollUtil.newArrayList();
|
return CollUtil.newArrayList();
|
||||||
}
|
}
|
||||||
|
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||||
return collection.stream().filter(function).collect(Collectors.toList());
|
return collection.stream().filter(function).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class StreamUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> String join(Collection<E> collection, Function<E, String> function, CharSequence delimiter) {
|
public static <E> String join(Collection<E> collection, Function<E, String> function, CharSequence delimiter) {
|
||||||
if (CollUtil.isEmpty(collection)) {
|
if (CollUtil.isEmpty(collection)) {
|
||||||
return StrUtil.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
return collection.stream().map(function).filter(Objects::nonNull).collect(Collectors.joining(delimiter));
|
return collection.stream().map(function).filter(Objects::nonNull).collect(Collectors.joining(delimiter));
|
||||||
}
|
}
|
||||||
|
|
@ -71,6 +71,7 @@ public class StreamUtils {
|
||||||
if (CollUtil.isEmpty(collection)) {
|
if (CollUtil.isEmpty(collection)) {
|
||||||
return CollUtil.newArrayList();
|
return CollUtil.newArrayList();
|
||||||
}
|
}
|
||||||
|
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||||
return collection.stream().sorted(comparing).collect(Collectors.toList());
|
return collection.stream().sorted(comparing).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,6 +190,7 @@ public class StreamUtils {
|
||||||
.stream()
|
.stream()
|
||||||
.map(function)
|
.map(function)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package org.dromara.common.core.utils.file;
|
package org.dromara.common.core.utils.file;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
@ -22,22 +21,12 @@ public class FileUtils extends FileUtil {
|
||||||
*
|
*
|
||||||
* @param response 响应对象
|
* @param response 响应对象
|
||||||
* @param realFileName 真实文件名
|
* @param realFileName 真实文件名
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException {
|
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) {
|
||||||
String percentEncodedFileName = percentEncode(realFileName);
|
String percentEncodedFileName = percentEncode(realFileName);
|
||||||
|
String contentDispositionValue = "attachment; filename=%s;filename*=utf-8''%s".formatted(percentEncodedFileName, percentEncodedFileName);
|
||||||
StringBuilder contentDispositionValue = new StringBuilder();
|
|
||||||
contentDispositionValue.append("attachment; filename=")
|
|
||||||
.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");
|
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
||||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
response.setHeader("Content-disposition", contentDispositionValue);
|
||||||
response.setHeader("download-filename", percentEncodedFileName);
|
response.setHeader("download-filename", percentEncodedFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,5 @@ public class RegionUtils {
|
||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import java.lang.annotation.Target;
|
||||||
/**
|
/**
|
||||||
* 自定义xss校验注解
|
* 自定义xss校验注解
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
||||||
|
|
@ -22,4 +22,5 @@ public @interface Xss {
|
||||||
Class<?>[] groups() default {};
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -12,12 +12,11 @@
|
||||||
<artifactId>ruoyi-common-doc</artifactId>
|
<artifactId>ruoyi-common-doc</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common-swagger系统接口
|
ruoyi-common-doc 系统接口
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- SpringBoot core -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
|
|
@ -39,4 +38,5 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk15to18</artifactId>
|
<artifactId>bcprov-jdk15to18</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -15,8 +15,7 @@
|
||||||
ruoyi-common-excel
|
ruoyi-common-excel
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-json</artifactId>
|
<artifactId>ruoyi-common-json</artifactId>
|
||||||
|
|
@ -26,6 +25,6 @@
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.dromara.common.excel.annotation;
|
package org.dromara.common.excel.annotation;
|
||||||
|
|
||||||
|
|
||||||
import org.dromara.common.excel.core.CellMergeStrategy;
|
import org.dromara.common.excel.core.CellMergeStrategy;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
import org.dromara.common.core.service.DictService;
|
import org.dromara.common.core.service.DictService;
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
|
||||||
import org.dromara.common.excel.utils.ExcelUtil;
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.alibaba.excel.metadata.Head;
|
import com.alibaba.excel.metadata.Head;
|
||||||
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
||||||
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
@ -12,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||||
import org.dromara.common.excel.annotation.CellMerge;
|
import org.dromara.common.excel.annotation.CellMerge;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ import com.alibaba.excel.exception.ExcelAnalysisException;
|
||||||
import com.alibaba.excel.exception.ExcelDataConvertException;
|
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.ValidatorUtils;
|
import org.dromara.common.core.utils.ValidatorUtils;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
|
|
||||||
import jakarta.validation.ConstraintViolation;
|
import jakarta.validation.ConstraintViolation;
|
||||||
import jakarta.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
|
||||||
private ExcelResult<T> excelResult;
|
private ExcelResult<T> excelResult;
|
||||||
|
|
||||||
public DefaultExcelListener(boolean isValidate) {
|
public DefaultExcelListener(boolean isValidate) {
|
||||||
this.excelResult = new DefautExcelResult<>();
|
this.excelResult = new DefaultExcelResult<>();
|
||||||
this.isValidate = isValidate;
|
this.isValidate = isValidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||||
* @author Yjoioooo
|
* @author Yjoioooo
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public class DefautExcelResult<T> implements ExcelResult<T> {
|
public class DefaultExcelResult<T> implements ExcelResult<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据对象list
|
* 数据对象list
|
||||||
|
|
@ -26,17 +26,17 @@ public class DefautExcelResult<T> implements ExcelResult<T> {
|
||||||
@Setter
|
@Setter
|
||||||
private List<String> errorList;
|
private List<String> errorList;
|
||||||
|
|
||||||
public DefautExcelResult() {
|
public DefaultExcelResult() {
|
||||||
this.list = new ArrayList<>();
|
this.list = new ArrayList<>();
|
||||||
this.errorList = new ArrayList<>();
|
this.errorList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefautExcelResult(List<T> list, List<String> errorList) {
|
public DefaultExcelResult(List<T> list, List<String> errorList) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.errorList = errorList;
|
this.errorList = errorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefautExcelResult(ExcelResult<T> excelResult) {
|
public DefaultExcelResult(ExcelResult<T> excelResult) {
|
||||||
this.list = excelResult.getList();
|
this.list = excelResult.getList();
|
||||||
this.errorList = excelResult.getErrorList();
|
this.errorList = excelResult.getErrorList();
|
||||||
}
|
}
|
||||||
|
|
@ -17,15 +17,14 @@ import org.dromara.common.excel.core.CellMergeStrategy;
|
||||||
import org.dromara.common.excel.core.DefaultExcelListener;
|
import org.dromara.common.excel.core.DefaultExcelListener;
|
||||||
import org.dromara.common.excel.core.ExcelListener;
|
import org.dromara.common.excel.core.ExcelListener;
|
||||||
import org.dromara.common.excel.core.ExcelResult;
|
import org.dromara.common.excel.core.ExcelResult;
|
||||||
|
import jakarta.servlet.ServletOutputStream;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import jakarta.servlet.ServletOutputStream;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -254,7 +253,7 @@ public class ExcelUtil {
|
||||||
/**
|
/**
|
||||||
* 重置响应体
|
* 重置响应体
|
||||||
*/
|
*/
|
||||||
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
|
private static void resetResponse(String sheetName, HttpServletResponse response) {
|
||||||
String filename = encodingFilename(sheetName);
|
String filename = encodingFilename(sheetName);
|
||||||
FileUtils.setAttachmentResponseHeader(response, filename);
|
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -15,8 +15,7 @@
|
||||||
ruoyi-common-idempotent 幂等功能
|
ruoyi-common-idempotent 幂等功能
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-json</artifactId>
|
<artifactId>ruoyi-common-json</artifactId>
|
||||||
|
|
@ -27,15 +26,16 @@
|
||||||
<artifactId>ruoyi-common-redis</artifactId>
|
<artifactId>ruoyi-common-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-crypto</artifactId>
|
<artifactId>hutool-crypto</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.dev33</groupId>
|
||||||
|
<artifactId>sa-token-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,6 @@ package org.dromara.common.idempotent.aspectj;
|
||||||
import cn.dev33.satoken.SaManager;
|
import cn.dev33.satoken.SaManager;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import org.aspectj.lang.JoinPoint;
|
|
||||||
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.GlobalConstants;
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
|
@ -17,11 +12,16 @@ import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
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.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -39,8 +39,10 @@ public class RepeatSubmitAspect {
|
||||||
@Before("@annotation(repeatSubmit)")
|
@Before("@annotation(repeatSubmit)")
|
||||||
public void doBefore(JoinPoint point, RepeatSubmit repeatSubmit) throws Throwable {
|
public void doBefore(JoinPoint point, RepeatSubmit repeatSubmit) throws Throwable {
|
||||||
// 如果注解不为0 则使用注解数值
|
// 如果注解不为0 则使用注解数值
|
||||||
long interval = repeatSubmit.timeUnit().toMillis(repeatSubmit.interval());
|
long interval = 0;
|
||||||
|
if (repeatSubmit.interval() > 0) {
|
||||||
|
interval = repeatSubmit.timeUnit().toMillis(repeatSubmit.interval());
|
||||||
|
}
|
||||||
if (interval < 1000) {
|
if (interval < 1000) {
|
||||||
throw new ServiceException("重复提交间隔时间不能小于'1'秒");
|
throw new ServiceException("重复提交间隔时间不能小于'1'秒");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<artifactId>ruoyi-common-log</artifactId>
|
<artifactId>ruoyi-common-log</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common-log日志记录
|
ruoyi-common-log 日志记录
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
@ -27,6 +27,11 @@
|
||||||
<artifactId>ruoyi-common-json</artifactId>
|
<artifactId>ruoyi-common-json</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>transmittable-thread-local</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dubbo</groupId>
|
<groupId>org.apache.dubbo</groupId>
|
||||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||||
|
|
@ -34,4 +39,5 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ public @interface Log {
|
||||||
*/
|
*/
|
||||||
boolean isSaveResponseData() default true;
|
boolean isSaveResponseData() default true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排除指定的请求参数
|
* 排除指定的请求参数
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,27 +3,29 @@ package org.dromara.common.log.aspect;
|
||||||
import cn.hutool.core.lang.Dict;
|
import cn.hutool.core.lang.Dict;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||||
import org.dromara.common.core.utils.ServletUtils;
|
import org.dromara.common.core.utils.ServletUtils;
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.dromara.common.log.annotation.Log;
|
import org.dromara.common.log.annotation.Log;
|
||||||
import org.dromara.common.log.enums.BusinessStatus;
|
import org.dromara.common.log.enums.BusinessStatus;
|
||||||
import org.dromara.common.log.event.OperLogEvent;
|
import org.dromara.common.log.event.OperLogEvent;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.time.StopWatch;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
import org.aspectj.lang.annotation.AfterThrowing;
|
import org.aspectj.lang.annotation.AfterThrowing;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -42,6 +44,22 @@ public class LogAspect {
|
||||||
*/
|
*/
|
||||||
public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
|
public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算操作消耗时间
|
||||||
|
*/
|
||||||
|
private static final ThreadLocal<StopWatch> TIME_THREADLOCAL = new TransmittableThreadLocal<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理请求前执行
|
||||||
|
*/
|
||||||
|
@Before(value = "@annotation(controllerLog)")
|
||||||
|
public void boBefore(JoinPoint joinPoint, Log controllerLog) {
|
||||||
|
StopWatch stopWatch = new StopWatch();
|
||||||
|
TIME_THREADLOCAL.set(stopWatch);
|
||||||
|
stopWatch.start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理完请求后执行
|
* 处理完请求后执行
|
||||||
*
|
*
|
||||||
|
|
@ -65,6 +83,7 @@ public class LogAspect {
|
||||||
|
|
||||||
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
|
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// *========数据库日志=========*//
|
// *========数据库日志=========*//
|
||||||
OperLogEvent operLog = new OperLogEvent();
|
OperLogEvent operLog = new OperLogEvent();
|
||||||
operLog.setTenantId(LoginHelper.getTenantId());
|
operLog.setTenantId(LoginHelper.getTenantId());
|
||||||
|
|
@ -72,7 +91,6 @@ public class LogAspect {
|
||||||
// 请求的地址
|
// 请求的地址
|
||||||
String ip = ServletUtils.getClientIP();
|
String ip = ServletUtils.getClientIP();
|
||||||
operLog.setOperIp(ip);
|
operLog.setOperIp(ip);
|
||||||
operLog.setOperLocation(AddressUtils.getRealAddressByIP(ip));
|
|
||||||
operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
|
operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
|
||||||
operLog.setOperName(LoginHelper.getUsername());
|
operLog.setOperName(LoginHelper.getUsername());
|
||||||
|
|
||||||
|
|
@ -88,12 +106,18 @@ public class LogAspect {
|
||||||
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
||||||
// 处理设置注解上的参数
|
// 处理设置注解上的参数
|
||||||
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
||||||
|
// 设置消耗时间
|
||||||
|
StopWatch stopWatch = TIME_THREADLOCAL.get();
|
||||||
|
stopWatch.stop();
|
||||||
|
operLog.setCostTime(stopWatch.getTime());
|
||||||
// 发布事件保存数据库
|
// 发布事件保存数据库
|
||||||
SpringUtils.context().publishEvent(operLog);
|
SpringUtils.context().publishEvent(operLog);
|
||||||
} catch (Exception exp) {
|
} catch (Exception exp) {
|
||||||
// 记录本地异常日志
|
// 记录本地异常日志
|
||||||
log.error("异常信息:{}", exp.getMessage());
|
log.error("异常信息:{}", exp.getMessage());
|
||||||
exp.printStackTrace();
|
exp.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
TIME_THREADLOCAL.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +156,7 @@ public class LogAspect {
|
||||||
Map<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
Map<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
||||||
String requestMethod = operLog.getRequestMethod();
|
String requestMethod = operLog.getRequestMethod();
|
||||||
if (MapUtil.isEmpty(paramsMap)
|
if (MapUtil.isEmpty(paramsMap)
|
||||||
&& HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) {
|
&& HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) {
|
||||||
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
||||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -15,8 +15,7 @@
|
||||||
ruoyi-common-mail 邮件模块
|
ruoyi-common-mail 邮件模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
|
|
@ -30,6 +29,6 @@
|
||||||
<groupId>org.eclipse.angus</groupId>
|
<groupId>org.eclipse.angus</groupId>
|
||||||
<artifactId>jakarta.mail</artifactId>
|
<artifactId>jakarta.mail</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
ruoyi-common-mybatis 数据库服务
|
ruoyi-common-mybatis 数据库服务
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-satoken</artifactId>
|
<artifactId>ruoyi-common-satoken</artifactId>
|
||||||
|
|
@ -67,4 +67,5 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.apache.ibatis.logging.Log;
|
import org.apache.ibatis.logging.Log;
|
||||||
import org.apache.ibatis.logging.LogFactory;
|
import org.apache.ibatis.logging.LogFactory;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class TableDataInfo<T> implements Serializable {
|
public class TableDataInfo<T> implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,15 @@ package org.dromara.common.mybatis.enums;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限类型
|
* 数据权限类型
|
||||||
* <p>
|
* <p>
|
||||||
* 语法支持 spel 模板表达式
|
* 语法支持 spel 模板表达式
|
||||||
* <p>
|
* <p>
|
||||||
* 内置数据 user 当前用户 内容参考 SysUser
|
* 内置数据 user 当前用户 内容参考 LoginUser
|
||||||
* 如需扩展数据 可使用 {@link org.dromara.common.mybatis.helper.DataPermissionHelper} 操作
|
* 如需扩展数据 可使用 {@link DataPermissionHelper} 操作
|
||||||
* 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService
|
* 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService
|
||||||
* 如需扩展更多自定义服务 可以参考 sdss 自行编写
|
* 如需扩展更多自定义服务 可以参考 sdss 自行编写
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,8 @@ public class PlusDataPermissionHandler {
|
||||||
currentUser = LoginHelper.getLoginUser();
|
currentUser = LoginHelper.getLoginUser();
|
||||||
DataPermissionHelper.setVariable("user", currentUser);
|
DataPermissionHelper.setVariable("user", currentUser);
|
||||||
}
|
}
|
||||||
// 如果是超级管理员,则不过滤数据
|
// 如果是超级管理员或租户管理员,则不过滤数据
|
||||||
if (ObjectUtil.isNull(currentUser) || LoginHelper.isSuperAdmin(currentUser.getUserId())) {
|
if (LoginHelper.isSuperAdmin() || LoginHelper.isTenantAdmin()) {
|
||||||
return where;
|
return where;
|
||||||
}
|
}
|
||||||
String dataFilterSql = buildDataFilter(dataColumns, isSelect);
|
String dataFilterSql = buildDataFilter(dataColumns, isSelect);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import java.sql.DatabaseMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库助手
|
* 数据库助手
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ public class DataPermissionHelper {
|
||||||
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
|
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
|
||||||
attribute = saStorage.get(DATA_PERMISSION_KEY);
|
attribute = saStorage.get(DATA_PERMISSION_KEY);
|
||||||
}
|
}
|
||||||
if (attribute instanceof Map) {
|
if (attribute instanceof Map map) {
|
||||||
return (Map<String, Object>) attribute;
|
return map;
|
||||||
}
|
}
|
||||||
throw new NullPointerException("data permission context type exception");
|
throw new NullPointerException("data permission context type exception");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ public class PlusDataPermissionInterceptor extends JsqlParserSupport implements
|
||||||
@Override
|
@Override
|
||||||
protected void processSelect(Select select, int index, String sql, Object obj) {
|
protected void processSelect(Select select, int index, String sql, Object obj) {
|
||||||
SelectBody selectBody = select.getSelectBody();
|
SelectBody selectBody = select.getSelectBody();
|
||||||
if (selectBody instanceof PlainSelect) {
|
if (selectBody instanceof PlainSelect plainSelect) {
|
||||||
this.setWhere((PlainSelect) selectBody, (String) obj);
|
this.setWhere(plainSelect, (String) obj);
|
||||||
} else if (selectBody instanceof SetOperationList setOperationList) {
|
} else if (selectBody instanceof SetOperationList setOperationList) {
|
||||||
List<SelectBody> selectBodyList = setOperationList.getSelects();
|
List<SelectBody> selectBodyList = setOperationList.getSelects();
|
||||||
selectBodyList.forEach(s -> this.setWhere((PlainSelect) s, (String) obj));
|
selectBodyList.forEach(s -> this.setWhere((PlainSelect) s, (String) obj));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -15,8 +15,7 @@
|
||||||
ruoyi-common-oss oss服务
|
ruoyi-common-oss oss服务
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-json</artifactId>
|
<artifactId>ruoyi-common-json</artifactId>
|
||||||
|
|
@ -31,6 +30,6 @@
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class OssClient {
|
||||||
.withClientConfiguration(clientConfig)
|
.withClientConfiguration(clientConfig)
|
||||||
.withCredentials(credentialsProvider)
|
.withCredentials(credentialsProvider)
|
||||||
.disableChunkedEncoding();
|
.disableChunkedEncoding();
|
||||||
if (!StringUtils.containsAny(properties.getEndpoint(), OssConstant.CLOUD_SERVICE)){
|
if (!StringUtils.containsAny(properties.getEndpoint(), OssConstant.CLOUD_SERVICE)) {
|
||||||
// minio 使用https限制使用域名访问 需要此配置 站点填域名
|
// minio 使用https限制使用域名访问 需要此配置 站点填域名
|
||||||
build.enablePathStyleAccess();
|
build.enablePathStyleAccess();
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +171,7 @@ public class OssClient {
|
||||||
String endpoint = properties.getEndpoint();
|
String endpoint = properties.getEndpoint();
|
||||||
String header = OssConstant.IS_HTTPS.equals(properties.getIsHttps()) ? "https://" : "http://";
|
String header = OssConstant.IS_HTTPS.equals(properties.getIsHttps()) ? "https://" : "http://";
|
||||||
// 云服务商直接返回
|
// 云服务商直接返回
|
||||||
if (StringUtils.containsAny(endpoint, OssConstant.CLOUD_SERVICE)){
|
if (StringUtils.containsAny(endpoint, OssConstant.CLOUD_SERVICE)) {
|
||||||
if (StringUtils.isNotBlank(domain)) {
|
if (StringUtils.isNotBlank(domain)) {
|
||||||
return header + domain;
|
return header + domain;
|
||||||
}
|
}
|
||||||
|
|
@ -231,16 +231,14 @@ public class OssClient {
|
||||||
return AccessPolicyType.getByType(properties.getAccessPolicy());
|
return AccessPolicyType.getByType(properties.getAccessPolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getPolicy(String bucketName, PolicyType policyType) {
|
private static String getPolicy(String bucketName, PolicyType policyType) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("{\n\"Statement\": [\n{\n\"Action\": [\n");
|
builder.append("{\n\"Statement\": [\n{\n\"Action\": [\n");
|
||||||
switch (policyType) {
|
builder.append(switch (policyType) {
|
||||||
case WRITE -> builder.append("\"s3:GetBucketLocation\",\n\"s3:ListBucketMultipartUploads\"\n");
|
case WRITE -> "\"s3:GetBucketLocation\",\n\"s3:ListBucketMultipartUploads\"\n";
|
||||||
case READ_WRITE ->
|
case READ_WRITE -> "\"s3:GetBucketLocation\",\n\"s3:ListBucket\",\n\"s3:ListBucketMultipartUploads\"\n";
|
||||||
builder.append("\"s3:GetBucketLocation\",\n\"s3:ListBucket\",\n\"s3:ListBucketMultipartUploads\"\n");
|
default -> "\"s3:GetBucketLocation\"\n";
|
||||||
default -> builder.append("\"s3:GetBucketLocation\"\n");
|
});
|
||||||
}
|
|
||||||
builder.append("],\n\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::");
|
builder.append("],\n\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::");
|
||||||
builder.append(bucketName);
|
builder.append(bucketName);
|
||||||
builder.append("\"\n},\n");
|
builder.append("\"\n},\n");
|
||||||
|
|
@ -250,13 +248,11 @@ public class OssClient {
|
||||||
builder.append("\"\n},\n");
|
builder.append("\"\n},\n");
|
||||||
}
|
}
|
||||||
builder.append("{\n\"Action\": ");
|
builder.append("{\n\"Action\": ");
|
||||||
switch (policyType) {
|
builder.append(switch (policyType) {
|
||||||
case WRITE ->
|
case WRITE -> "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n";
|
||||||
builder.append("[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n");
|
case READ_WRITE -> "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n";
|
||||||
case READ_WRITE ->
|
default -> "\"s3:GetObject\",\n";
|
||||||
builder.append("[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n");
|
});
|
||||||
default -> builder.append("\"s3:GetObject\",\n");
|
|
||||||
}
|
|
||||||
builder.append("\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::");
|
builder.append("\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::");
|
||||||
builder.append(bucketName);
|
builder.append(bucketName);
|
||||||
builder.append("/*\"\n}\n],\n\"Version\": \"2012-10-17\"\n}\n");
|
builder.append("/*\"\n}\n],\n\"Version\": \"2012-10-17\"\n}\n");
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class OssProperties {
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 域名
|
* 访问站点
|
||||||
*/
|
*/
|
||||||
private String endpoint;
|
private String endpoint;
|
||||||
|
|
||||||
|
|
@ -60,5 +60,4 @@ public class OssProperties {
|
||||||
*/
|
*/
|
||||||
private String accessPolicy;
|
private String accessPolicy;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -12,14 +12,14 @@
|
||||||
<artifactId>ruoyi-common-redis</artifactId>
|
<artifactId>ruoyi-common-redis</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common-redis缓存服务
|
ruoyi-common-redis 缓存服务
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- RuoYi Common Core-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--redisson-->
|
<!--redisson-->
|
||||||
|
|
@ -28,21 +28,10 @@
|
||||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson-spring-data-27</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>lock4j-redisson-spring-boot-starter</artifactId>
|
<artifactId>lock4j-redisson-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- RuoYi Common Core-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package org.dromara.common.redis.utils;
|
package org.dromara.common.redis.utils;
|
||||||
|
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.redisson.api.*;
|
import org.redisson.api.*;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
@ -474,5 +474,4 @@ public class RedisUtils {
|
||||||
RKeys rKeys = CLIENT.getKeys();
|
RKeys rKeys = CLIENT.getKeys();
|
||||||
return rKeys.countExists(key) > 0;
|
return rKeys.countExists(key) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
|
@ -16,7 +17,6 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Sa-Token 权限认证(core核心包), 在线文档:http://sa-token.dev33.cn/ -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-core</artifactId>
|
<artifactId>sa-token-core</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ public class PlusSaTokenDao implements SaTokenDao {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void set(String key, String value, long timeout) {
|
public void set(String key, String value, long timeout) {
|
||||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
if (timeout == 0 || timeout <= NOT_VALUE_EXPIRE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 判断是否为永不过期
|
// 判断是否为永不过期
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
if (timeout == NEVER_EXPIRE) {
|
||||||
RedisUtils.setCacheObject(key, value);
|
RedisUtils.setCacheObject(key, value);
|
||||||
} else {
|
} else {
|
||||||
RedisUtils.setCacheObject(key, value, Duration.ofSeconds(timeout));
|
RedisUtils.setCacheObject(key, value, Duration.ofSeconds(timeout));
|
||||||
|
|
@ -47,7 +47,7 @@ public class PlusSaTokenDao implements SaTokenDao {
|
||||||
public void update(String key, String value) {
|
public void update(String key, String value) {
|
||||||
long expire = getTimeout(key);
|
long expire = getTimeout(key);
|
||||||
// -2 = 无此键
|
// -2 = 无此键
|
||||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
if (expire == NOT_VALUE_EXPIRE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.set(key, value, expire);
|
this.set(key, value, expire);
|
||||||
|
|
@ -76,9 +76,9 @@ public class PlusSaTokenDao implements SaTokenDao {
|
||||||
@Override
|
@Override
|
||||||
public void updateTimeout(String key, long timeout) {
|
public void updateTimeout(String key, long timeout) {
|
||||||
// 判断是否想要设置为永久
|
// 判断是否想要设置为永久
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
if (timeout == NEVER_EXPIRE) {
|
||||||
long expire = getTimeout(key);
|
long expire = getTimeout(key);
|
||||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
if (expire == NEVER_EXPIRE) {
|
||||||
// 如果其已经被设置为永久,则不作任何处理
|
// 如果其已经被设置为永久,则不作任何处理
|
||||||
} else {
|
} else {
|
||||||
// 如果尚未被设置为永久,那么再次set一次
|
// 如果尚未被设置为永久,那么再次set一次
|
||||||
|
|
@ -103,11 +103,11 @@ public class PlusSaTokenDao implements SaTokenDao {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setObject(String key, Object object, long timeout) {
|
public void setObject(String key, Object object, long timeout) {
|
||||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
if (timeout == 0 || timeout <= NOT_VALUE_EXPIRE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 判断是否为永不过期
|
// 判断是否为永不过期
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
if (timeout == NEVER_EXPIRE) {
|
||||||
RedisUtils.setCacheObject(key, object);
|
RedisUtils.setCacheObject(key, object);
|
||||||
} else {
|
} else {
|
||||||
RedisUtils.setCacheObject(key, object, Duration.ofSeconds(timeout));
|
RedisUtils.setCacheObject(key, object, Duration.ofSeconds(timeout));
|
||||||
|
|
@ -121,7 +121,7 @@ public class PlusSaTokenDao implements SaTokenDao {
|
||||||
public void updateObject(String key, Object object) {
|
public void updateObject(String key, Object object) {
|
||||||
long expire = getObjectTimeout(key);
|
long expire = getObjectTimeout(key);
|
||||||
// -2 = 无此键
|
// -2 = 无此键
|
||||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
if (expire == NOT_VALUE_EXPIRE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setObject(key, object, expire);
|
this.setObject(key, object, expire);
|
||||||
|
|
@ -150,9 +150,9 @@ public class PlusSaTokenDao implements SaTokenDao {
|
||||||
@Override
|
@Override
|
||||||
public void updateObjectTimeout(String key, long timeout) {
|
public void updateObjectTimeout(String key, long timeout) {
|
||||||
// 判断是否想要设置为永久
|
// 判断是否想要设置为永久
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
if (timeout == NEVER_EXPIRE) {
|
||||||
long expire = getObjectTimeout(key);
|
long expire = getObjectTimeout(key);
|
||||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
if (expire == NEVER_EXPIRE) {
|
||||||
// 如果其已经被设置为永久,则不作任何处理
|
// 如果其已经被设置为永久,则不作任何处理
|
||||||
} else {
|
} else {
|
||||||
// 如果尚未被设置为永久,那么再次set一次
|
// 如果尚未被设置为永久,那么再次set一次
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
|
@ -11,11 +12,10 @@
|
||||||
<artifactId>ruoyi-common-security</artifactId>
|
<artifactId>ruoyi-common-security</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common-security安全模块
|
ruoyi-common-security 安全模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-common-satoken</artifactId>
|
<artifactId>ruoyi-common-satoken</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,30 @@
|
||||||
package org.dromara.common.security.handler;
|
package org.dromara.common.security.handler;
|
||||||
|
|
||||||
import cn.dev33.satoken.exception.SameTokenInvalidException;
|
|
||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.dev33.satoken.exception.NotPermissionException;
|
import cn.dev33.satoken.exception.NotPermissionException;
|
||||||
import cn.dev33.satoken.exception.NotRoleException;
|
import cn.dev33.satoken.exception.NotRoleException;
|
||||||
|
import cn.dev33.satoken.exception.SameTokenInvalidException;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import org.dromara.common.core.constant.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.core.exception.DemoModeException;
|
import org.dromara.common.core.exception.DemoModeException;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
|
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局异常处理器
|
* 全局异常处理器
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
|
|
@ -34,7 +37,7 @@ public class GlobalExceptionHandler {
|
||||||
public R<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
|
public R<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
||||||
return R.fail(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
return R.fail(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +47,7 @@ public class GlobalExceptionHandler {
|
||||||
public R<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) {
|
public R<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
||||||
return R.fail(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
return R.fail(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,7 +57,7 @@ public class GlobalExceptionHandler {
|
||||||
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||||
return R.fail(HttpStatus.UNAUTHORIZED, "认证失败,无法访问系统资源");
|
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,7 +67,7 @@ public class GlobalExceptionHandler {
|
||||||
public R<Void> handleSameTokenInvalidException(SameTokenInvalidException e, HttpServletRequest request) {
|
public R<Void> handleSameTokenInvalidException(SameTokenInvalidException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',内网认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
log.error("请求地址'{}',内网认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||||
return R.fail(HttpStatus.UNAUTHORIZED, "认证失败,无法访问系统资源");
|
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,7 +75,7 @@ public class GlobalExceptionHandler {
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
public R<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
public R<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||||
return R.fail(e.getMessage());
|
return R.fail(e.getMessage());
|
||||||
|
|
@ -114,7 +117,17 @@ public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(BindException.class)
|
@ExceptionHandler(BindException.class)
|
||||||
public R<Void> handleBindException(BindException e) {
|
public R<Void> handleBindException(BindException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
String message = StreamUtils.join(e.getAllErrors(), DefaultMessageSourceResolvable::getDefaultMessage, ", ");
|
||||||
|
return R.fail(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义验证异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(ConstraintViolationException.class)
|
||||||
|
public R<Void> constraintViolationException(ConstraintViolationException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
String message = StreamUtils.join(e.getConstraintViolations(), ConstraintViolation::getMessage, ", ");
|
||||||
return R.fail(message);
|
return R.fail(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
||||||
@EnableConfigurationProperties(TenantProperties.class)
|
@EnableConfigurationProperties(TenantProperties.class)
|
||||||
@AutoConfiguration(after = {RedisConfiguration.class})
|
@AutoConfiguration(after = {RedisConfiguration.class})
|
||||||
@ConditionalOnProperty(value = "tenant.enable", havingValue = "true")
|
@ConditionalOnProperty(value = "tenant.enable", havingValue = "true")
|
||||||
public class TenantConfig {
|
public class TenantConfiguration {
|
||||||
|
|
||||||
@ConditionalOnBean(MybatisPlusConfiguration.class)
|
@ConditionalOnBean(MybatisPlusConfiguration.class)
|
||||||
@AutoConfiguration(after = {MybatisPlusConfiguration.class})
|
@AutoConfiguration(after = {MybatisPlusConfiguration.class})
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.dromara.common.tenant.core;
|
package org.dromara.common.tenant.core;
|
||||||
|
|
||||||
|
|
||||||
import org.dromara.common.core.constant.GlobalConstants;
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
import org.dromara.common.satoken.core.dao.PlusSaTokenDao;
|
import org.dromara.common.satoken.core.dao.PlusSaTokenDao;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.dromara.common.tenant.exception;
|
package org.dromara.common.tenant.exception;
|
||||||
|
|
||||||
|
|
||||||
import org.dromara.common.core.exception.base.BaseException;
|
import org.dromara.common.core.exception.base.BaseException;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@ package org.dromara.common.tenant.handle;
|
||||||
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
|
||||||
import net.sf.jsqlparser.expression.NullValue;
|
|
||||||
import net.sf.jsqlparser.expression.StringValue;
|
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.tenant.helper.TenantHelper;
|
import org.dromara.common.tenant.helper.TenantHelper;
|
||||||
import org.dromara.common.tenant.properties.TenantProperties;
|
import org.dromara.common.tenant.properties.TenantProperties;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
|
import net.sf.jsqlparser.expression.NullValue;
|
||||||
|
import net.sf.jsqlparser.expression.StringValue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.dromara.common.tenant.handle;
|
package org.dromara.common.tenant.handle;
|
||||||
|
|
||||||
|
|
||||||
import org.dromara.common.core.constant.GlobalConstants;
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.redis.handler.KeyPrefixHandler;
|
import org.dromara.common.redis.handler.KeyPrefixHandler;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.dromara.common.tenant.manager;
|
package org.dromara.common.tenant.manager;
|
||||||
|
|
||||||
|
|
||||||
import org.dromara.common.core.constant.GlobalConstants;
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.redis.manager.PlusSpringCacheManager;
|
import org.dromara.common.redis.manager.PlusSpringCacheManager;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
org.dromara.common.tenant.config.TenantConfig
|
org.dromara.common.tenant.config.TenantConfiguration
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
package org.dromara.common.translation.annotation;
|
package org.dromara.common.translation.annotation;
|
||||||
|
|
||||||
|
import org.dromara.common.translation.core.TranslationInterface;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻译类型注解 (标注到{@link org.dromara.common.translation.core.TranslationInterface} 的实现类)
|
* 翻译类型注解 (标注到{@link TranslationInterface} 的实现类)
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ import org.dromara.common.translation.annotation.TranslationType;
|
||||||
import org.dromara.common.translation.core.TranslationInterface;
|
import org.dromara.common.translation.core.TranslationInterface;
|
||||||
import org.dromara.common.translation.core.handler.TranslationBeanSerializerModifier;
|
import org.dromara.common.translation.core.handler.TranslationBeanSerializerModifier;
|
||||||
import org.dromara.common.translation.core.handler.TranslationHandler;
|
import org.dromara.common.translation.core.handler.TranslationHandler;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
|
||||||
import jakarta.annotation.PostConstruct;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package org.dromara.common.translation.core;
|
package org.dromara.common.translation.core;
|
||||||
|
|
||||||
|
import org.dromara.common.translation.annotation.TranslationType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻译接口 (实现类需标注 {@link org.dromara.common.translation.annotation.TranslationType} 注解标明翻译类型)
|
* 翻译接口 (实现类需标注 {@link TranslationType} 注解标明翻译类型)
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
@ -10,7 +12,8 @@ public interface TranslationInterface<T> {
|
||||||
/**
|
/**
|
||||||
* 翻译
|
* 翻译
|
||||||
*
|
*
|
||||||
* @param key 需要被翻译的键(不为空)
|
* @param key 需要被翻译的键(不为空)
|
||||||
|
* @param other 其他参数
|
||||||
* @return 返回键对应的值
|
* @return 返回键对应的值
|
||||||
*/
|
*/
|
||||||
T translation(Object key, String other);
|
T translation(Object key, String other);
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ public class TranslationBeanSerializerModifier extends BeanSerializerModifier {
|
||||||
List<BeanPropertyWriter> beanProperties) {
|
List<BeanPropertyWriter> beanProperties) {
|
||||||
for (BeanPropertyWriter writer : beanProperties) {
|
for (BeanPropertyWriter writer : beanProperties) {
|
||||||
// 如果序列化器为 TranslationHandler 的话 将 Null 值也交给他处理
|
// 如果序列化器为 TranslationHandler 的话 将 Null 值也交给他处理
|
||||||
if (writer.getSerializer() instanceof TranslationHandler) {
|
if (writer.getSerializer() instanceof TranslationHandler serializer) {
|
||||||
writer.assignNullSerializer(writer.getSerializer());
|
writer.assignNullSerializer(serializer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return beanProperties;
|
return beanProperties;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
|
|
@ -69,6 +69,6 @@
|
||||||
<version>2.7.6</version>
|
<version>2.7.6</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
package org.dromara.common.web.core;
|
package org.dromara.common.web.core;
|
||||||
|
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web层通用数据处理
|
* web层通用数据处理
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class BaseController {
|
public class BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,8 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否支持分片消息
|
* 是否支持分片消息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPartialMessages() {
|
public boolean supportsPartialMessages() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue