Commit 6b3a54c8dfd3e94966d0c3afdd817e1ea1d68897
1 parent
bb06c114
!69fix(system): 修复更新账号时岗位为空时发生的空指针异常
Showing
2 changed files
with
7 additions
and
5 deletions
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java
| ... | ... | @@ -138,8 +138,9 @@ public class PermissionServiceImpl implements PermissionService { |
| 138 | 138 | // 获得角色拥有菜单编号 |
| 139 | 139 | Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId); |
| 140 | 140 | // 计算新增和删除的菜单编号 |
| 141 | - Collection<Long> createMenuIds = CollUtil.subtract(menuIds, dbMenuIds); | |
| 142 | - Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIds); | |
| 141 | + Set<Long> menuIdList = CollUtil.emptyIfNull(menuIds); | |
| 142 | + Collection<Long> createMenuIds = CollUtil.subtract(menuIdList, dbMenuIds); | |
| 143 | + Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIdList); | |
| 143 | 144 | // 执行新增和删除。对于已经授权的菜单,不用做任何处理 |
| 144 | 145 | if (CollUtil.isNotEmpty(createMenuIds)) { |
| 145 | 146 | roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> { |
| ... | ... | @@ -205,8 +206,9 @@ public class PermissionServiceImpl implements PermissionService { |
| 205 | 206 | Set<Long> dbRoleIds = convertSet(userRoleMapper.selectListByUserId(userId), |
| 206 | 207 | UserRoleDO::getRoleId); |
| 207 | 208 | // 计算新增和删除的角色编号 |
| 208 | - Collection<Long> createRoleIds = CollUtil.subtract(roleIds, dbRoleIds); | |
| 209 | - Collection<Long> deleteMenuIds = CollUtil.subtract(dbRoleIds, roleIds); | |
| 209 | + Set<Long> roleIdList = CollUtil.emptyIfNull(roleIds); | |
| 210 | + Collection<Long> createRoleIds = CollUtil.subtract(roleIdList, dbRoleIds); | |
| 211 | + Collection<Long> deleteMenuIds = CollUtil.subtract(dbRoleIds, roleIdList); | |
| 210 | 212 | // 执行新增和删除。对于已经授权的角色,不用做任何处理 |
| 211 | 213 | if (!CollectionUtil.isEmpty(createRoleIds)) { |
| 212 | 214 | userRoleMapper.insertBatch(CollectionUtils.convertList(createRoleIds, roleId -> { | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
| ... | ... | @@ -117,7 +117,7 @@ public class AdminUserServiceImpl implements AdminUserService { |
| 117 | 117 | Long userId = reqVO.getId(); |
| 118 | 118 | Set<Long> dbPostIds = convertSet(userPostMapper.selectListByUserId(userId), UserPostDO::getPostId); |
| 119 | 119 | // 计算新增和删除的岗位编号 |
| 120 | - Set<Long> postIds = updateObj.getPostIds(); | |
| 120 | + Set<Long> postIds = CollUtil.emptyIfNull(updateObj.getPostIds()); | |
| 121 | 121 | Collection<Long> createPostIds = CollUtil.subtract(postIds, dbPostIds); |
| 122 | 122 | Collection<Long> deletePostIds = CollUtil.subtract(dbPostIds, postIds); |
| 123 | 123 | // 执行新增和删除。对于已经授权的菜单,不用做任何处理 | ... | ... |