org.redisson
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java
deleted file mode 100644
index 26d664f6e8..0000000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.ruoyi.common.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * 数据权限过滤注解
- *
- * @author ruoyi
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface DataScope {
- /**
- * 部门表的别名
- */
- public String deptAlias() default "";
-
- /**
- * 用户表的别名
- */
- public String userAlias() default "";
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScopeAspect.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScopeAspect.java
deleted file mode 100644
index cc01b9422a..0000000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScopeAspect.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package com.ruoyi.framework.aspectj;
-
-import java.lang.reflect.Method;
-
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.Signature;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.springframework.stereotype.Component;
-import com.ruoyi.common.annotation.DataScope;
-import com.ruoyi.common.core.domain.BaseEntity;
-import com.ruoyi.common.core.domain.entity.SysRole;
-import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.utils.ServletUtils;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.spring.SpringUtils;
-import com.ruoyi.framework.web.service.TokenService;
-
-/**
- * 数据过滤处理
- *
- * @author ruoyi
- */
-@Aspect
-@Component
-public class DataScopeAspect {
- /**
- * 全部数据权限
- */
- public static final String DATA_SCOPE_ALL = "1";
-
- /**
- * 自定数据权限
- */
- public static final String DATA_SCOPE_CUSTOM = "2";
-
- /**
- * 部门数据权限
- */
- public static final String DATA_SCOPE_DEPT = "3";
-
- /**
- * 部门及以下数据权限
- */
- public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
-
- /**
- * 仅本人数据权限
- */
- public static final String DATA_SCOPE_SELF = "5";
-
- /**
- * 数据权限过滤关键字
- */
- public static final String DATA_SCOPE = "dataScope";
-
- // 配置织入点
- @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
- public void dataScopePointCut() {
- }
-
- @Before("dataScopePointCut()")
- public void doBefore(JoinPoint point) throws Throwable {
- handleDataScope(point);
- }
-
- protected void handleDataScope(final JoinPoint joinPoint) {
- // 获得注解
- DataScope controllerDataScope = getAnnotationLog(joinPoint);
- if (controllerDataScope == null) {
- return;
- }
- // 获取当前的用户
- LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
- if (StringUtils.isNotNull(loginUser)) {
- SysUser currentUser = loginUser.getUser();
- // 如果是超级管理员,则不过滤数据
- if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
- dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
- controllerDataScope.userAlias());
- }
- }
- }
-
- /**
- * 数据范围过滤
- *
- * @param joinPoint 切点
- * @param user 用户
- * @param userAlias 别名
- */
- public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) {
- StringBuilder sqlString = new StringBuilder();
-
- for (SysRole role : user.getRoles()) {
- String dataScope = role.getDataScope();
- if (DATA_SCOPE_ALL.equals(dataScope)) {
- sqlString = new StringBuilder();
- break;
- } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
- sqlString.append(StringUtils.format(
- " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
- role.getRoleId()));
- } else if (DATA_SCOPE_DEPT.equals(dataScope)) {
- sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
- } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
- sqlString.append(StringUtils.format(
- " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
- deptAlias, user.getDeptId(), user.getDeptId()));
- } else if (DATA_SCOPE_SELF.equals(dataScope)) {
- if (StringUtils.isNotBlank(userAlias)) {
- sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
- } else {
- // 数据权限为仅本人且没有userAlias别名不查询任何数据
- sqlString.append(" OR 1=0 ");
- }
- }
- }
-
- if (StringUtils.isNotBlank(sqlString.toString())) {
- Object params = joinPoint.getArgs()[0];
- if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
- BaseEntity baseEntity = (BaseEntity) params;
- baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
- }
- }
- }
-
- /**
- * 是否存在注解,如果存在就获取
- */
- private DataScope getAnnotationLog(JoinPoint joinPoint) {
- Signature signature = joinPoint.getSignature();
- MethodSignature methodSignature = (MethodSignature) signature;
- Method method = methodSignature.getMethod();
-
- if (method != null) {
- return method.getAnnotation(DataScope.class);
- }
- return null;
- }
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java
deleted file mode 100644
index 11b0d579c8..0000000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.ruoyi.common.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.ruoyi.common.enums.DataSourceType;
-
-/**
- * 自定义多数据源切换注解
- *
- * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
- *
- * @author ruoyi
- */
-@Target({ElementType.METHOD, ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-@Inherited
-public @interface DataSource {
- /**
- * 切换数据源名称
- */
- public DataSourceType value() default DataSourceType.MASTER;
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSourceAspect.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSourceAspect.java
deleted file mode 100644
index 020493d2db..0000000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSourceAspect.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.ruoyi.framework.aspectj;
-
-import java.util.Objects;
-
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-import com.ruoyi.common.annotation.DataSource;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
-
-/**
- * 多数据源处理
- *
- * @author ruoyi
- */
-@Aspect
-@Order(1)
-@Component
-public class DataSourceAspect {
- protected Logger logger = LoggerFactory.getLogger(getClass());
-
- @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"
- + "|| @within(com.ruoyi.common.annotation.DataSource)")
- public void dsPointCut() {
-
- }
-
- @Around("dsPointCut()")
- public Object around(ProceedingJoinPoint point) throws Throwable {
- DataSource dataSource = getDataSource(point);
-
- if (StringUtils.isNotNull(dataSource)) {
- DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name());
- }
-
- try {
- return point.proceed();
- } finally {
- // 销毁数据源 在执行方法之后
- DynamicDataSourceContextHolder.clearDataSourceType();
- }
- }
-
- /**
- * 获取需要切换的数据源
- */
- public DataSource getDataSource(ProceedingJoinPoint point) {
- MethodSignature signature = (MethodSignature) point.getSignature();
- DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class);
- if (Objects.nonNull(dataSource)) {
- return dataSource;
- }
-
- return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);
- }
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSourceType.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSourceType.java
deleted file mode 100644
index 0d945be549..0000000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSourceType.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.ruoyi.common.enums;
-
-/**
- * 数据源
- *
- * @author ruoyi
- */
-public enum DataSourceType
-{
- /**
- * 主库
- */
- MASTER,
-
- /**
- * 从库
- */
- SLAVE
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DynamicDataSource.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DynamicDataSource.java
deleted file mode 100644
index f60b35cb65..0000000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DynamicDataSource.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.ruoyi.framework.datasource;
-
-import java.util.Map;
-import javax.sql.DataSource;
-
-import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
-
-/**
- * 动态数据源
- *
- * @author ruoyi
- */
-public class DynamicDataSource extends AbstractRoutingDataSource {
- public DynamicDataSource(DataSource defaultTargetDataSource, Map