diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/constants/SystemConstants.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/constants/SystemConstants.java index 36ba71f48..364411e7c 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/constants/SystemConstants.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/constants/SystemConstants.java @@ -51,6 +51,6 @@ public interface SystemConstants { /** * 超级管理员角色编码 */ - String SYSTEM_ADMIN_ROLE_CODE = "superAdmin"; + //String SYSTEM_ADMIN_ROLE_CODE = "superAdmin"; } diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/SysRoleExceptionEnum.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/SysRoleExceptionEnum.java index 45b12d522..a94da9ef7 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/SysRoleExceptionEnum.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/SysRoleExceptionEnum.java @@ -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", "系统角色不能被删除"), + /** * 必须选择公司范围集合 */ diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/request/SysRoleRequest.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/request/SysRoleRequest.java index bfa1266aa..d425cddc9 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/request/SysRoleRequest.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/request/SysRoleRequest.java @@ -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; + /** * 授权资源 */ diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/response/SysRoleResponse.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/response/SysRoleResponse.java index d719ee50f..a1d15c652 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/response/SysRoleResponse.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/role/response/SysRoleResponse.java @@ -53,4 +53,14 @@ public class SysRoleResponse extends BaseRequest { */ private Integer statusFlag; + /** + * 是否是系统角色:Y-是,N-否 + */ + private String roleSystemFlag; + + /** + * 角色类型 + */ + private String roleTypeCode; + } diff --git a/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/entity/SysRole.java b/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/entity/SysRole.java index bedf159df..ad75f69b3 100644 --- a/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/entity/SysRole.java +++ b/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/entity/SysRole.java @@ -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; + } diff --git a/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/service/impl/SysRoleServiceImpl.java b/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/service/impl/SysRoleServiceImpl.java index be901e4e8..a3b92226d 100644 --- a/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/service/impl/SysRoleServiceImpl.java +++ b/kernel-s-system/system-business-role/src/main/java/cn/stylefeng/roses/kernel/role/modular/service/impl/SysRoleServiceImpl.java @@ -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 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 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());