Prechádzať zdrojové kódy

feature(服务授权申请重复服务代码校验): 服务授权申请重复服务代码校验

服务授权申请重复服务代码校验
mazq 4 rokov pred
rodič
commit
c26e0271d1

+ 11 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/IServiceAuthBusiness.java

@@ -4,6 +4,8 @@ import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthFlowDTO;
 import com.dragoninfo.dcuc.auth.auth.dto.WorkFlowResutlAcceptDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 
+import java.util.List;
+
 /**
  * 工作流处理business层
  * @author mazq
@@ -24,4 +26,13 @@ public interface IServiceAuthBusiness {
      * @return
      */
     ResponseDTO serviceAuthFlowSave(ServiceAuthFlowDTO dto);
+
+    /**
+     * 服务授权申请查询是否有重复的授权申请
+     * @param appCode
+     * @param serviceCodes
+     * @return 存在申请中的重复授权单 返回响应状态'300' 内容为重复的服务code集合
+     *         存在申请中的重复授权单 返回响应状态'200'
+     */
+    ResponseDTO authFlowRepeatCheck(String appCode, List<String> serviceCodes);
 }

+ 21 - 3
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/impl/ServiceAuthBusinessImpl.java

@@ -12,6 +12,7 @@ import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthFlowDTO;
 import com.dragoninfo.dcuc.auth.auth.dto.WorkFlowDTO;
 import com.dragoninfo.dcuc.auth.auth.dto.WorkFlowResutlAcceptDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthFlow;
+import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthResult;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WokrFlowPermissionTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.service.IAuthFlowService;
@@ -110,9 +111,9 @@ public class ServiceAuthBusinessImpl implements IServiceAuthBusiness {
             }
         }
         //校验服务授权是否存在重复申请
-        List<String> exitstServiceCodes = authFlowService.authFlowRepeatCheck(dto.getAppCode(), Arrays.asList(serviceCodArray));
-        if(!CollectionUtils.isEmpty(exitstServiceCodes)) {
-            return ResponseDTO.fail(ResponseStatus.FAIL_CODE, String.format("服务授权申请中,服务code: %s ", exitstServiceCodes), exitstServiceCodes);
+        ResponseDTO checkRepeat = authFlowRepeatCheck(dto.getAppCode(), Arrays.asList(serviceCodArray));
+        if(!ResponseStatus.SUCCESS_CODE.equals(checkRepeat.getStatusCode())){
+            return checkRepeat;
         }
         String flowStatus = WorkFlowStatusEnum.APPLYING.getValue();
         //生成消息id
@@ -155,6 +156,23 @@ public class ServiceAuthBusinessImpl implements IServiceAuthBusiness {
         return responseDTO;
     }
 
+    @Override
+    public ResponseDTO authFlowRepeatCheck(String appCode, List<String> serviceCodes) {
+        List<String> list = authFlowService.authFlowApplyRepeatCheck(appCode, serviceCodes);
+        if(!CollectionUtils.isEmpty(list)) {
+            return ResponseDTO.fail(ResponseStatus.FAIL_CODE, String.format("服务授权申请中,申请中的服务代码:%s ", list), list);
+        }
+        List<ServiceAuthResult> authResults = authResultService.getByAppCode(appCode);
+        List<String> exist = authResults.stream()
+                .map(item -> item.getServiceCode())
+                .filter(item -> serviceCodes.contains(item))
+                .collect(Collectors.toList());
+        if(!CollectionUtils.isEmpty(list)) {
+            return ResponseDTO.fail(ResponseStatus.FAIL_CODE, String.format("服务授权已存在,存在的服务代码:%s ", exist), exist);
+        }
+        return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,null);
+    }
+
     /**
      * 将服务授权工作单推送给审批服务
      *

+ 1 - 6
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/ServiceAuthFacade.java

@@ -107,11 +107,6 @@ public class ServiceAuthFacade implements IServiceAuthFlowFacade {
 
     @Override
     public ResponseDTO authFlowRepeatCheck(String appCode, List<String> serviceCodes) {
-        List<String> list = authFlowService.authFlowRepeatCheck(appCode, serviceCodes);
-        if(CollectionUtils.isEmpty(list)){
-            return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,null);
-        }else {
-            return ResponseDTO.fail(ResponseStatus.FAIL_CODE,list);
-        }
+       return serviceAuthBusiness.authFlowRepeatCheck(appCode, serviceCodes);
     }
 }

+ 1 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IAuthFlowService.java

@@ -71,5 +71,5 @@ public interface IAuthFlowService {
      * @param serviceCodes
      * @return
      */
-    List<String> authFlowRepeatCheck(String appCode, List<String> serviceCodes);
+    List<String> authFlowApplyRepeatCheck(String appCode, List<String> serviceCodes);
 }

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

@@ -125,7 +125,7 @@ public class AuthFlowServiceImpl implements IAuthFlowService {
     }
 
     @Override
-    public List<String> authFlowRepeatCheck(String appCode, List<String> serviceCodes) {
+    public List<String> authFlowApplyRepeatCheck(String appCode, List<String> serviceCodes) {
         Searchable searchable = Searchable.newSearchable();
         searchable.addSearchFilter("app_code",SearchOperator.eq,appCode);
         searchable.addSearchFilter("flow_status",SearchOperator.eq, WorkFlowStatusEnum.APPLYING.getValue());