【SysRoleResponse】 新增角色分类

pull/3/head
chenjinlong 2021-01-26 23:54:55 +08:00
parent 6e6e4251ad
commit 21fb538b85
6 changed files with 51 additions and 8 deletions

View File

@ -51,6 +51,6 @@ public interface SystemConstants {
/**
*
*/
String SYSTEM_ADMIN_ROLE_CODE = "superAdmin";
//String SYSTEM_ADMIN_ROLE_CODE = "superAdmin";
}

View File

@ -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", "系统角色不能被删除"),
/**
*
*/

View File

@ -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;
/**
*
*/

View File

@ -53,4 +53,14 @@ public class SysRoleResponse extends BaseRequest {
*/
private Integer statusFlag;
/**
* Y-N-
*/
private String roleSystemFlag;
/**
*
*/
private String roleTypeCode;
}

View File

@ -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;
}

View File

@ -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());