TRX 1 năm trước cách đây
mục cha
commit
8ee8fc27fb

+ 3 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/RoleAddParam.java

@@ -12,4 +12,7 @@ import lombok.Data;
 public class RoleAddParam extends SuperParam {
     @Schema(description = "名称")
     private String name;
+
+    @Schema(description = "角色编码")
+    private String code;
 }

+ 20 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/RoleModel.java

@@ -1,9 +1,12 @@
 package com.zhongshu.card.client.model.org;
 
 import com.zhongshu.card.client.model.base.SuperModel;
+import com.zhongshu.card.client.utils.type.RoleType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.Set;
+
 /**
  * @author TRX
  * @date 2024/5/31
@@ -16,4 +19,21 @@ public class RoleModel extends SuperModel {
     @Schema(description = "角色编码")
     private String code;
 
+    @Schema(description = "角色类型")
+    RoleType roleType;
+
+    private String roleTypeStr;
+
+    @Schema(description = "角色权限列表")
+    private Set<String> auth;
+
+    public String getRoleTypeStr() {
+        if (roleType != null) {
+            return roleType.getRemark();
+        }
+        return "";
+    }
+
+    @Schema(description = "是否管理角色")
+    private Boolean isAdmin = Boolean.FALSE;
 }

+ 3 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/RoleSearchParam.java

@@ -12,4 +12,7 @@ import lombok.Data;
 public class RoleSearchParam extends SuperSearch {
     @Schema(description = "名称")
     private String name;
+
+    @Schema(description = "角色编码")
+    private String code;
 }

+ 19 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/utils/type/RoleType.java

@@ -0,0 +1,19 @@
+package com.zhongshu.card.client.utils.type;
+
+import lombok.Getter;
+
+/**
+ * 用户类型
+ */
+public enum RoleType {
+    BuildIn("系统内置"),
+    Custom("自定义"),
+    ;
+
+    @Getter
+    private String remark;
+
+    RoleType(String remark) {
+        this.remark = remark;
+    }
+}

+ 5 - 5
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/DepartmentController.java

@@ -23,24 +23,24 @@ public class DepartmentController {
     @Autowired
     private DepartmentService departmentService;
 
-    @ResourceAuth(value = "user",type = AuthType.User)
+    @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "添加-编辑部门", description = "添加-编辑部门")
     @RequestMapping(value = "addDepartment", method = {RequestMethod.POST})
-    public ResultContent addDepartment(DepartmentParam param) {
+    public ResultContent addDepartment(@RequestBody DepartmentParam param) {
         return this.departmentService.addDepartment(param);
     }
 
-    @ResourceAuth(value = "user",type = AuthType.User)
+    @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "得到机构部门树", description = "得到机构部门树")
     @RequestMapping(value = "getDepartmentTree", method = {RequestMethod.POST})
     public ResultContent getDepartmentTree(@RequestBody OidModel param) {
         return this.departmentService.getDepartmentTree(param.getOid());
     }
 
-    @ResourceAuth(value = "user",type = AuthType.User)
+    @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "删除部门", description = "删除部门")
     @RequestMapping(value = "deleteDepartment", method = {RequestMethod.POST})
