mirror of https://gitee.com/stylefeng/roses
【SysRoleResponse】 新增角色分类
parent
6e6e4251ad
commit
21fb538b85
|
@ -51,6 +51,6 @@ public interface SystemConstants {
|
|||
/**
|
||||
* 超级管理员角色编码
|
||||
*/
|
||||
String SYSTEM_ADMIN_ROLE_CODE = "superAdmin";
|
||||
//String SYSTEM_ADMIN_ROLE_CODE = "superAdmin";
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,11 @@ public enum SysRoleExceptionEnum implements AbstractExceptionEnum {
|
|||
*/
|
||||
SUPER_ADMIN_CANT_DELETE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "44", "超级管理员不能被删除"),
|
||||
|
||||
/**
|
||||
* 超级管理员不能被删除
|
||||
*/
|
||||
SYSTEM_ROLE_CANT_DELETE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "45", "系统角色不能被删除"),
|
||||
|
||||
/**
|
||||
* 必须选择公司范围集合
|
||||
*/
|
||||
|
|
|
@ -26,6 +26,7 @@ package cn.stylefeng.roses.kernel.system.pojo.role.request;
|
|||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.validator.validators.unique.TableUniqueValue;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -93,6 +94,16 @@ public class SysRoleRequest extends BaseRequest {
|
|||
*/
|
||||
private Integer statusFlag;
|
||||
|
||||
/**
|
||||
* 是否是系统角色:Y-是,N-否
|
||||
*/
|
||||
private String roleSystemFlag;
|
||||
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
private String roleTypeCode;
|
||||
|
||||
/**
|
||||
* 授权资源
|
||||
*/
|
||||
|
|
|
@ -53,4 +53,14 @@ public class SysRoleResponse extends BaseRequest {
|
|||
*/
|
||||
private Integer statusFlag;
|
||||
|
||||
/**
|
||||
* 是否是系统角色:Y-是,N-否
|
||||
*/
|
||||
private String roleSystemFlag;
|
||||
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
private String roleTypeCode;
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,19 @@ public class SysRole extends BaseEntity {
|
|||
/**
|
||||
* 删除标记(Y-已删除,N-未删除)
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
@TableField(value = "del_flag",fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 是否是系统角色:Y-是,N-否
|
||||
*/
|
||||
@TableField("role_system_flag")
|
||||
private String roleSystemFlag;
|
||||
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
@TableField("role_type_code")
|
||||
private String roleTypeCode;
|
||||
|
||||
}
|
||||
|
|
|
@ -66,8 +66,6 @@ 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接口实现类
|
||||
|
@ -97,10 +95,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
public void add(SysRoleRequest sysRoleRequest) {
|
||||
SysRole sysRole = new SysRole();
|
||||
BeanUtil.copyProperties(sysRoleRequest, sysRole);
|
||||
|
||||
// 默认设置为启用
|
||||
sysRole.setStatusFlag(StatusEnum.ENABLE.getCode());
|
||||
|
||||
// 默认设置为普通角色
|
||||
sysRole.setRoleSystemFlag(YesOrNotEnum.N.getCode());
|
||||
//默认数据范围
|
||||
sysRole.setDataScopeType(DataScopeTypeEnum.SELF.getCode());
|
||||
this.save(sysRole);
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,14 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
SysRole sysRole = this.querySysRole(sysRoleRequest);
|
||||
|
||||
// 超级管理员不能删除
|
||||
if (SYSTEM_ADMIN_ROLE_CODE.equals(sysRole.getRoleCode())) {
|
||||
throw new ServiceException(SUPER_ADMIN_CANT_DELETE);
|
||||
if (YesOrNotEnum.Y.getCode().equals(sysRole.getRoleSystemFlag())) {
|
||||
throw new ServiceException(SysRoleExceptionEnum.SYSTEM_ROLE_CANT_DELETE);
|
||||
}
|
||||
// 超级管理员不能删除
|
||||
// TODO 暂时弃用
|
||||
//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