|
|
@@ -17,6 +17,11 @@ import com.ruoyi.common.security.annotation.PreAuthorize;
|
|
17
|
17
|
import com.ruoyi.common.security.service.TokenService;
|
|
18
|
18
|
import com.ruoyi.system.api.model.LoginUser;
|
|
19
|
19
|
|
|
|
20
|
+/**
|
|
|
21
|
+ * 自定义权限实现
|
|
|
22
|
+ *
|
|
|
23
|
+ * @author ruoyi
|
|
|
24
|
+ */
|
|
20
|
25
|
@Aspect
|
|
21
|
26
|
@Component
|
|
22
|
27
|
public class PreAuthorizeAspect
|
|
|
@@ -42,34 +47,56 @@ public class PreAuthorizeAspect
|
|
42
|
47
|
return point.proceed();
|
|
43
|
48
|
}
|
|
44
|
49
|
|
|
45
|
|
- if (StringUtils.isEmpty(annotation.hasPermi()) && hasPermi(annotation.hasPermi()))
|
|
|
50
|
+ if (!StringUtils.isEmpty(annotation.hasPermi()))
|
|
46
|
51
|
{
|
|
47
|
|
- return point.proceed();
|
|
48
|
|
- }
|
|
49
|
|
- else if (StringUtils.isEmpty(annotation.lacksPermi()) && hasPermi(annotation.lacksPermi()))
|
|
50
|
|
- {
|
|
51
|
|
- return point.proceed();
|
|
|
52
|
+ if (hasPermi(annotation.hasPermi()))
|
|
|
53
|
+ {
|
|
|
54
|
+ return point.proceed();
|
|
|
55
|
+ }
|
|
|
56
|
+ throw new PreAuthorizeException();
|
|
52
|
57
|
}
|
|
53
|
|
- else if (StringUtils.isEmpty(annotation.hasAnyPermi()) && hasAnyPermi(annotation.hasAnyPermi()))
|
|
|
58
|
+ else if (!StringUtils.isEmpty(annotation.lacksPermi()))
|
|
54
|
59
|
{
|
|
55
|
|
- return point.proceed();
|
|
|
60
|
+ if (lacksPermi(annotation.lacksPermi()))
|
|
|
61
|
+ {
|
|
|
62
|
+ return point.proceed();
|
|
|
63
|
+ }
|
|
|
64
|
+ throw new PreAuthorizeException();
|
|
56
|
65
|
}
|
|
57
|
|
- else if (StringUtils.isEmpty(annotation.hasRole()) && hasRole(annotation.hasRole()))
|
|
|
66
|
+ else if (!StringUtils.isEmpty(annotation.hasAnyPermi()))
|
|
58
|
67
|
{
|
|
59
|
|
- return point.proceed();
|
|
|
68
|
+ if (hasAnyPermi(annotation.hasAnyPermi()))
|
|
|
69
|
+ {
|
|
|
70
|
+ return point.proceed();
|
|
|
71
|
+ }
|
|
|
72
|
+ throw new PreAuthorizeException();
|
|
60
|
73
|
}
|
|
61
|
|
- else if (StringUtils.isEmpty(annotation.lacksRole()) && lacksRole(annotation.lacksRole()))
|
|
|
74
|
+ else if (!StringUtils.isEmpty(annotation.hasRole()))
|
|
62
|
75
|
{
|
|
63
|
|
- return point.proceed();
|
|
|
76
|
+ if (hasRole(annotation.hasRole()))
|
|
|
77
|
+ {
|
|
|
78
|
+ return point.proceed();
|
|
|
79
|
+ }
|
|
|
80
|
+ throw new PreAuthorizeException();
|
|
64
|
81
|
}
|
|
65
|
|
- else if (StringUtils.isEmpty(annotation.hasAnyRoles()) && hasAnyRoles(annotation.hasAnyRoles()))
|
|
|
82
|
+ else if (StringUtils.isEmpty(annotation.lacksRole()))
|
|
66
|
83
|
{
|
|
67
|
|
- return point.proceed();
|
|
|
84
|
+ if (lacksRole(annotation.lacksRole()))
|
|
|
85
|
+ {
|
|
|
86
|
+ return point.proceed();
|
|
|
87
|
+ }
|
|
|
88
|
+ throw new PreAuthorizeException();
|
|
68
|
89
|
}
|
|
69
|
|
- else
|
|
|
90
|
+ else if (StringUtils.isEmpty(annotation.hasAnyRoles()))
|
|
70
|
91
|
{
|
|
|
92
|
+ if (hasAnyRoles(annotation.hasAnyRoles()))
|
|
|
93
|
+ {
|
|
|
94
|
+ return point.proceed();
|
|
|
95
|
+ }
|
|
71
|
96
|
throw new PreAuthorizeException();
|
|
72
|
97
|
}
|
|
|
98
|
+
|
|
|
99
|
+ return point.proceed();
|
|
73
|
100
|
}
|
|
74
|
101
|
|
|
75
|
102
|
/**
|