-    public ResultContent deleteDepartment(IDParam param) {
+    public ResultContent deleteDepartment(@RequestBody IDParam param) {
         return this.departmentService.deleteDepartment(param.getId());
     }
 

+ 63 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/RoleController.java

@@ -0,0 +1,63 @@
+package com.zhongshu.card.server.core.controller.org;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.org.*;
+import com.zhongshu.card.client.ret.ResultContent;
+import com.zhongshu.card.server.core.service.org.RoleService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("role")
+@Tag(name = "角色管理")
+public class RoleController {
+
+    @Autowired
+    RoleService roleService;
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "添加-编辑角色", description = "添加-编辑角色")
+    @RequestMapping(value = "addRole", method = {RequestMethod.POST})
+    public ResultContent addRole(@RequestBody RoleAddParam param) {
+        return this.roleService.addRole(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "角色列表-分页查询", description = "角色列表-分页查询")
+    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
+    public ResultContent<Page<RoleModel>> page(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) RoleSearchParam param) {
+        return roleService.page(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除角色", description = "删除角色")
+    @RequestMapping(value = "deleteRole", method = {RequestMethod.POST})
+    public ResultContent deleteRole(@RequestBody IDParam param) {
+        return this.roleService.deleteRole(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "角色详情", description = "角色详情")
+    @RequestMapping(value = "getRole", method = {RequestMethod.POST})
+    public ResultContent<RoleModel> getRole(@RequestBody IDParam param) {
+        return this.roleService.getRole(param.getId());
+    }
+
+}

+ 2 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/RoleDao.java

@@ -15,4 +15,6 @@ public interface RoleDao extends MongoDao<Role>, RoleDaoExtend {
     Role findTopById(String id);
 
     Role findTopByNameAndOid(String name, String oid);
+
+    Role findTopByCodeAndOid(String code, String oid);
 }

+ 4 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/org/impl/RoleDaoImpl.java

@@ -47,10 +47,13 @@ public class RoleDaoImpl extends BaseImpl implements RoleDaoExtend {
             Pattern pattern = Pattern.compile("^.*" + param.getName() + ".*$");
             criterias.add(Criteria.where("name").is(pattern));
         }
+        if (StringUtils.isNotEmpty(param.getCode())) {
+            Pattern pattern = Pattern.compile("^.*" + param.getName() + ".*$");
+            criterias.add(Criteria.where("code").is(pattern));
+        }
         if (!CollectionUtils.isEmpty(criterias)) {
             criteria.andOperator(criterias.toArray(new Criteria[]{}));
         }
-
         criteria.and("isDelete").is(Boolean.FALSE);
         Sort sort = buildSort(param);
         Query query = Query.query(criteria);

+ 9 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/Role.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.domain.org;
 
+import com.zhongshu.card.client.utils.type.RoleType;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.*;
@@ -27,17 +28,24 @@ public class Role extends SuperMain {
     @Schema(description = "角色编码")
     private String code;
 
+    @Schema(description = "角色类型")
+    RoleType roleType;
+
     @Schema(description = "是否管理角色")
     @Indexed
-    private boolean isAdmin = false;
+    private Boolean isAdmin = Boolean.FALSE;
 
     @Schema(description = "角色权限列表")
     @Indexed
     private Set<String> auth;
 
+    @Schema(description = "权限执行的角色组id")
     @Indexed
     private String roleGroupId;
 
+    @Schema(description = "权限中心的角色ID")
+    private String roleId;
+
     @Schema(description = "操作人")
     @DBRef(lazy = true)
     private UserAccount creator;

+ 14 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/DepartmentServiceImpl.java

@@ -9,6 +9,7 @@ import com.zhongshu.card.client.ret.ResultMessage;
 import com.zhongshu.card.client.service.org.DepartmentService;
 import com.zhongshu.card.client.utils.ITree;
 import com.zhongshu.card.client.utils.TreeUtil;
+import com.zhongshu.card.client.utils.type.DataState;
 import com.zhongshu.card.server.core.dao.org.DepartmentDao;
 import com.zhongshu.card.server.core.domain.org.Department;
 import com.zhongshu.card.server.core.domain.org.Organization;
@@ -56,6 +57,18 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
         if (CommonUtil.longIsEmpty(param.getSort())) {
             param.setSort(1L);
         }
+        if (StringUtils.isEmpty(param.getParentId())) {
+            param.setParentId(ITree.ROOT_ID);
+        }
+        if (!param.getParentId().equals(ITree.ROOT_ID)) {
+            Department temp = departmentDao.findTopById(param.getParentId());
+            if (ObjectUtils.isEmpty(temp)) {
+                return ResultContent.buildFail(String.format("上级部门ID不存在:%s", param.getParentId()));
+            }
+        }
+        if(param.getState() == null) {
+            param.setState(DataState.Enable);
+        }
         Department department = null;
         if (StringUtils.isNotEmpty(param.getId())) {
             department = departmentDao.findTopById(param.getId());
@@ -103,7 +116,7 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
             return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
         }
         List<Department> childrens = departmentDao.findByParentIdAndOid(id, oid);
-        if(ObjectUtils.isNotEmpty(childrens)) {
+        if (ObjectUtils.isNotEmpty(childrens)) {
             return ResultContent.buildFail(String.format("%s 有下级部门,不能删除", department.getName()));
         }
         return ResultContent.buildSuccess();

+ 18 - 19
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/OrganizationServiceImpl.java

@@ -18,6 +18,7 @@ import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.client.ret.ResultMessage;
 import com.zhongshu.card.client.service.org.OrganizationService;
 import com.zhongshu.card.client.utils.type.OrganizationState;
+import com.zhongshu.card.client.utils.type.RoleType;
 import com.zhongshu.card.client.utils.type.UserState;
 import com.zhongshu.card.server.core.dao.org.*;
 import com.zhongshu.card.server.core.dataConfig.CardDefault;
@@ -96,7 +97,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
      */
     @Override
     public ResultContent<Organization> addOrganization(OrganizationAddParam param) {
-        if(StringUtils.isNotEmpty(param.getPassword())) {
+        if (StringUtils.isNotEmpty(param.getPassword())) {
             // 验证密码是否符合格式
             ValidateResult validateResult = ValidateUtils.validatePassWord(param.getPassword());
             if (!validateResult.isSuccess()) {
@@ -134,8 +135,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
         organizationModel.setName(param.getName());
         organizationModel.setAuthType(authType);
         organizationModel.setRemark(param.getRemark());
-        com.github.microservice.auth.client.content.ResultContent<String>
-                resultContent = organizationService.add(organizationModel);
+        com.github.microservice.auth.client.content.ResultContent<String> resultContent = organizationService.add(organizationModel);
 
         if (resultContent.getState() == ResultState.Success) {
             log.info("平台初始成功: {}", resultContent.getContent());
@@ -300,6 +300,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
 
     /**
      * 查询结构详情
+     *
      * @param oid
      * @return
      */
@@ -435,8 +436,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
             organizationModel.setName(CardDefault.DEFAULT_PLATFORM_NAME);
             organizationModel.setAuthType(authType);
             organizationModel.setRemark("系统自动初始化");
-            com.github.microservice.auth.client.content.ResultContent<String>
-                    resultContent = organizationService.add(organizationModel);
+            com.github.microservice.auth.client.content.ResultContent<String> resultContent = organizationService.add(organizationModel);
 
             if (resultContent.getState() == ResultState.Success) {
                 log.info("平台初始成功: {}", resultContent.getContent());
@@ -477,17 +477,14 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
     public ResultContent initOrganization(Organization organization, String password) {
         String userId = "";
         // 查询用户是否存在
-        com.github.microservice.auth.client.content.ResultContent<UserModel> userModelResult =
-                userService.queryFromLoginType(LoginType.Phone, organization.getContactPhone());
+        com.github.microservice.auth.client.content.ResultContent<UserModel> userModelResult = userService.queryFromLoginType(LoginType.Phone, organization.getContactPhone());
         if (userModelResult.getState() != ResultState.Success) {
             //未注册
             //TODO 权限中心: 注册用户
             if (StringUtils.isEmpty(password)) {
                 password = CardDefault.DEFAULT_PASSWORD;
             }
-            com.github.microservice.auth.client.content.ResultContent<String> addModelResult = userService.add(
-                    UserAuthModel.builder().loginType(LoginType.Phone).loginValue(organization.getContactPhone())
-                            .passWord(password).build());
+            com.github.microservice.auth.client.content.ResultContent<String> addModelResult = userService.add(UserAuthModel.builder().loginType(LoginType.Phone).loginValue(organization.getContactPhone()).passWord(password).build());
             userId = addModelResult.getContent();
             log.info("初始权限中心 用户成功:{}", userId);
         } else {
@@ -562,16 +559,16 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
                 roleModel.setName(CardDefault.DEFAULT_ROLE_NAME);
                 roleModel.setRemark(CardDefault.DEFAULT_ROLE_NAME);
                 roleModel.setAuth(auth);
-                com.github.microservice.auth.client.content.ResultContent<String> updateRole =
-                        roleService.updateRole(roleModel);
-                roleService.addRoleToRoleGroup(groupId, new String[]{updateRole.getContent()});
+                com.github.microservice.auth.client.content.ResultContent<String> updateRole = roleService.updateRole(roleModel);
+                String roleId = updateRole.getContent();
+                roleService.addRoleToRoleGroup(groupId, new String[]{roleId});
                 log.info("权限中心:初始角色和角色组关系成功");
 
                 // 添加本地角色信息
                 adminRole = new Role();
                 if (organization.getAuthType().equals(AuthType.Platform)) {
                     adminRole.setCode(AuthConstant.SuperAdmin);
-                }else {
+                } else {
                     adminRole.setCode(AuthConstant.Admin);
                 }
                 adminRole.setAuth(auth);
@@ -579,7 +576,9 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
                 adminRole.setRoleGroupId(groupId);
                 adminRole.setName(CardDefault.DEFAULT_ROLE_NAME);
                 adminRole.setRemark(CardDefault.DEFAULT_ROLE_NAME);
-                adminRole.setAdmin(true);
+                adminRole.setRoleType(RoleType.BuildIn);
+                adminRole.setIsAdmin(Boolean.TRUE);
+                adminRole.setRoleId(roleId);
                 roleDao.save(adminRole);
 
                 //权限中心: 将用户添加进管理员角色组
@@ -607,7 +606,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
         if (ObjectUtils.isNotEmpty(entity)) {
             BeanUtils.copyProperties(entity, model);
             // 判断不同的类型
-            if(entity.getAuthType() == AuthType.School) {
+            if (entity.getAuthType() == AuthType.School) {
                 // 学校:查询出关联的项目信息
                 OrganizationRelation organization = organizationRelationDao.findTopByMainOrganizationAndAuthType(entity, AuthType.School);
                 if (ObjectUtils.isNotEmpty(organization)) {
@@ -617,13 +616,13 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
 
             // 区域信息
             String adminDivisionItemCode = entity.getAdminDivisionItemCode();
-            if(StringUtils.isEmpty(adminDivisionItemCode)) {
+            if (StringUtils.isEmpty(adminDivisionItemCode)) {
                 List<String> codes = List.of(adminDivisionItemCode.split(","));
                 List<Region> regions = regionDao.findByCodeIn(codes);
-                List<RegionModel> regionList = regions.stream().map(it->{
+                List<RegionModel> regionList = regions.stream().map(it -> {
                     RegionModel regionModel = new RegionModel();
                     BeanUtils.copyProperties(it, regionModel);
-                    return  regionModel;
+                    return regionModel;
                 }).collect(Collectors.toList());
                 model.setRegionList(regionList);
             }

+ 186 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/RoleService.java

@@ -0,0 +1,186 @@
+package com.zhongshu.card.server.core.service.org;
+
+import com.github.microservice.auth.client.content.ResultState;
+import com.github.microservice.auth.client.model.RoleGroupModel;
+import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.zhongshu.card.client.model.org.*;
+import com.zhongshu.card.client.ret.ResultContent;
+import com.zhongshu.card.client.ret.ResultMessage;
+import com.zhongshu.card.client.utils.type.RoleType;
+import com.zhongshu.card.server.core.dao.org.RoleDao;
+import com.zhongshu.card.server.core.dataConfig.CardDefault;
+import com.zhongshu.card.server.core.domain.org.Organization;
+import com.zhongshu.card.server.core.domain.org.Role;
+import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.util.BeanUtils;
+import com.zhongshu.card.server.core.util.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+import java.util.List;
+
+/**
+ * @author TRX
+ * @date 2024/6/5
+ */
+@Slf4j
+@Service
+public class RoleService extends SuperService {
+
+    @Autowired
+    RoleDao roleDao;
+
+    @Autowired
+    com.github.microservice.auth.client.service.RoleService roleService;
+
+    /**
+     * 添加/编辑角色
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent addRole(RoleAddParam param) {
+        Assert.hasText(param.getName(), "name不能为空");
+        Assert.hasText(param.getCode(), "code不能为空");
+        String oid = param.getOid();
+        if (StringUtils.isEmpty(oid)) {
+            oid = getCurrentOid();
+        }
+        param.setOid(oid);
+        if (param.getSort() == null) {
+            param.setSort(1L);
+        }
+        Role nameRole = roleDao.findTopByNameAndOid(param.getName(), oid);
+        Role codeRole = roleDao.findTopByCodeAndOid(param.getCode(), oid);
+        if (StringUtils.isEmpty(param.getId())) {
+            param.setId(null);
+            // 添加
+            if (ObjectUtils.isNotEmpty(nameRole)) {
+                return ResultContent.buildFail(String.format("角色名称已存在:%s", param.getName()));
+            }
+            if (ObjectUtils.isNotEmpty(codeRole)) {
+                return ResultContent.buildFail(String.format("角色名称已存在:%s", param.getCode()));
+            }
+
+            RoleGroupModel admin = new RoleGroupModel();
+            admin.setName(param.getName());
+            admin.setRemark("");
+            admin.setOrganizationId(oid);
+            com.github.microservice.auth.client.content.ResultContent<String> updateRoleGroupAdmin = roleService.updateRoleGroup(admin);
+            String groupId = updateRoleGroupAdmin.getContent();
+
+            com.github.microservice.auth.client.model.RoleModel roleModel = new com.github.microservice.auth.client.model.RoleModel();
+            roleModel.setOrganizationId(oid);
+            roleModel.setName(param.getName());
+            roleModel.setRemark("");
+            // 添加角色
+            com.github.microservice.auth.client.content.ResultContent<String> updateRole = roleService.updateRole(roleModel);
+            String roleId = updateRole.getContent();
+            // 把角色绑定到角色组
+            roleService.addRoleToRoleGroup(groupId, new String[]{updateRole.getContent()});
+
+            Role role = new Role();
+            BeanUtils.copyProperties(param, role);
+            role.setRoleGroupId(groupId);
+            role.setRoleType(RoleType.Custom);
+            role.setRoleId(roleId);
+            role.setCreateUserId(getCurrentUserId());
+            role.setIsAdmin(Boolean.FALSE);
+            roleDao.save(role);
+        } else {
+            // 编辑
+            Role role = roleDao.findTopById(param.getId());
+            if (ObjectUtils.isEmpty(role)) {
+                return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
+            }
+            if (ObjectUtils.isNotEmpty(nameRole) && !nameRole.getId().equals(role.getId())) {
+                return ResultContent.buildFail(String.format("角色名称已存在:%s", param.getName()));
+            }
+            if (ObjectUtils.isNotEmpty(codeRole) && !codeRole.getId().equals(role.getId())) {
+                return ResultContent.buildFail(String.format("角色编码已存在:%s", param.getCode()));
+            }
+            com.github.microservice.auth.client.content.ResultContent<RoleGroupModel> resultContent = roleService.getRoleGroup(role.getRoleGroupId());
+            if (resultContent.getState() == ResultState.Success) {
+                RoleGroupModel roleGroupModel = resultContent.getContent();
+                roleGroupModel.setName(param.getName());
+                roleService.updateRoleGroup(roleGroupModel);
+            }
+
+            if (StringUtils.isNotEmpty(role.getRoleId())) {
+                com.github.microservice.auth.client.content.ResultContent<com.github.microservice.auth.client.model.RoleModel> roleModelResultContent = roleService.getRole(role.getRoleId());
+                if (roleModelResultContent.getState() == ResultState.Success) {
+                    com.github.microservice.auth.client.model.RoleModel roleModel = roleModelResultContent.getContent();
+                    roleModel.setName(param.getName());
+                    roleService.updateRole(roleModel);
+                }
+            }
+            // 编辑本地角色
+            BeanUtils.copyProperties(param, role);
+            roleDao.save(role);
+        }
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 删除角色
+     *
+     * @param id
+     * @return
+     */
+    public ResultContent deleteRole(String id) {
+        Role role = roleDao.findTopById(id);
+        if (ObjectUtils.isEmpty(role)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        if (role.getIsAdmin() != null && role.getIsAdmin()) {
+            return ResultContent.buildFail(String.format("管理员角色不能删除"));
+        }
+        // 删除本地角色
+        roleDao.delete(role);
+        // 删除权限中心角色
+        roleService.removeRole(role.getRoleId());
+        roleService.removeRoleGroup(role.getRoleGroupId());
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 角色详情
+     *
+     * @param id
+     * @return
+     */
+    public ResultContent<RoleModel> getRole(String id) {
+        Role role = roleDao.findTopById(id);
+        if (ObjectUtils.isEmpty(role)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        RoleModel roleModel = toModel(role);
+        return ResultContent.buildSuccess(roleModel);
+    }
+
+    /**
+     * 角色列表
+     *
+     * @param param
+     * @param pageable
+     * @return
+     */
+    public ResultContent<Page<RoleModel>> page(RoleSearchParam param, Pageable pageable) {
+        Page<Role> page = roleDao.page(pageable, param);
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
+
+    public RoleModel toModel(Role role) {
+        RoleModel roleModel = new RoleModel();
+        if (ObjectUtils.isNotEmpty(role)) {
+            BeanUtils.copyProperties(role, roleModel);
+        }
+        return roleModel;
+    }
+}