【role】更新角色相关接口

pull/3/head
fengshuonan 2021-01-08 21:56:10 +08:00
parent 2caa1cd098
commit 1f94d549c8
5 changed files with 23 additions and 4 deletions

View File

@ -58,4 +58,9 @@ public interface SystemConstants {
*/
String DEFAULT_SYSTEM_NAME = "Guns快速开发平台";
}
/**
*
*/
String SYSTEM_ADMIN_ROLE_CODE = "superAdmin";
}

View File

@ -51,7 +51,12 @@ public enum SysRoleExceptionEnum implements AbstractExceptionEnum {
/**
*
*/
ROLE_NAME_REPEAT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "43", "角色名称重复请检查name参数");
ROLE_NAME_REPEAT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "43", "角色名称重复请检查name参数"),
/**
*
*/
SUPER_ADMIN_CANT_DELETE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "44", "超级管理员不能被删除");
/**
*

View File

@ -77,7 +77,7 @@ public class SysRoleRequest extends BaseRequest {
private BigDecimal roleSort;
/**
* 10-20-30-40-50-
* 10-20-30-40-50-
*/
@Null(message = "数据范围类型应该为空, 请移除dataScopeType参数", groups = {add.class, edit.class})
@NotNull(message = "数据范围类型不能为空请检查dataScopeType参数", groups = {grantData.class})

View File

@ -113,7 +113,7 @@ public class SysRoleController {
* @date 2020/11/5 10:19
*/
@GetResource(name = "查询角色", path = "/sysRole/page")
public ResponseData page(@RequestBody SysRoleRequest sysRoleRequest) {
public ResponseData page(SysRoleRequest sysRoleRequest) {
return new SuccessResponseData(sysRoleService.page(sysRoleRequest));
}

View File

@ -46,6 +46,7 @@ import cn.stylefeng.roses.kernel.role.modular.service.SysRoleResourceService;
import cn.stylefeng.roses.kernel.role.modular.service.SysRoleService;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.system.RoleServiceApi;
import cn.stylefeng.roses.kernel.system.UserServiceApi;
@ -67,6 +68,9 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.stylefeng.roses.kernel.system.constants.SystemConstants.SYSTEM_ADMIN_ROLE_CODE;
import static cn.stylefeng.roses.kernel.system.exception.enums.SysRoleExceptionEnum.SUPER_ADMIN_CANT_DELETE;
/**
* service
*
@ -115,6 +119,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
public void delete(SysRoleRequest sysRoleRequest) {
SysRole sysRole = this.querySysRole(sysRoleRequest);
// 超级管理员不能删除
if (SYSTEM_ADMIN_ROLE_CODE.equals(sysRole.getRoleCode())) {
throw new ServiceException(SUPER_ADMIN_CANT_DELETE);
}
// 逻辑删除,设为删除标志
sysRole.setDelFlag(YesOrNotEnum.Y.getCode());