mirror of https://gitee.com/stylefeng/roses
【role】更新角色相关接口
parent
2caa1cd098
commit
1f94d549c8
|
@ -58,4 +58,9 @@ public interface SystemConstants {
|
|||
*/
|
||||
String DEFAULT_SYSTEM_NAME = "Guns快速开发平台";
|
||||
|
||||
}
|
||||
/**
|
||||
* 超级管理员角色编码
|
||||
*/
|
||||
String SYSTEM_ADMIN_ROLE_CODE = "superAdmin";
|
||||
|
||||
}
|
||||
|
|
|
@ -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", "超级管理员不能被删除");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue