From 4d46f4c1b5600c71bec9c08181b412acf9d13895 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 9 Dec 2020 10:32:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=E5=92=8C?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E8=A7=A3=E7=BB=91=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/system/mapper/SysRoleMenuMapper.java | 8 ++++++++ .../ruoyi/system/service/impl/SysRoleServiceImpl.java | 10 ++++++++++ .../ruoyi/system/service/impl/SysUserServiceImpl.java | 6 ++++++ .../main/resources/mapper/system/SysRoleMenuMapper.xml | 7 +++++++ ruoyi-ui/src/assets/styles/ruoyi.scss | 6 +++--- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java index 99de1dece..23391557d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java @@ -26,6 +26,14 @@ public interface SysRoleMenuMapper */ public int deleteRoleMenuByRoleId(Long roleId); + /** + * 批量删除角色菜单关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleMenu(Long[] ids); + /** * 批量新增角色菜单信息 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 8bfc5a410..cecc6a2cb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -290,8 +290,13 @@ public class SysRoleServiceImpl implements ISysRoleService * @return 结果 */ @Override + @Transactional public int deleteRoleById(Long roleId) { + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenuByRoleId(roleId); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDeptByRoleId(roleId); return roleMapper.deleteRoleById(roleId); } @@ -302,6 +307,7 @@ public class SysRoleServiceImpl implements ISysRoleService * @return 结果 */ @Override + @Transactional public int deleteRoleByIds(Long[] roleIds) { for (Long roleId : roleIds) @@ -313,6 +319,10 @@ public class SysRoleServiceImpl implements ISysRoleService throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenu(roleIds); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDept(roleIds); return roleMapper.deleteRoleByIds(roleIds); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 9c77dd8d1..065ae4818 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -363,6 +363,7 @@ public class SysUserServiceImpl implements ISysUserService * @return 结果 */ @Override + @Transactional public int deleteUserById(Long userId) { // 删除用户与角色关联 @@ -379,12 +380,17 @@ public class SysUserServiceImpl implements ISysUserService * @return 结果 */ @Override + @Transactional public int deleteUserByIds(Long[] userIds) { for (Long userId : userIds) { checkUserAllowed(new SysUser(userId)); } + // 删除用户与角色关联 + userRoleMapper.deleteUserRole(userIds); + // 删除用户与岗位关联 + userPostMapper.deleteUserPost(userIds); return userMapper.deleteUserByIds(userIds); } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml index b81c34dbc..e75bb1744 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml @@ -17,6 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from sys_role_menu where role_id=#{roleId} + + delete from sys_role_menu where role_id in + + #{roleId} + + + insert into sys_role_menu(role_id, menu_id) values diff --git a/ruoyi-ui/src/assets/styles/ruoyi.scss b/ruoyi-ui/src/assets/styles/ruoyi.scss index 96c95c1e2..67c2900fc 100644 --- a/ruoyi-ui/src/assets/styles/ruoyi.scss +++ b/ruoyi-ui/src/assets/styles/ruoyi.scss @@ -238,7 +238,7 @@ position: relative; float: right; } -/* XY 代码生成预览左右滑动 */ -.el-tabs__content{ - overflow-x: scroll; +/* el-tabs提供滚动机制 */ +.el-tabs__content { + overflow-x: scroll; } \ No newline at end of file