Bläddra i källkod

add xinlu api 返回值处理

GITZYY 7 månader sedan
förälder
incheckning
39cb16cf30

+ 26 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/common/DataVoStatusEnum.java

@@ -0,0 +1,26 @@
+package com.hrsk.cloud.eg.domain.api.common;
+
+import lombok.Getter;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: DataVoStatusEnum
+ * @date 2024/9/5 12:03
+ */
+@Getter
+public enum DataVoStatusEnum {
+
+   SUCCESS(1,"成功"),
+    FAIL(0,"失败");
+
+   private Integer code;
+   private String msg;
+   DataVoStatusEnum(Integer code, String msg) {
+       this.code = code;
+       this.msg = msg;
+   }
+
+
+
+}

+ 44 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/common/ThreeplatfromResultCodeEnum.java

@@ -0,0 +1,44 @@
+package com.hrsk.cloud.eg.domain.api.common;
+
+import com.google.common.collect.Lists;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: ThreeplatfromResultCodeEnum 对接api或者平台 成功的返回值用来
+ * @date 2024/9/5 13:52
+ */
+@Getter
+public enum ThreeplatfromResultCodeEnum {
+    ONE(200,""),
+    TWO(400,"")
+;
+    private Integer code;
+    private String msg;
+
+    ThreeplatfromResultCodeEnum(Integer code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public static ThreeplatfromResultCodeEnum getByCode(Integer code) {
+        for (ThreeplatfromResultCodeEnum result : ThreeplatfromResultCodeEnum.values()) {
+            if (result.getCode().equals(code)) {
+                return result;
+            }
+        }
+        return null;
+    }
+
+    public static List<Integer> getList() {
+        List<Integer> result = Lists.newArrayList();
+        for (ThreeplatfromResultCodeEnum code : ThreeplatfromResultCodeEnum.values()) {
+            result.add(code.getCode());
+        }
+        return result;
+    }
+}

+ 16 - 14
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/func/EncryptionFunction.java

@@ -4,6 +4,8 @@ package com.hrsk.cloud.eg.domain.api.func;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.hrsk.cloud.eg.domain.api.FunctionParam;
+import com.hrsk.cloud.eg.domain.api.common.DataVoStatusEnum;
+import com.hrsk.cloud.eg.domain.api.common.ThreeplatfromResultCodeEnum;
 
 import java.security.MessageDigest;
 import java.util.List;
@@ -49,22 +51,22 @@ public class EncryptionFunction {
             return null;
         }
     }
-    public static String outPrint(FunctionParam input) {
-        JSONObject.toJSONString(input);
-        System.out.println(input.getInput());
-        return "";
-    }
-
-
 
-    public static String md5Sign(FunctionParam functionParam) {
-        functionParam.setInput(JSON.toJSONString(functionParam));
 
-        List<Object> extArg = functionParam.getExtArg();
-        StringBuilder builder = new StringBuilder();
-        for (Object o : extArg) {
-            builder.append(o.toString());
+    /**
+     * @description:  第三方返回值进行配置
+     * @param:
+     * @return: Integer
+     * @author zhangyy
+     * @date: 2024/9/5 14:00
+     */
+    public static Integer resultCodeConvertStatus(FunctionParam functionParam) {
+        String value = functionParam.getInput().toString();
+        Integer result = Integer.valueOf(value);
+        if (ThreeplatfromResultCodeEnum.getList().contains(result)) {
+            return DataVoStatusEnum.SUCCESS.getCode();
+        }else  {
+            return DataVoStatusEnum.FAIL.getCode();
         }
-        return null;
     }
 }

+ 1 - 1
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/func/ValueObjectFunctionManager.java

@@ -47,7 +47,7 @@ public class ValueObjectFunctionManager {
     private static void regist(){
         log.info("开始注册值对象函数!");
         FUNCTIONS.put("md5", EncryptionFunction::md5);
-        FUNCTIONS.put("md5Sign", EncryptionFunction::md5Sign);
+        FUNCTIONS.put("resultCodeConvertStatus", EncryptionFunction::resultCodeConvertStatus);
         log.info("md5函数已注册!");
     }
 

+ 2 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/ApiGateWayImpl/ApiGatewayImpl.java

@@ -1,5 +1,6 @@
 package com.hrsk.cloud.eg.infrastructure.ApiGateWayImpl;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.hrsk.cloud.eg.domain.api.ApiGateway;
 import com.hrsk.cloud.eg.dto.data.CheckIntoParamDto;
 import com.hrsk.cloud.eg.infrastructure.business.HttpRequestCheckIntoService;
@@ -28,6 +29,7 @@ public class ApiGatewayImpl implements ApiGateway {
     @Override
     public DefaultResponseVo<DataVo> checkIntoRequest(CheckIntoParamDto param) {
         DataVo data = checkIntoService.checkInto(param);
+        log.info(JSONObject.toJSONString(data));
         return DefaultResponseVo.success(data);
 
     }

+ 6 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/business/GenerateCheckIntoHttpApiConfigService.java

@@ -171,6 +171,11 @@ public class GenerateCheckIntoHttpApiConfigService {
         KeyValueObject status=new KeyValueObject();
         status.setType("spel");
         status.setValue("#root[code]");
+        List<FunctionObject> functionObjects = Lists.newArrayList();
+        FunctionObject functionObject = new FunctionObject();
+        functionObject.setCode("resultCodeConvertStatus");
+        functionObjects.add(functionObject);
+        status.setFunctions(functionObjects);
         resultObj.put("status","#"+JSONObject.toJSONString(status));
         httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
         String jsonString = JSONObject.toJSONString(httpApiConfig);
@@ -366,4 +371,5 @@ public class GenerateCheckIntoHttpApiConfigService {
          return httpApiConfig;
     }
 
+
 }

+ 29 - 0
start/src/test/java/StartTest.java

@@ -68,6 +68,14 @@ public class StartTest {
     }
 
 
+    @Test
+    public void createXinLuApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointCodeForList("7");
+        generateCHeckIntoHttpApiConfigService.generateXinLuConfig(productBusinessApiInfoDos.get(1).getThreeSystemConfig());
+    }
+
+
+
     @Test
     public void apiHuiRonTest(){
       Long apiId= 441293753667392L;
@@ -120,6 +128,27 @@ public class StartTest {
         apiGateway.checkIntoRequest(checkin);
     }
 
+    /**
+     * @description:  鑫鹿 APi test
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:15
+     */
+    @Test
+    public void xinLuApiRsaTest(){
+        Long apiId= 441336439865408L;
+        UserInBaseInfoDto user =new UserInBaseInfoDto();
+        user.setPhoneMd5("b5500dfab55f42b340d31326561e16cb");
+        user.setCompanyCity("重庆");
+        PlanDto  plan =new PlanDto();
+        plan.setApiId(apiId);
+        plan.setBid("aff1c7b30d8b240826030235business");
+        CheckIntoParamDto checkin =new CheckIntoParamDto();
+        checkin.setPlan(plan);
+        checkin.setUser(user);
+        apiGateway.checkIntoRequest(checkin);
+    }
 
     @Test
     public void spel(){