正在显示
5 个修改的文件
包含
33 行增加
和
2 行删除
| @@ -27,6 +27,14 @@ public interface SysRoleMenuMapper | @@ -27,6 +27,14 @@ public interface SysRoleMenuMapper | ||
| 27 | public int deleteRoleMenuByRoleId(Long roleId); | 27 | public int deleteRoleMenuByRoleId(Long roleId); |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | + * 批量删除角色菜单关联信息 | ||
| 31 | + * | ||
| 32 | + * @param ids 需要删除的数据ID | ||
| 33 | + * @return 结果 | ||
| 34 | + */ | ||
| 35 | + public int deleteRoleMenu(Long[] ids); | ||
| 36 | + | ||
| 37 | + /** | ||
| 30 | * 批量新增角色菜单信息 | 38 | * 批量新增角色菜单信息 |
| 31 | * | 39 | * |
| 32 | * @param roleMenuList 角色菜单列表 | 40 | * @param roleMenuList 角色菜单列表 |
| @@ -290,8 +290,13 @@ public class SysRoleServiceImpl implements ISysRoleService | @@ -290,8 +290,13 @@ public class SysRoleServiceImpl implements ISysRoleService | ||
| 290 | * @return 结果 | 290 | * @return 结果 |
| 291 | */ | 291 | */ |
| 292 | @Override | 292 | @Override |
| 293 | + @Transactional | ||
| 293 | public int deleteRoleById(Long roleId) | 294 | public int deleteRoleById(Long roleId) |
| 294 | { | 295 | { |
| 296 | + // 删除角色与菜单关联 | ||
| 297 | + roleMenuMapper.deleteRoleMenuByRoleId(roleId); | ||
| 298 | + // 删除角色与部门关联 | ||
| 299 | + roleDeptMapper.deleteRoleDeptByRoleId(roleId); | ||
| 295 | return roleMapper.deleteRoleById(roleId); | 300 | return roleMapper.deleteRoleById(roleId); |
| 296 | } | 301 | } |
| 297 | 302 | ||
| @@ -302,6 +307,7 @@ public class SysRoleServiceImpl implements ISysRoleService | @@ -302,6 +307,7 @@ public class SysRoleServiceImpl implements ISysRoleService | ||
| 302 | * @return 结果 | 307 | * @return 结果 |
| 303 | */ | 308 | */ |
| 304 | @Override | 309 | @Override |
| 310 | + @Transactional | ||
| 305 | public int deleteRoleByIds(Long[] roleIds) | 311 | public int deleteRoleByIds(Long[] roleIds) |
| 306 | { | 312 | { |
| 307 | for (Long roleId : roleIds) | 313 | for (Long roleId : roleIds) |
| @@ -313,6 +319,10 @@ public class SysRoleServiceImpl implements ISysRoleService | @@ -313,6 +319,10 @@ public class SysRoleServiceImpl implements ISysRoleService | ||
| 313 | throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName())); | 319 | throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName())); |
| 314 | } | 320 | } |
| 315 | } | 321 | } |
| 322 | + // 删除角色与菜单关联 | ||
| 323 | + roleMenuMapper.deleteRoleMenu(roleIds); | ||
| 324 | + // 删除角色与部门关联 | ||
| 325 | + roleDeptMapper.deleteRoleDept(roleIds); | ||
| 316 | return roleMapper.deleteRoleByIds(roleIds); | 326 | return roleMapper.deleteRoleByIds(roleIds); |
| 317 | } | 327 | } |
| 318 | } | 328 | } |
| @@ -363,6 +363,7 @@ public class SysUserServiceImpl implements ISysUserService | @@ -363,6 +363,7 @@ public class SysUserServiceImpl implements ISysUserService | ||
| 363 | * @return 结果 | 363 | * @return 结果 |
| 364 | */ | 364 | */ |
| 365 | @Override | 365 | @Override |
| 366 | + @Transactional | ||
| 366 | public int deleteUserById(Long userId) | 367 | public int deleteUserById(Long userId) |
| 367 | { | 368 | { |
| 368 | // 删除用户与角色关联 | 369 | // 删除用户与角色关联 |
| @@ -379,12 +380,17 @@ public class SysUserServiceImpl implements ISysUserService | @@ -379,12 +380,17 @@ public class SysUserServiceImpl implements ISysUserService | ||
| 379 | * @return 结果 | 380 | * @return 结果 |
| 380 | */ | 381 | */ |
| 381 | @Override | 382 | @Override |
| 383 | + @Transactional | ||
| 382 | public int deleteUserByIds(Long[] userIds) | 384 | public int deleteUserByIds(Long[] userIds) |
| 383 | { | 385 | { |
| 384 | for (Long userId : userIds) | 386 | for (Long userId : userIds) |
| 385 | { | 387 | { |
| 386 | checkUserAllowed(new SysUser(userId)); | 388 | checkUserAllowed(new SysUser(userId)); |
| 387 | } | 389 | } |
| 390 | + // 删除用户与角色关联 | ||
| 391 | + userRoleMapper.deleteUserRole(userIds); | ||
| 392 | + // 删除用户与岗位关联 | ||
| 393 | + userPostMapper.deleteUserPost(userIds); | ||
| 388 | return userMapper.deleteUserByIds(userIds); | 394 | return userMapper.deleteUserByIds(userIds); |
| 389 | } | 395 | } |
| 390 | 396 |
| @@ -17,6 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -17,6 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 17 | delete from sys_role_menu where role_id=#{roleId} | 17 | delete from sys_role_menu where role_id=#{roleId} |
| 18 | </delete> | 18 | </delete> |
| 19 | 19 | ||
| 20 | + <delete id="deleteRoleMenu" parameterType="Long"> | ||
| 21 | + delete from sys_role_menu where role_id in | ||
| 22 | + <foreach collection="array" item="roleId" open="(" separator="," close=")"> | ||
| 23 | + #{roleId} | ||
| 24 | + </foreach> | ||
| 25 | + </delete> | ||
| 26 | + | ||
| 20 | <insert id="batchRoleMenu"> | 27 | <insert id="batchRoleMenu"> |
| 21 | insert into sys_role_menu(role_id, menu_id) values | 28 | insert into sys_role_menu(role_id, menu_id) values |
| 22 | <foreach item="item" index="index" collection="list" separator=","> | 29 | <foreach item="item" index="index" collection="list" separator=","> |
-
请 注册 或 登录 后发表评论