From e7fa08d156535c457ca6c14bebde87abd1118324 Mon Sep 17 00:00:00 2001 From: Liyanjun Date: Fri, 30 Jun 2023 18:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=BB=91=E5=AE=9A=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E8=B5=84=E6=BA=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menu/service/impl/SysMenuServiceImpl.java | 2 +- .../service/impl/SysRoleMenuServiceImpl.java | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/menu/service/impl/SysMenuServiceImpl.java b/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/menu/service/impl/SysMenuServiceImpl.java index c9d0178b3..556bfcff9 100644 --- a/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/menu/service/impl/SysMenuServiceImpl.java +++ b/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/menu/service/impl/SysMenuServiceImpl.java @@ -277,7 +277,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl // 查询数据库菜单id对应的应用id集合 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(SysMenu::getMenuId, menuIdList); - queryWrapper.select(SysMenu::getAppId); + queryWrapper.select(SysMenu::getAppId,SysMenu::getMenuId); List queryList = this.list(queryWrapper); if (ObjectUtil.isEmpty(queryList)) { diff --git a/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleMenuServiceImpl.java b/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleMenuServiceImpl.java index aac8b51b1..e9ee23ed6 100644 --- a/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleMenuServiceImpl.java +++ b/kernel-s-sys/sys-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/SysRoleMenuServiceImpl.java @@ -181,12 +181,15 @@ public class SysRoleMenuServiceImpl extends ServiceImpl totalMenuOptions = sysMenuOptionsService.list(queryWrapper); - // 3. 先删除已经绑定的所有角色和功能的绑定 - LambdaQueryWrapper roleMenuOptionsLambdaQueryWrapper = new LambdaQueryWrapper<>(); - roleMenuOptionsLambdaQueryWrapper.eq(SysRoleMenuOptions::getRoleId, roleId); - roleMenuOptionsLambdaQueryWrapper.in(SysRoleMenuOptions::getMenuOptionId, - totalMenuOptions.stream().map(SysMenuOptions::getMenuOptionId).collect(Collectors.toSet())); - sysRoleMenuOptionsService.remove(roleMenuOptionsLambdaQueryWrapper); + if(ObjectUtil.isNotEmpty(totalMenuOptions)) { + // 3. 先删除已经绑定的所有角色和功能的绑定 + LambdaQueryWrapper roleMenuOptionsLambdaQueryWrapper = new LambdaQueryWrapper<>(); + roleMenuOptionsLambdaQueryWrapper.eq(SysRoleMenuOptions::getRoleId, roleId); + roleMenuOptionsLambdaQueryWrapper.in(SysRoleMenuOptions::getMenuOptionId, + totalMenuOptions.stream().map(SysMenuOptions::getMenuOptionId).collect(Collectors.toSet())); + sysRoleMenuOptionsService.remove(roleMenuOptionsLambdaQueryWrapper); + } + // 4. 如果是选中状态,则从新进行这些角色和功能的绑定 if (roleBindPermissionRequest.getChecked()) { @@ -200,6 +203,12 @@ public class SysRoleMenuServiceImpl extends ServiceImpl roleMenuLambdaQueryWrapper = new LambdaQueryWrapper<>(); + roleMenuLambdaQueryWrapper.eq(SysRoleMenu::getRoleId, sysRoleMenu.getRoleId()); + roleMenuLambdaQueryWrapper.eq(SysRoleMenu::getMenuId, sysRoleMenu.getMenuId()); + this.remove(roleMenuLambdaQueryWrapper); } // 5. 根据菜单下的资源信息,封装返回结果