update 内置角色无法删除
This commit is contained in:
+11
@@ -82,6 +82,9 @@ public class SysRoleController {
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
private final static List<String> INTERNAL_ROLE =
|
||||
Arrays.asList("admin", "xmfzr", "cwry", "yjry", "dbry", "sld", "bmfzr", "qyry");
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @param role
|
||||
@@ -194,6 +197,10 @@ public class SysRoleController {
|
||||
IPage<SysUser> pageInfo = sysUserService.getUserByRoleId(new Page<>(), id, null);
|
||||
long total = pageInfo.getTotal();
|
||||
if (total == 0) {
|
||||
SysRole sysRole = sysRoleService.getById(id);
|
||||
if (INTERNAL_ROLE.contains(sysRole.getRoleCode())){
|
||||
throw new JeroBootException("内置角色无法删除");
|
||||
}
|
||||
sysRoleService.deleteRole(id);
|
||||
return Result.OK("删除角色成功");
|
||||
} else {
|
||||
@@ -218,7 +225,11 @@ public class SysRoleController {
|
||||
IPage<SysUser> pageInfo = sysUserService.getUserByRoleId(new Page<>(), id, null);
|
||||
long total = pageInfo.getTotal();
|
||||
if (total != 0) {
|
||||
|
||||
SysRole sysRole = sysRoleService.getById(id);
|
||||
if (INTERNAL_ROLE.contains(sysRole.getRoleCode())){
|
||||
throw new JeroBootException("内置角色无法删除");
|
||||
}
|
||||
roleNames.add(sysRole.getRoleName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user