Explorar o código

修正数组权限为空判断

JuJu %!s(int64=5) %!d(string=hai) anos
pai
achega
07df90f99b

+ 5 - 2
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java

@@ -35,6 +35,9 @@ public class PreAuthorizeAspect
35
     /** 管理员角色权限标识 */
35
     /** 管理员角色权限标识 */
36
     private static final String SUPER_ADMIN = "admin";
36
     private static final String SUPER_ADMIN = "admin";
37
 
37
 
38
+    /** 数组为0时 */
39
+    private static final Integer ARRAY_EMPTY = 0;
40
+
38
     @Around("@annotation(com.ruoyi.common.security.annotation.PreAuthorize)")
41
     @Around("@annotation(com.ruoyi.common.security.annotation.PreAuthorize)")
39
     public Object around(ProceedingJoinPoint point) throws Throwable
42
     public Object around(ProceedingJoinPoint point) throws Throwable
40
     {
43
     {
@@ -63,7 +66,7 @@ public class PreAuthorizeAspect
63
             }
66
             }
64
             throw new PreAuthorizeException();
67
             throw new PreAuthorizeException();
65
         }
68
         }
66
-        else if (!StringUtils.isEmpty(annotation.hasAnyPermi()))
69
+        else if (ARRAY_EMPTY < annotation.hasAnyPermi().length)
67
         {
70
         {
68
             if (hasAnyPermi(annotation.hasAnyPermi()))
71
             if (hasAnyPermi(annotation.hasAnyPermi()))
69
             {
72
             {
@@ -87,7 +90,7 @@ public class PreAuthorizeAspect
87
             }
90
             }
88
             throw new PreAuthorizeException();
91
             throw new PreAuthorizeException();
89
         }
92
         }
90
-        else if (!StringUtils.isEmpty(annotation.hasAnyRoles()))
93
+        else if (ARRAY_EMPTY < annotation.hasAnyRoles().length)
91
         {
94
         {
92
             if (hasAnyRoles(annotation.hasAnyRoles()))
95
             if (hasAnyRoles(annotation.hasAnyRoles()))
93
             {
96
             {