瀏覽代碼

update 三元表达是结构

GITZYY 7 月之前
父節點
當前提交
122595207f

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

@@ -15,7 +15,8 @@ import java.util.List;
 @Getter
 public enum ThreeplatfromResultCodeEnum {
     ONE(200,""),
-    TWO(400,"")
+    TWO(400,""),
+    THREE(1,""),
 ;
     private Integer code;
     private String msg;

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

@@ -6,6 +6,7 @@ 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 com.hrsk.cloud.eg.domain.api.common.ThreeplatfromResultStringEnum;
 import lombok.extern.slf4j.Slf4j;
 
 import java.security.MessageDigest;
@@ -82,7 +83,7 @@ public class EncryptionFunction {
     public static Integer resultCodeConvertStatusString(FunctionParam functionParam) {
         String value = functionParam.getInput().toString();
         Integer result = Integer.valueOf(value);
-        if (ThreeplatfromResultCodeEnum.getList().contains(result)) {
+        if (ThreeplatfromResultStringEnum.getList().contains(result)) {
             return DataVoStatusEnum.SUCCESS.getCode();
         }else  {
             return DataVoStatusEnum.FAIL.getCode();

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

@@ -689,12 +689,12 @@ public class GenerateCheckIntoHttpApiConfigService {
         JSONObject resultObj=new  JSONObject();
         KeyValueObject status=new KeyValueObject();
         status.setType("spel");
-        status.setValue("#root[code]");
-        List<FunctionObject> functionObjects = Lists.newArrayList();
-        FunctionObject functionObject = new FunctionObject();
-        functionObject.setCode("resultCodeConvertStatusInteger");
-        functionObjects.add(functionObject);
-        status.setFunctions(functionObjects);
+        status.setValue("#root[code]=='0000'?0:1");
+//        List<FunctionObject> functionObjects = Lists.newArrayList();
+//        FunctionObject functionObject = new FunctionObject();
+//        functionObject.setCode("resultCodeConvertStatusInteger");
+//        functionObjects.add(functionObject);
+//        status.setFunctions(functionObjects);
         resultObj.put("status","#"+JSONObject.toJSONString(status));
         httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
         String jsonString = JSONObject.toJSONString(httpApiConfig);
@@ -734,14 +734,20 @@ public class GenerateCheckIntoHttpApiConfigService {
         head.setType(ValueObjectTypeEnum.BASIC.getType());
         head.setKey("Content-Type");
         head.setValue("application/json");
+        KeyValueObject head1=new KeyValueObject();
+        head1.setKey("channel");
+        head1.setType(ValueObjectTypeEnum.BASIC.getType());
+        head1.setValue(jsonObject.getString("channel"));
         headers.add(head);
+        headers.add(head1);
+
         httpApiConfig.setHeader(headers);
         JSONObject body=new  JSONObject();
         KeyValueObject attackPhone=new KeyValueObject();
         attackPhone.setType("spel");
         attackPhone.setValue("#param.user.phoneMd5");
-        body.put("channelSource",jsonObject.getString("channelSource"));
-        body.put("phoneNo","#"+JSONObject.toJSONString(attackPhone));
+//        body.put("channelSource",jsonObject.getString("channelSource"));
+        body.put("phoneMd5","#"+JSONObject.toJSONString(attackPhone));
         //主体
         httpApiConfig.setContent(JSONObject.toJSONString(body));
 
@@ -826,4 +832,131 @@ public class GenerateCheckIntoHttpApiConfigService {
         log.info("huixin api  {}",jsonString);
         return httpApiConfig;
     }
+
+    /**
+     * @description:  惠众直贷api对接方式
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/9 10:07
+     */
+    public void generateHuiZhongZhiConfig(String openApiConfig){
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":Huizhong01");
+        egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
+        egApiService.save(egApiDo);
+        JSONObject jsonObject = JSONObject.parseObject(openApiConfig);
+        EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
+        egApiEndpointDo.setApiCode(egApiDo.getApiCode());
+        egApiEndpointDo.setApiId(egApiDo.getId());
+        egApiEndpointDo.setApiName(jsonObject.getString("name"));
+        egApiEndpointDo.setApiConfig(HessianUtils.serialize(createHuiZhongCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    /**
+     * @description: 惠众直贷api Config
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/9 10:08
+     */
+    private HttpApiConfig createHuiZhongZhiCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("url")+"/api/user/check");
+        httpApiConfig.setMethod("POST");
+        httpApiConfig.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
+        List<KeyValueObject> headers = Lists.newArrayList();
+        KeyValueObject head=new KeyValueObject();
+        head.setType(ValueObjectTypeEnum.BASIC.getType());
+        head.setKey("Content-Type");
+        head.setValue("application/json");
+        headers.add(head);
+        httpApiConfig.setHeader(headers);
+        JSONObject body=new  JSONObject();
+        KeyValueObject attackPhone=new KeyValueObject();
+        attackPhone.setType("spel");
+        attackPhone.setValue("#param.user.phoneMd5");
+        body.put("channelSource",jsonObject.getString("channelSource"));
+        body.put("phoneNo","#"+JSONObject.toJSONString(attackPhone));
+        //主体
+        httpApiConfig.setContent(JSONObject.toJSONString(body));
+
+        JSONObject resultObj=new  JSONObject();
+        KeyValueObject status=new KeyValueObject();
+        status.setType("spel");
+        status.setValue("#root[code]");
+        List<FunctionObject> functionObjects = Lists.newArrayList();
+        FunctionObject functionObject = new FunctionObject();
+        functionObject.setCode("resultCodeConvertStatusInteger");
+        functionObjects.add(functionObject);
+        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("huizhong api {}",jsonString);
+        return httpApiConfig;
+    }
+
+
+    /**
+     * @description:  愉快花api对接方式
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/9 10:07
+     */
+    public void generateYuKuaiHuaConfig(String openApiConfig){
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":YuKuaiHua");
+        egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
+        egApiService.save(egApiDo);
+        JSONObject jsonObject = JSONObject.parseObject(openApiConfig);
+        EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
+        egApiEndpointDo.setApiCode(egApiDo.getApiCode());
+        egApiEndpointDo.setApiId(egApiDo.getId());
+        egApiEndpointDo.setApiName(jsonObject.getString("name"));
+        egApiEndpointDo.setApiConfig(HessianUtils.serialize(createYuKuaiHuaCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createYuKuaiHuaCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("url")+"api/External/hit_library");
+        httpApiConfig.setMethod("POST");
+        httpApiConfig.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
+        List<KeyValueObject> headers = Lists.newArrayList();
+        KeyValueObject head=new KeyValueObject();
+        head.setType(ValueObjectTypeEnum.BASIC.getType());
+        head.setKey("Content-Type");
+        head.setValue("application/json");
+        headers.add(head);
+        httpApiConfig.setHeader(headers);
+        JSONObject body=new  JSONObject();
+        KeyValueObject attackPhone=new KeyValueObject();
+        attackPhone.setType("spel");
+        attackPhone.setValue("#param.user.phoneMd5");
+//        body.put("channelSource",jsonObject.getString("channelSource"));
+        body.put("userPhone","#"+JSONObject.toJSONString(attackPhone));
+        //主体
+        httpApiConfig.setContent(JSONObject.toJSONString(body));
+
+        JSONObject resultObj=new  JSONObject();
+        KeyValueObject status=new KeyValueObject();
+        status.setType("spel");
+        status.setValue("#root[code]==1?0:1");
+//        List<FunctionObject> functionObjects = Lists.newArrayList();
+//        FunctionObject functionObject = new FunctionObject();
+//        functionObject.setCode("resultCodeConvertStatusInteger");
+//        functionObjects.add(functionObject);
+//        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("YuKuaiHua api {}",jsonString);
+        return httpApiConfig;
+    }
+
 }

+ 23 - 2
start/src/test/java/StartTest.java

@@ -106,6 +106,12 @@ public class StartTest {
     }
 
 
+    @Test
+    public void createYuKuaiHuaApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointJonintTypeForList("YuKuaiHua");
+        generateCHeckIntoHttpApiConfigService.generateYuKuaiHuaConfig(productBusinessApiInfoDos.get(0).getThreeSystemConfig());
+    }
+
 
     @Test
     public void apiHuiRonTest(){
@@ -280,7 +286,7 @@ public class StartTest {
      */
     @Test
     public void huiZhongApiTest(){
-        Long apiId= 441338278858304L;
+        Long apiId= 441425580433728L;
         UserInBaseInfoDto user =new UserInBaseInfoDto();
         user.setPhoneMd5("b5500dfab55f42b340d31326561e16cb");
         user.setCompanyCity("重庆");
@@ -302,7 +308,7 @@ public class StartTest {
      */
     @Test
     public void yinHuaApiTest(){
-        Long apiId= 441422299497792L;
+        Long apiId= 441425513479232L;
         UserInBaseInfoDto user =new UserInBaseInfoDto();
         user.setPhoneMd5("b5500dfab55f42b340d31326561e16cb");
         user.setCompanyCity("重庆");
@@ -338,6 +344,21 @@ public class StartTest {
     }
 
 
+    @Test
+    public void yuKuaiHuaApiTest(){
+        Long apiId= 441424861741888L;
+        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(){
         Map<String,Object> map =new HashMap<>();