ソースを参照

feature(红白名单功能开发): 红白名单功能开发

红白名单功能开发
mazq 3 年 前
コミット
fe71dda841

+ 5 - 1
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/entity/AppFunApplyContent.java

@@ -42,7 +42,11 @@ public class AppFunApplyContent implements IdEntity<String> {
     @Column(name = "APP_NAME")
     private String appName;
 
-    /** 功能标识,多个用','号隔开 */
+    /** 功能id,多个用','号隔开 */
+    @Column(name = "FUN_IDS")
+    private String funIds;
+
+    /** 功能code,多个用','号隔开 */
     @Column(name = "FUN_CODES")
     private String funCodes;
 

+ 1 - 1
dcuc-auth-service/pom.xml

@@ -83,7 +83,7 @@
         <dependency>
             <groupId>com.dragoninfo</groupId>
             <artifactId>dcuc-duceap-api</artifactId>
-            <version>2.1.1-SNAPSHOT</version>
+            <version>2.1.2-SNAPSHOT</version>
         </dependency>
         <!--配置 dcuc 结束-->
 

+ 1 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AppFunAuthApplyServiceImpl.java

@@ -58,6 +58,7 @@ public class AppFunAuthApplyServiceImpl implements IAppFunAuthApplyService {
             applyContent.setAppCode(applyInfo.getApplyCode());
             applyContent.setAppId(appId);
             applyContent.setAppName(applyInfo.getApplyName());
+            applyContent.setFunIds(resourceDTO.getFunIds());
             applyContent.setFunCodes(resourceDTO.getFunCodes());
             applyContent.setFunNames(resourceDTO.getFunNames());
             applyContent.setAuthApplyId(workFlow.getId());

+ 17 - 12
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AppFunAuthResultServiceImpl.java

@@ -57,7 +57,7 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
             searchable.addSearchFilter("app_id", SearchOperator.eq, appId);
             List<AppFunAuthResult> exist =  getResultList(searchable);
             Map<String, AppFunAuthResult> resultMap = exist.stream()
-                    .collect(Collectors.toMap(AppFunAuthResult::getFunCode, item -> item, (old, last) -> last));
+                    .collect(Collectors.toMap(AppFunAuthResult::getFunId, item -> item, (old, last) -> last));
             addAuthApply(flow, applyInfo, resultMap);
             delAuthExist(applyInfo,resultMap);
         }
@@ -65,12 +65,12 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
     }
 
     private void delAuthExist(AppFunApplyContent applyInfo, Map<String, AppFunAuthResult> resultMap) {
-        String funCodes = applyInfo.getFunCodes();
-        List<String> applyFunCodes = Arrays.asList(funCodes.split(","));
-        Set<String> existFunCodes = resultMap.keySet();
-        for (String existFunCode : existFunCodes) {
-            if(!applyFunCodes.contains(existFunCode)) {
-                AppFunAuthResult authResult = resultMap.get(existFunCode);
+        String funCodes = applyInfo.getFunIds();
+        List<String> applyFunIds = Arrays.asList(funCodes.split(","));
+        Set<String> existFunIds = resultMap.keySet();
+        for (String existFunId : existFunIds) {
+            if(!applyFunIds.contains(existFunId)) {
+                AppFunAuthResult authResult = resultMap.get(existFunId);
                 authResultRepository.delete(authResult);
             }
         }
@@ -78,7 +78,7 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
     }
 
     private void addAuthApply(WorkFlow flow, AppFunApplyContent applyInfo, Map<String, AppFunAuthResult> resultMap) {
-        Set<String> existFunCodes = resultMap.keySet();
+        Set<String> existFunIds = resultMap.keySet();
         String userId = applyInfo.getUserId();
         String appId = applyInfo.getAppId();
         Date startTime = null;
@@ -97,23 +97,28 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
                 authStatus = AuthStatusEnum.OVER_DUE.getValue();
             }
         }
+        String funIds = applyInfo.getFunIds();
         String funCodes = applyInfo.getFunCodes();
-        String[] applyFunCodes = funCodes.split(",");
-        for (String funCode : applyFunCodes) {
-            if(!existFunCodes.contains(funCode)) {
+        String[] funCodeArr = funCodes.split(",");
+        String[] funIdsArr = funIds.split(",");
+        for (int i = 0; i < funIdsArr.length; i++) {
+            String funId = funIdsArr[i];
+            String funCode = funCodeArr[i];
+            if(!existFunIds.contains(funId)) {
                 AppFunAuthResult authResult = new AppFunAuthResult();
                 authResult.setAppId(appId);
                 authResult.setAppCode(applyInfo.getAppCode());
                 authResult.setAuthSource(flow.getApplySource());
                 authResult.setSourceId(flow.getMessageId());
                 authResult.setUserId(userId);
+                authResult.setFunId(funId);
                 authResult.setFunCode(funCode);
                 authResult.setAuthStatus(authStatus);
                 authResult.setStartTime(startTime);
                 authResult.setEndTime(endTime);
                 save(authResult);
             } else {
-                AppFunAuthResult authResult = resultMap.get(funCode);
+                AppFunAuthResult authResult = resultMap.get(funId);
                 authResult.setAuthSource(flow.getApplySource());
                 authResult.setSourceId(flow.getMessageId());
                 authResult.setAuthStatus(authStatus);

+ 40 - 34
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/WorkFlowServiceImpl.java

@@ -56,41 +56,9 @@ public class WorkFlowServiceImpl implements IWorkFlowService {
 
     @Override
     public ResponseStatus pushToApproval(AppFunAuthApplyDTO authApplyDTO) {
-        WorkFlowDTO workFlowDTO = authApplyDTO.getWorkFlow();
-        ApprovalWorkFlowDTO approvalWorkFlowDTO = new ApprovalWorkFlowDTO();
-        BeanUtils.copyProperties(workFlowDTO, approvalWorkFlowDTO, "resourceInfoDTO", "startTime", "endTime");
-        List<AppFunAuthResourceDTO> authResourceInfos = authApplyDTO.getResourceInfos();
-        String applicantIdcard = authApplyDTO.getWorkFlow().getApplicantIdcard();
-        String applicantName = authApplyDTO.getWorkFlow().getApplicantName();
-        ResourceInfoDTO resourceInfoDTO = new ResourceInfoDTO();
-        resourceInfoDTO.setVisitorName(applicantName);
-        resourceInfoDTO.setVisitorCode(applicantIdcard);
-
-        String funCodes = authResourceInfos.stream()
-                .map(AppFunAuthResourceDTO::getFunCodes)
-                .collect(Collectors.joining(StrUtil.COLON));
-        String funNames = authResourceInfos.stream()
-                .map(AppFunAuthResourceDTO::getFunNames)
-                .collect(Collectors.joining(StrUtil.COLON));
-        funCodes = funCodes.replaceAll(StrUtil.COMMA, StrUtil.SLASH).replaceAll(StrUtil.COLON, StrUtil.COMMA);
-        funNames = funNames.replaceAll(StrUtil.COMMA, StrUtil.SLASH).replaceAll(StrUtil.COLON, StrUtil.COMMA);
-        resourceInfoDTO.setVisitResourceCode(funCodes);
-        resourceInfoDTO.setVisitResourceName(funNames);
-        approvalWorkFlowDTO.setResourceInfoDTO(resourceInfoDTO);
 
-        if (WorkFlowPermissionTypeEnum.TEMP.getValue().equals(approvalWorkFlowDTO.getPermissionValidType())) {
-            Date startTime = workFlowDTO.getStartTime();
-            Date endTime = workFlowDTO.getEndTime();
-            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-            if (null != startTime) {
-                String startTimeStr = format.format(startTime);
-                approvalWorkFlowDTO.setStartTime(startTimeStr);
-            }
-            if (null != endTime) {
-                String endTimeStr = format.format(endTime);
-                approvalWorkFlowDTO.setStartTime(endTimeStr);
-            }
-        }
+        WorkFlowDTO workFlowDTO = authApplyDTO.getWorkFlow();
+        ApprovalWorkFlowDTO approvalWorkFlowDTO = prepareApprovalWorkFlowDTO(authApplyDTO, workFlowDTO);
 
         List<Header> headers = new ArrayList<>();
         RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
@@ -137,6 +105,44 @@ public class WorkFlowServiceImpl implements IWorkFlowService {
         return JSON.parseObject(response, ResponseStatus.class);
     }
 
+    private ApprovalWorkFlowDTO prepareApprovalWorkFlowDTO(AppFunAuthApplyDTO authApplyDTO, WorkFlowDTO workFlowDTO) {
+        ApprovalWorkFlowDTO approvalWorkFlowDTO = new ApprovalWorkFlowDTO();
+        BeanUtils.copyProperties(workFlowDTO, approvalWorkFlowDTO, "resourceInfoDTO", "startTime", "endTime");
+        List<AppFunAuthResourceDTO> authResourceInfos = authApplyDTO.getResourceInfos();
+        String applicantIdcard = authApplyDTO.getWorkFlow().getApplicantIdcard();
+        String applicantName = authApplyDTO.getWorkFlow().getApplicantName();
+        ResourceInfoDTO resourceInfoDTO = new ResourceInfoDTO();
+        resourceInfoDTO.setVisitorName(applicantName);
+        resourceInfoDTO.setVisitorCode(applicantIdcard);
+
+        String funCodes = authResourceInfos.stream()
+                .map(AppFunAuthResourceDTO::getFunCodes)
+                .collect(Collectors.joining(StrUtil.COLON));
+        String funNames = authResourceInfos.stream()
+                .map(AppFunAuthResourceDTO::getFunNames)
+                .collect(Collectors.joining(StrUtil.COLON));
+        funCodes = funCodes.replaceAll(StrUtil.COMMA, StrUtil.SLASH).replaceAll(StrUtil.COLON, StrUtil.COMMA);
+        funNames = funNames.replaceAll(StrUtil.COMMA, StrUtil.SLASH).replaceAll(StrUtil.COLON, StrUtil.COMMA);
+        resourceInfoDTO.setVisitResourceCode(funCodes);
+        resourceInfoDTO.setVisitResourceName(funNames);
+        approvalWorkFlowDTO.setResourceInfoDTO(resourceInfoDTO);
+
+        if (WorkFlowPermissionTypeEnum.TEMP.getValue().equals(approvalWorkFlowDTO.getPermissionValidType())) {
+            Date startTime = workFlowDTO.getStartTime();
+            Date endTime = workFlowDTO.getEndTime();
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+            if (null != startTime) {
+                String startTimeStr = format.format(startTime);
+                approvalWorkFlowDTO.setStartTime(startTimeStr);
+            }
+            if (null != endTime) {
+                String endTimeStr = format.format(endTime);
+                approvalWorkFlowDTO.setStartTime(endTimeStr);
+            }
+        }
+        return approvalWorkFlowDTO;
+    }
+
     @Override
     public WorkFlow getByMessageId(String messageId) {
         if(StringUtils.isBlank(messageId)) {