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,8 +138,9 @@ public class PermissionServiceImpl implements PermissionService { | ||
| 138 | // 获得角色拥有菜单编号 | 138 | // 获得角色拥有菜单编号 |
| 139 | Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId); | 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 | if (CollUtil.isNotEmpty(createMenuIds)) { | 145 | if (CollUtil.isNotEmpty(createMenuIds)) { |
| 145 | roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> { | 146 | roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> { |
| @@ -205,8 +206,9 @@ public class PermissionServiceImpl implements PermissionService { | @@ -205,8 +206,9 @@ public class PermissionServiceImpl implements PermissionService { | ||
| 205 | Set<Long> dbRoleIds = convertSet(userRoleMapper.selectListByUserId(userId), | 206 | Set<Long> dbRoleIds = convertSet(userRoleMapper.selectListByUserId(userId), |
| 206 | UserRoleDO::getRoleId); | 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 | if (!CollectionUtil.isEmpty(createRoleIds)) { | 213 | if (!CollectionUtil.isEmpty(createRoleIds)) { |
| 212 | userRoleMapper.insertBatch(CollectionUtils.convertList(createRoleIds, roleId -> { | 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,7 +117,7 @@ public class AdminUserServiceImpl implements AdminUserService { | ||
| 117 | Long userId = reqVO.getId(); | 117 | Long userId = reqVO.getId(); |
| 118 | Set<Long> dbPostIds = convertSet(userPostMapper.selectListByUserId(userId), UserPostDO::getPostId); | 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 | Collection<Long> createPostIds = CollUtil.subtract(postIds, dbPostIds); | 121 | Collection<Long> createPostIds = CollUtil.subtract(postIds, dbPostIds); |
| 122 | Collection<Long> deletePostIds = CollUtil.subtract(dbPostIds, postIds); | 122 | Collection<Long> deletePostIds = CollUtil.subtract(dbPostIds, postIds); |
| 123 | // 执行新增和删除。对于已经授权的菜单,不用做任何处理 | 123 | // 执行新增和删除。对于已经授权的菜单,不用做任何处理 |