|
@@ -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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|