소스 검색

添加非空判断

黄远 5 년 전
부모
커밋
1fc9f8ebd8
1개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  1. 9 7
      lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/RoleService.java

+ 9 - 7
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/RoleService.java

@@ -184,13 +184,15 @@ public class RoleService extends ServiceImpl<RoleMapper, Role> implements IRoleS
             Map<Long, UserRole> userIdToUserRole = ProjectUtils.attrToObjMap(userRoleList, "userId", null);
             //获取角色列表
             List<Long> roleIdList = ProjectUtils.getAttrList(userRoleList, "roleId", null);
-            List<Role> roleList = (List<Role>) this.listByIds(roleIdList);
-            Map<Long, Role> idToRole = ProjectUtils.attrToObjMap(roleList, "id", null);
-            for (Long userId : userIdList) {
-                UserRole userRole = userIdToUserRole.get(userId);
-                if (userRole != null) {
-                    Role role = idToRole.get(userRole.getRoleId());
-                    userIdToRole.put(userId, role);
+            if(roleIdList != null && roleIdList.size() > 0){
+                List<Role> roleList = (List<Role>) this.listByIds(roleIdList);
+                Map<Long, Role> idToRole = ProjectUtils.attrToObjMap(roleList, "id", null);
+                for (Long userId : userIdList) {
+                    UserRole userRole = userIdToUserRole.get(userId);
+                    if (userRole != null) {
+                        Role role = idToRole.get(userRole.getRoleId());
+                        userIdToRole.put(userId, role);
+                    }
                 }
             }
         }