diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java
index ac01be2..e11419f 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java
@@ -28,6 +28,14 @@ public interface SysRoleMenuMapper
public int deleteRoleMenuByRoleId(Long roleId);
/**
+ * 批量删除角色菜单关联信息
+ *
+ * @param ids 需要删除的数据ID
+ * @return 结果
+ */
+ public int deleteRoleMenu(Long[] ids);
+
+ /**
* 批量新增角色菜单信息
*
* @param roleMenuList 角色菜单列表
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
index 99419db..9594b99 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
+++ b/ruoyi-modules/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-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index fe0d5e7..bcae058 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-modules/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-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml
index b81c34d..e75bb17 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml
+++ b/ruoyi-modules/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}
+
+