|
|
@@ -127,23 +127,17 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void remove(String ids) {
|
|
|
- List<String> idList = Arrays.asList(ids.split(","));
|
|
|
- idList.forEach(item -> {
|
|
|
- SysRole sysRole = this.getById(item);
|
|
|
- if("admin".equalsIgnoreCase(sysRole.getRoleCode())){
|
|
|
- throw new CustomException("管理员角色不可删除");
|
|
|
- }
|
|
|
- long userRoleCount = sysUserRoleService.count(Wrappers.lambdaQuery(SysUserRole.class).eq(SysUserRole::getRoleId, item));
|
|
|
- if (userRoleCount!=0) {
|
|
|
- throw new CustomException(String.format("角色【%s】存在用户,无法删除", sysRole.getRoleName()));
|
|
|
- }
|
|
|
-// long deptRoleCount = sysRoleDeptService.count(Wrappers.lambdaQuery(SysRoleDept.class).eq(SysRoleDept::getRoleId, item));
|
|
|
-// if (deptRoleCount!=0) {
|
|
|
-// throw new CustomException(String.format("角色【%s】已被使用,无法删除", sysRole.getRoleName()));
|
|
|
-// }
|
|
|
- });
|
|
|
- this.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ public void remove(String id) {
|
|
|
+ SysRole sysRole = this.getById(id);
|
|
|
+ if("admin".equalsIgnoreCase(sysRole.getRoleCode())){
|
|
|
+ throw new CustomException("管理员角色不可删除");
|
|
|
+ }
|
|
|
+ long userRoleCount = sysUserRoleService.count(Wrappers.lambdaQuery(SysUserRole.class).eq(SysUserRole::getRoleId, id));
|
|
|
+ if (userRoleCount!=0) {
|
|
|
+ throw new CustomException(String.format("角色【%s】存在用户,无法删除", sysRole.getRoleName()));
|
|
|
+ }
|
|
|
+ this.removeById(id);
|
|
|
+ sysRoleMenuService.remove(new QueryWrapper<SysRoleMenu>().lambda().eq(SysRoleMenu::getRoleId,sysRole.getId()));
|
|
|
}
|
|
|
|
|
|
@Override
|