|
|
@@ -8,7 +8,9 @@ import com.ruoyi.common.core.domain.model.LoginUser;
|
|
8
|
8
|
import com.ruoyi.common.core.text.Convert;
|
|
9
|
9
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
10
|
10
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
11
|
+import com.ruoyi.common.utils.spring.SpringUtils;
|
|
11
|
12
|
import com.ruoyi.framework.security.context.PermissionContextHolder;
|
|
|
13
|
+import com.ruoyi.system.mapper.SysRoleMapper;
|
|
12
|
14
|
import org.aspectj.lang.JoinPoint;
|
|
13
|
15
|
import org.aspectj.lang.annotation.Aspect;
|
|
14
|
16
|
import org.aspectj.lang.annotation.Before;
|
|
|
@@ -55,6 +57,14 @@ public class DataScopeAspect
|
|
55
|
57
|
* 数据权限过滤关键字
|
|
56
|
58
|
*/
|
|
57
|
59
|
public static final String DATA_SCOPE = "dataScope";
|
|
|
60
|
+ private static SysRoleMapper roleMapper;
|
|
|
61
|
+
|
|
|
62
|
+
|
|
|
63
|
+ static {
|
|
|
64
|
+ roleMapper= SpringUtils.getBean(SysRoleMapper.class);
|
|
|
65
|
+
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
58
|
68
|
|
|
59
|
69
|
@Before("@annotation(controllerDataScope)")
|
|
60
|
70
|
public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable
|
|
|
@@ -93,7 +103,9 @@ public class DataScopeAspect
|
|
93
|
103
|
{
|
|
94
|
104
|
StringBuilder sqlString = new StringBuilder();
|
|
95
|
105
|
List<String> conditions = new ArrayList<String>();
|
|
96
|
|
-
|
|
|
106
|
+ if(user.getUserId()!=null){
|
|
|
107
|
+ user.setRoles(roleMapper.selectRolePermissionByUserId(user.getUserId()));
|
|
|
108
|
+ }
|
|
97
|
109
|
for (SysRole role : user.getRoles())
|
|
98
|
110
|
{
|
|
99
|
111
|
String dataScope = role.getDataScope();
|