Browse Source

feature: 角色授权申请列表接口开发

mazq 1 year ago
parent
commit
fe86deeb7a

+ 9 - 0
dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/IRoleAuthInfoFacade.java

@@ -3,6 +3,7 @@ package com.dragoninfo.dcuc.auth.auth.facade;
 import com.dragoninfo.dcuc.auth.auth.entity.StaffAssignAuthInfo;
 import com.dragoninfo.dcuc.auth.auth.vo.RoleInfoVO;
 import com.dragoninfo.dcuc.auth.auth.vo.TreeInfoVO;
+import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.roleauthapply.ApplyRoleInVo;
 import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.roleauthapply.RoleAuthApplySaveVo;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
@@ -88,4 +89,12 @@ public interface IRoleAuthInfoFacade {
      */
     @PostMapping("roleAuthApply")
     ResponseStatus roleAuthApply(@RequestBody RoleAuthApplySaveVo saveVo);
+
+    /**
+     * 角色授权-角色列表
+     * @param searchDTO
+     * @return
+     */
+    @PostMapping("applyRoleList")
+    List<ApplyRoleInVo> applyRoleList(@RequestBody SearchDTO searchDTO);
 }

+ 3 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/vo/zerotrust/roleauthapply/ApplyRoleInVo.java

@@ -15,6 +15,9 @@ public class ApplyRoleInVo {
     @ApiModelProperty(value = "应用id")
     private String appId;
 
+    @ApiModelProperty(value = "应用名称")
+    private String appName;
+
     @ApiModelProperty(value = "角色名称")
     private String roleName;
 

+ 66 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/RoleAuthInfoFacade.java

@@ -1,13 +1,21 @@
 package com.dragoninfo.dcuc.auth.auth.facade;
 
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
+import com.dragoninfo.dcuc.auth.auth.entity.RoleInfo;
 import com.dragoninfo.dcuc.auth.auth.entity.StaffAssignAuthInfo;
+import com.dragoninfo.dcuc.auth.auth.entity.zerotrust.RoleOperateContent;
 import com.dragoninfo.dcuc.auth.auth.service.IRoleAuthInfoService;
+import com.dragoninfo.dcuc.auth.auth.service.IRoleInfoService;
 import com.dragoninfo.dcuc.auth.auth.service.zerotrust.IRoleAuthApplyService;
+import com.dragoninfo.dcuc.auth.auth.service.zerotrust.IRoleOperateApplyService;
 import com.dragoninfo.dcuc.auth.auth.vo.RoleInfoVO;
 import com.dragoninfo.dcuc.auth.auth.vo.TreeInfoVO;
+import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.roleauthapply.ApplyRoleInVo;
 import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.roleauthapply.RoleAuthApplySaveVo;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.core.search.Searchable;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -16,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description:
@@ -31,14 +40,24 @@ public class RoleAuthInfoFacade implements IRoleAuthInfoFacade {
     @Autowired
     private IRoleAuthInfoService roleAuthInfoService;
 
+    @Autowired
+    private IRoleInfoService roleInfoService;
+
     @Autowired
     private IRoleAuthApplyService roleAuthApplyService;
 
+    @Autowired
+    private IRoleOperateApplyService roleOperateApplyService;
+
+    @Autowired
+    private IApplyInfoFacade applyInfoFacade;
+
     @Override
     public List<StaffAssignAuthInfo> getStaff(String roleId, String orgId) {
         return roleAuthInfoService.getStaff(roleId, orgId);
     }
 
+    @Override
     public Page<RoleInfoVO> getOrgRoleQuotaList(String appId, String orgId, SearchDTO searchDTO) {
         return roleAuthInfoService.getOrgRoleQuotaList(appId, orgId, Searchable.toSearchable(searchDTO));
     }
@@ -59,7 +78,7 @@ public class RoleAuthInfoFacade implements IRoleAuthInfoFacade {
     }
 
     @Override
-    public Map<String, Object> getRoleTjInfo(String appId,String orgCode) {
+    public Map<String, Object> getRoleTjInfo(String appId, String orgCode) {
         return roleAuthInfoService.getRoleTjInfo(appId, orgCode);
     }
 
@@ -73,4 +92,50 @@ public class RoleAuthInfoFacade implements IRoleAuthInfoFacade {
     public ResponseStatus roleAuthApply(RoleAuthApplySaveVo saveVo) {
         return roleAuthApplyService.roleAuthApply(saveVo);
     }
+
+    @Override
+    public List<ApplyRoleInVo> applyRoleList(SearchDTO searchDTO) {
+        // 查询申请中的角色
+        List<RoleOperateContent> applyRolesContent = roleOperateApplyService.getApplyingRoleInfos();
+        List<ApplyRoleInVo> applyRoles = applyRolesContent.stream()
+                .map(e -> {
+                    ApplyRoleInVo vo = new ApplyRoleInVo();
+                    vo.setAppId(e.getAppId());
+                    vo.setRoleName(e.getName());
+                    vo.setRoleCode(e.getCode());
+                    vo.setApply(BooleanEnum.TRUE.value);
+                    return vo;
+                }).collect(Collectors.toList());
+
+        // 查所有的已存在的角色列表
+        List<RoleInfo> all = roleInfoService.findAll();
+        List<ApplyRoleInVo> collect = all.stream()
+                .filter(e -> BooleanEnum.TRUE.value.equals(e.getIsActive()))
+                .map(e -> {
+                    ApplyRoleInVo vo = new ApplyRoleInVo();
+                    vo.setAppId(e.getAppId());
+                    vo.setRoleName(e.getName());
+                    vo.setRoleCode(e.getCode());
+                    vo.setApply(BooleanEnum.FALSE.value);
+                    return vo;
+                }).collect(Collectors.toList());
+        applyRoles.addAll(collect);
+
+        // 设置应用信息
+        List<String> appIds = applyRoles.stream()
+                .map(ApplyRoleInVo::getAppId)
+                .distinct()
+                .collect(Collectors.toList());
+
+        List<ApplyInfo> applyInfos = applyInfoFacade.getAppById(appIds);
+        Map<String, String> appInfoMap = applyInfos.stream()
+                .collect(Collectors.toMap(ApplyInfo::getId, ApplyInfo::getApplyName));
+        applyRoles.forEach(e-> {
+            String appId = e.getAppId();
+            String appName = appInfoMap.get(appId);
+            e.setAppName(appName);
+        });
+
+        return applyRoles;
+    }
 }

+ 10 - 4
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/zerotrust/RoleOperateApplyServiceImpl.java

@@ -29,10 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * 角色操作申请业务类
@@ -138,5 +135,14 @@ public class RoleOperateApplyServiceImpl implements IRoleOperateApplyService {
         repository.updateApprovalResult(id, approvalResult);
     }
 
+    @Override
+    public List<RoleOperateContent> getApplyingRoleInfos() {
+        RoleOperateContent content = new RoleOperateContent();
+        content.setOperateType(OperateTypeEnum.ADD.getValue());
+        content.setApprovalResult(AuthApplyStatusEnum.APPLYING.getValue());
+        Example<RoleOperateContent> example = Example.of(content);
+        return repository.findAll(example);
+    }
+
 
 }

+ 9 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/zerotrust/IRoleOperateApplyService.java

@@ -4,6 +4,8 @@ import com.dragoninfo.dcuc.auth.auth.entity.zerotrust.RoleOperateContent;
 import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.rolemanage.RoleOperateApplyVo;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 
+import java.util.List;
+
 /**
  * 角色操作申请业务类
  *
@@ -42,4 +44,11 @@ public interface IRoleOperateApplyService {
      * @param approvalResult
      */
     void updateApprovalResult(String id, String approvalResult);
+
+    /**
+     * 获取申请中的角色信息
+     * @return
+     */
+    List<RoleOperateContent> getApplyingRoleInfos();
+
 }