|
@@ -138,8 +138,9 @@ public class PermissionServiceImpl implements PermissionService {
|
|
|
// 获得角色拥有菜单编号
|
|
|
Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId);
|
|
|
// 计算新增和删除的菜单编号
|
|
|
- Collection<Long> createMenuIds = CollUtil.subtract(menuIds, dbMenuIds);
|
|
|
- Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIds);
|
|
|
+ Set<Long> menuIdList = CollUtil.emptyIfNull(menuIds);
|
|
|
+ Collection<Long> createMenuIds = CollUtil.subtract(menuIdList, dbMenuIds);
|
|
|
+ Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIdList);
|
|
|
// 执行新增和删除。对于已经授权的菜单,不用做任何处理
|
|
|
if (CollUtil.isNotEmpty(createMenuIds)) {
|
|
|
roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> {
|
|
@@ -205,8 +206,9 @@ public class PermissionServiceImpl implements PermissionService {
|
|
|
Set<Long> dbRoleIds = convertSet(userRoleMapper.selectListByUserId(userId),
|
|
|
UserRoleDO::getRoleId);
|
|
|
// 计算新增和删除的角色编号
|
|
|
- Collection<Long> createRoleIds = CollUtil.subtract(roleIds, dbRoleIds);
|
|
|
- Collection<Long> deleteMenuIds = CollUtil.subtract(dbRoleIds, roleIds);
|
|
|
+ Set<Long> roleIdList = CollUtil.emptyIfNull(roleIds);
|
|
|
+ Collection<Long> createRoleIds = CollUtil.subtract(roleIdList, dbRoleIds);
|
|
|
+ Collection<Long> deleteMenuIds = CollUtil.subtract(dbRoleIds, roleIdList);
|
|
|
// 执行新增和删除。对于已经授权的角色,不用做任何处理
|
|
|
if (!CollectionUtil.isEmpty(createRoleIds)) {
|
|
|
userRoleMapper.insertBatch(CollectionUtils.convertList(createRoleIds, roleId -> {
|