瀏覽代碼

权限完成

wuheng 1 年之前
父節點
當前提交
7d066dd6ae

+ 7 - 1
service/src/main/java/com/koobietech/eas/service/impl/EasSysAdminLoginServiceImpl.java

@@ -32,6 +32,7 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 
 @Service
@@ -97,7 +98,12 @@ public class EasSysAdminLoginServiceImpl implements EasSysAdminLoginService {
                     Method declaredMethod = easAuthorityConfig.getClass().getDeclaredMethod("get" + methodName, null);
                     if ( declaredMethod != null ) {
                         List<String> depUrlList = (List<String>) declaredMethod.invoke(easAuthorityConfig, null);
-                        userDetailPojoInRedis.setPermissionPojos(depUrlList);
+                        if (Objects.nonNull(depUrlList) && depUrlList.size() > 0 ) {
+                            if ( Objects.nonNull(userDetailPojoInRedis.getPermissionPojos()) ) {
+                                depUrlList.addAll(userDetailPojoInRedis.getPermissionPojos());
+                            }
+                            userDetailPojoInRedis.setPermissionPojos(depUrlList);
+                        }
                     }
                 }
             } catch (NoSuchMethodException ignored) {}

+ 11 - 3
service/src/main/java/com/koobietech/eas/service/impl/EasSysStudentLoginServiceImpl.java

@@ -30,6 +30,7 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 
 /**
@@ -100,11 +101,18 @@ public class EasSysStudentLoginServiceImpl implements EasSysStudentLoginService
         departments.forEach(departmentPojo -> {
             try {
                 String authority = departmentPojo.getAuthority();
-                if (authority != null && !authority.isEmpty() && !authority.isBlank() ) {
+                if ( authority != null && !authority.isEmpty() ) {
                     String methodName = Character.toUpperCase(authority.charAt(0)) + authority.substring(1);
                     Method declaredMethod = easAuthorityConfig.getClass().getDeclaredMethod("get" + methodName, null);
-                    List<String> depUrlList = (List<String>) declaredMethod.invoke(easAuthorityConfig, null);
-                    userDetailPojo.setPermissionPojos(depUrlList);
+                    if ( declaredMethod != null ) {
+                        List<String> depUrlList = (List<String>) declaredMethod.invoke(easAuthorityConfig, null);
+                        if (Objects.nonNull(depUrlList) && depUrlList.size() > 0 ) {
+                            if ( Objects.nonNull(userDetailPojo.getPermissionPojos()) ) {
+                                depUrlList.addAll(userDetailPojo.getPermissionPojos());
+                            }
+                            userDetailPojo.setPermissionPojos(depUrlList);
+                        }
+                    }
                 }
             } catch (NoSuchMethodException ignored) {}
             catch (InvocationTargetException | IllegalAccessException ignored) {}