浏览代码

add rxk api 初始化对接http参数

GITZYY 7 月之前
父节点
当前提交
124f04a3a3

+ 27 - 0
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 lombok.extern.slf4j.Slf4j;
 
 import java.security.MessageDigest;
 import java.util.List;
@@ -16,6 +17,7 @@ import java.util.Objects;
  * @create: 2024-07-31 15:58
  * @description: 加解密函数
  **/
+@Slf4j
 public class EncryptionFunction {
     /**
      * MD5函数
@@ -69,4 +71,29 @@ public class EncryptionFunction {
             return DataVoStatusEnum.FAIL.getCode();
         }
     }
+
+    /**
+     * @description:  组合第三方返回值进行配置返回
+     * @param:
+     * @return: Integer
+     * @author zhangyy
+     * @date: 2024/9/5 14:00
+     */
+    public static Integer combinationCodeSuccessIsExit(FunctionParam functionParam) {
+       try {
+           List<Object> extArg = functionParam.getExtArg();
+           Integer o = (Integer) extArg.get(0);
+           Boolean o1 = (Boolean) extArg.get(1);
+           Boolean o2 = (Boolean) extArg.get(2);
+          if (o.equals(DataVoStatusEnum.SUCCESS.getCode())
+           && o1&&o2) {
+              return DataVoStatusEnum.SUCCESS.getCode();
+          }
+
+       }catch (Exception e){
+           log.error("组合方式参数校验出现错误{}",e.getMessage(),e);
+           return DataVoStatusEnum.FAIL.getCode();
+       }
+          return DataVoStatusEnum.FAIL.getCode();
+    }
 }

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

@@ -48,6 +48,7 @@ public class ValueObjectFunctionManager {
         log.info("开始注册值对象函数!");
         FUNCTIONS.put("md5", EncryptionFunction::md5);
         FUNCTIONS.put("resultCodeConvertStatus", EncryptionFunction::resultCodeConvertStatus);
+        FUNCTIONS.put("combinationCodeSuccessIsExit",EncryptionFunction::combinationCodeSuccessIsExit);
         log.info("md5函数已注册!");
     }
 

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

@@ -139,6 +139,271 @@ public class GenerateCheckIntoHttpApiConfigService {
         egApiEndpointService.save(egApiEndpointDo);
     }
 
+    /**
+     * @description: 享可达 api配置对接方式
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:31
+     */
+    public void generateXkdConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":CRM_XKD:10");
+        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(createXkdApiCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    /**
+     * @description:锦碟 api配置对接方式
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:31
+     */
+    public void generateJinDieConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":CRM_JD:5");
+        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(createJinDieCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createJinDieCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("CheckUrl"));
+        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("Appid",jsonObject.getString("Appid"));
+        body.put("Appkey",jsonObject.getString("AppKey"));
+        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]");
+        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);
+        log.info("xkd api  {}",jsonString);
+        return httpApiConfig;
+    }
+
+    /**
+     * @description:锦碟 api配置对接方式
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:31
+     */
+    public void generateJinDieV3Config(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":CRM_JDV3:12");
+        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(createJinDieCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createJinDieV3CheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("CheckUrl"));
+        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("Appid",jsonObject.getString("Appid"));
+        body.put("Appkey",jsonObject.getString("AppKey"));
+        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]");
+        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);
+        log.info("xkd api  {}",jsonString);
+        return httpApiConfig;
+    }
+
+
+    /**
+     * @description:融享客 api配置对接方式
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:31
+     */
+    public void generateRxkConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":CRM_RXK:6");
+        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(createRxkCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createRxkCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        if(null !=jsonObject.getString("private") && jsonObject.getBoolean("private")){
+            httpApiConfig.setUrl(jsonObject.getString("domain")+"/youka/api/user_filter/md5");
+        }else {
+            httpApiConfig.setUrl(jsonObject.getString("domain")+"/xxb-filter/api/filter/md5");
+        }
+        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("sourceCode",jsonObject.getString("sourceCode"));
+        body.put("accessKey",jsonObject.getString("accessKey"));
+        body.put("phoneMd5","#"+JSONObject.toJSONString(attackPhone));
+        //主体
+        httpApiConfig.setContent(JSONObject.toJSONString(body));
+        JSONObject resultObj=new  JSONObject();
+        KeyValueObject status=new KeyValueObject();
+        status.setType("spel");
+        status.setValue("");
+        List<FunctionObject> functionObjects = Lists.newArrayList();
+        FunctionObject functionObject = new FunctionObject();
+        functionObject.setCode("combinationCodeSuccessIsExit");
+        List<ValueObject> valueObjectList= Lists.newArrayList();
+        ValueObject valueObject = new ValueObject();
+        valueObject.setType(ValueObjectTypeEnum.SPEL.getType());
+        valueObject.setValue("#root[code]");
+        valueObjectList.add(valueObject);
+        ValueObject valueObject1 = new ValueObject();
+        valueObject1.setType(ValueObjectTypeEnum.SPEL.getType());
+        valueObject1.setValue("#root[success]");
+        valueObjectList.add(valueObject1);
+
+        ValueObject valueObject2 = new ValueObject();
+        valueObject2.setType(ValueObjectTypeEnum.SPEL.getType());
+        valueObject2.setValue("#root[data][phoneMd5Exist]");
+        valueObjectList.add(valueObject2);
+
+        functionObject.setArgs(valueObjectList);
+        functionObjects.add(functionObject);
+        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("rxk api  {}",jsonString);
+        return httpApiConfig;
+    }
+
+    /**
+     * @description:  享可达 api转化
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:32
+     */
+    private HttpApiConfig createXkdApiCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("checkUrl"));
+        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("phone","#"+JSONObject.toJSONString(attackPhone));
+        body.put("type",2);
+        body.put("tenantId",jsonObject.getString("tenantId"));
+        //主体
+        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("resultCodeConvertStatus");
+        functionObjects.add(functionObject);
+        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("xkd api  {}",jsonString);
+        return httpApiConfig;
+    }
+
+
     /**
      * @description: 鑫鹿api转化
      * @author zhangyy

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

@@ -74,7 +74,18 @@ public class StartTest {
         generateCHeckIntoHttpApiConfigService.generateXinLuConfig(productBusinessApiInfoDos.get(1).getThreeSystemConfig());
     }
 
+    @Test
+    public void createXkdApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointCodeForList("10");
+        generateCHeckIntoHttpApiConfigService.generateXinLuConfig(productBusinessApiInfoDos.get(1).getThreeSystemConfig());
+    }
+
 
+    @Test
+    public void createRxkApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointCodeForList("6");
+        generateCHeckIntoHttpApiConfigService.generateRxkConfig(productBusinessApiInfoDos.get(0).getThreeSystemConfig());
+    }
 
     @Test
     public void apiHuiRonTest(){
@@ -150,6 +161,72 @@ public class StartTest {
         apiGateway.checkIntoRequest(checkin);
     }
 
+    /**
+     * @description:  享可达 api 测试
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:34
+     */
+    @Test
+    public void xkdApiRsaTest(){
+        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);
+    }
+
+    /**
+     * @description:  锦碟V2 api 测试
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:34
+     */
+    @Test
+    public void jinDieApiRsaTest(){
+        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);
+    }
+
+
+    /**
+     * @description:  融享客 api 测试
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/5 14:34
+     */
+    @Test
+    public void rxkApiTest(){
+        Long apiId= 441338278858304L;
+        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<>();