|
@@ -1,10 +1,10 @@
|
|
|
package com.hrsk.cloud.eg.infrastructure.business;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.hrsk.cloud.eg.constant.BusinessPrefixEnum;
|
|
|
-import com.hrsk.cloud.eg.domain.api.HttpApiConfig;
|
|
|
-import com.hrsk.cloud.eg.domain.api.KeyValueObject;
|
|
|
+import com.hrsk.cloud.eg.domain.api.*;
|
|
|
import com.hrsk.cloud.eg.domain.api.common.ApiPayloadTypeEnum;
|
|
|
import com.hrsk.cloud.eg.domain.api.common.ValueObjectTypeEnum;
|
|
|
import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
|
|
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -98,7 +99,7 @@ public class GenerateCheckIntoHttpApiConfigService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 庆鱼api转化
|
|
|
+ * @description: 庆鱼api转化 !!!暂时不支持
|
|
|
* @param:
|
|
|
* @return:
|
|
|
* @author zhangyy
|
|
@@ -119,15 +120,72 @@ public class GenerateCheckIntoHttpApiConfigService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 庆鱼创建api
|
|
|
+ * @description: 鑫鹿api对接方式
|
|
|
+ * @author zhangyy
|
|
|
+ * @date 2024/9/5 11:06
|
|
|
+ * @version 1.0
|
|
|
+ */
|
|
|
+ public void generateXinLuConfig(String openApiConfig) {
|
|
|
+ EgApiDo egApiDo=new EgApiDo();
|
|
|
+ egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":CRM_XL:7");
|
|
|
+ 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(createXinLuApiCheckIntoBean(openApiConfig)));
|
|
|
+ egApiEndpointService.save(egApiEndpointDo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 鑫鹿api转化
|
|
|
+ * @author zhangyy
|
|
|
+ * @date 2024/9/5 11:07
|
|
|
+ * @version 1.0
|
|
|
+ */
|
|
|
+ private HttpApiConfig createXinLuApiCheckIntoBean(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]");
|
|
|
+ resultObj.put("status","#"+JSONObject.toJSONString(status));
|
|
|
+ httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
|
|
|
+ String jsonString = JSONObject.toJSONString(httpApiConfig);
|
|
|
+ log.info("xinLu api {}",jsonString);
|
|
|
+ return httpApiConfig;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 庆鱼创建api !!! 暂时不支持
|
|
|
* @param:
|
|
|
* @return:
|
|
|
* @author zhangyy
|
|
|
* @date: 2024/9/4 14:58
|
|
|
*/
|
|
|
private HttpApiConfig createQinYuCheckIntoBean(String openApiConfig) {
|
|
|
- // todo
|
|
|
-// {"url":"https://king.cdsxlc.cn/saasbg","key":"fluxZhudai*_key","tenantId":"1637995763721633794","trafficPlatformId":"1636573781981466625"}
|
|
|
JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
|
|
|
HttpApiConfig httpApiConfig = new HttpApiConfig();
|
|
|
httpApiConfig.setUrl(jsonObject.getString("url")+"/openapi/interface/query/phones");
|
|
@@ -142,17 +200,36 @@ public class GenerateCheckIntoHttpApiConfigService {
|
|
|
httpApiConfig.setHeader(headers);
|
|
|
JSONObject body=new JSONObject();
|
|
|
|
|
|
- KeyValueObject attackPhone=new KeyValueObject();
|
|
|
- attackPhone.setType("spel");
|
|
|
- attackPhone.setValue("#param.user.phoneMd5");
|
|
|
- KeyValueObject merchantNo=new KeyValueObject();
|
|
|
-
|
|
|
- merchantNo.setType("spel");
|
|
|
- merchantNo.setValue("#param.user.companyCity");
|
|
|
-
|
|
|
- body.put("data","#"+JSONObject.toJSONString(attackPhone));
|
|
|
- body.put("sign","#"+JSONObject.toJSONString(merchantNo));
|
|
|
- body.put("trafficPlatformId","#"+JSONObject.toJSONString(merchantNo));
|
|
|
+ KeyValueObject data=new KeyValueObject();
|
|
|
+ data.setType("spel");
|
|
|
+ JSONObject dataJson=new JSONObject();
|
|
|
+ List<JSONObject> attackPhone=new ArrayList<>();
|
|
|
+ JSONObject phoneJson=new JSONObject();
|
|
|
+ phoneJson.put("phone","#param.user.phoneMd5");
|
|
|
+ attackPhone.add(phoneJson);
|
|
|
+ dataJson.put("customers",attackPhone);
|
|
|
+ dataJson.put("tenantId",jsonObject.getString("tenantId"));
|
|
|
+ data.setValue("#"+JSONObject.toJSONString(dataJson));
|
|
|
+ FunctionObject functionObject=new FunctionObject();
|
|
|
+ functionObject.setCode("outPrint");
|
|
|
+ data.setFunctions(Lists.newArrayList(functionObject));
|
|
|
+// log.info("qin yu input {}", JSONObject.toJSONString(data));
|
|
|
+ body.put("trafficPlatformId",jsonObject.getString("trafficPlatformId"));
|
|
|
+ body.put("data","#"+JSONObject.toJSONString(data));
|
|
|
+ List<ValueObject> args=Lists.newArrayList();
|
|
|
+ ValueObject valueObject=new ValueObject();
|
|
|
+ valueObject.setValue("#param.content.data");
|
|
|
+ args.add(valueObject);
|
|
|
+ ValueObject valueObject1=new ValueObject();
|
|
|
+ valueObject1.setValue("#param.content.trafficPlatformId");
|
|
|
+ args.add(valueObject1);
|
|
|
+ ValueObject valueObject2=new ValueObject();
|
|
|
+ valueObject1.setValue(jsonObject.getString("key"));
|
|
|
+ args.add(valueObject2);
|
|
|
+ FunctionObject functionObject1=new FunctionObject();
|
|
|
+ functionObject1.setCode("md5Sign");
|
|
|
+ functionObject1.setArgs(args);
|
|
|
+ body.put("sign","#"+JSONObject.toJSONString(functionObject1));
|
|
|
//主体
|
|
|
httpApiConfig.setContent(JSONObject.toJSONString(body));
|
|
|
JSONObject resultObj=new JSONObject();
|