|
@@ -3,14 +3,10 @@ package com.hrsk.cloud.eg.infrastructure.business;
|
|
|
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.FunctionObject;
|
|
|
import com.hrsk.cloud.eg.domain.api.HttpApiConfig;
|
|
|
import com.hrsk.cloud.eg.domain.api.KeyValueObject;
|
|
|
-import com.hrsk.cloud.eg.domain.api.ValueObject;
|
|
|
import com.hrsk.cloud.eg.domain.api.common.ApiPayloadTypeEnum;
|
|
|
import com.hrsk.cloud.eg.domain.api.common.ValueObjectTypeEnum;
|
|
|
-import com.hrsk.cloud.eg.domain.common.utils.GsonUtils;
|
|
|
-import com.hrsk.cloud.eg.domain.common.utils.SnowflakeIdWorker;
|
|
|
import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
|
|
|
import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiDo;
|
|
|
import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiEndpointDo;
|
|
@@ -30,7 +26,7 @@ import java.util.List;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class GenerateHttpApiConfigService {
|
|
|
+public class GenerateCheckIntoHttpApiConfigService {
|
|
|
|
|
|
@Resource
|
|
|
private EgApiService egApiService;
|
|
@@ -50,13 +46,77 @@ public class GenerateHttpApiConfigService {
|
|
|
egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":HUIRONG_CRM:9");
|
|
|
egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
|
|
|
egApiService.save(egApiDo);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(huiRonApiConfig);
|
|
|
EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
|
|
|
egApiEndpointDo.setApiCode(egApiDo.getApiCode());
|
|
|
egApiEndpointDo.setApiId(egApiDo.getId());
|
|
|
- egApiEndpointDo.setApiConfig(HessianUtils.serialize(createCheckIntoBean(huiRonApiConfig)));
|
|
|
+ egApiEndpointDo.setApiName(jsonObject.getString("name"));
|
|
|
+ egApiEndpointDo.setApiConfig(HessianUtils.serialize(createHuiRonCheckIntoBean(huiRonApiConfig)));
|
|
|
egApiEndpointService.save(egApiEndpointDo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description: 对接我们openapiRsa文档转化
|
|
|
+ * @param:
|
|
|
+ * @return:
|
|
|
+ * @author zhangyy
|
|
|
+ * @date: 2024/9/4 10:42
|
|
|
+ */
|
|
|
+ public void generateOpenApiRSAConfig(String openApiConfig) {
|
|
|
+ EgApiDo egApiDo=new EgApiDo();
|
|
|
+ egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":OPEN_API:1");
|
|
|
+ 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(createOpenApiRsaCheckIntoBean(openApiConfig)));
|
|
|
+ egApiEndpointService.save(egApiEndpointDo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: openapi Rsa 信息
|
|
|
+ * @author zhangyy
|
|
|
+ * @date 2024/9/4 10:56
|
|
|
+ * @version 1.0
|
|
|
+ */
|
|
|
+ private HttpApiConfig createOpenApiRsaCheckIntoBean(String param) {
|
|
|
+ JSONObject jsonObject=JSONObject.parseObject(param);
|
|
|
+ HttpApiConfig httpApiConfig = new HttpApiConfig();
|
|
|
+ httpApiConfig.setUrl(jsonObject.getString("openapiCheckUrl"));
|
|
|
+ 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");
|
|
|
+ KeyValueObject merchantNo=new KeyValueObject();
|
|
|
+ merchantNo.setType("spel");
|
|
|
+ merchantNo.setValue("#param.user.companyCity");
|
|
|
+ body.put("phoneMd5","#"+JSONObject.toJSONString(attackPhone));
|
|
|
+ body.put("city","#"+JSONObject.toJSONString(merchantNo));
|
|
|
+ //主体
|
|
|
+ httpApiConfig.setContent(JSONObject.toJSONString(body));
|
|
|
+ JSONObject resultObj=new JSONObject();
|
|
|
+ KeyValueObject status=new KeyValueObject();
|
|
|
+ status.setType("spel");
|
|
|
+ status.setValue("#root[data][status]");
|
|
|
+ resultObj.put("status","#"+JSONObject.toJSONString(status));
|
|
|
+ httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
|
|
|
+ String jsonString = JSONObject.toJSONString(httpApiConfig);
|
|
|
+ log.info("open api rsa{}",jsonString);
|
|
|
+ return httpApiConfig;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @description: 创建撞库httpApi信息
|
|
|
* @param:
|
|
@@ -64,7 +124,7 @@ public class GenerateHttpApiConfigService {
|
|
|
* @author zhangyy
|
|
|
* @date: 2024/8/30 09:31
|
|
|
*/
|
|
|
- public HttpApiConfig createCheckIntoBean(String param){
|
|
|
+ public HttpApiConfig createHuiRonCheckIntoBean(String param){
|
|
|
JSONObject jsonObject=JSONObject.parseObject(param);
|
|
|
HttpApiConfig httpApiConfig = new HttpApiConfig();
|
|
|
httpApiConfig.setUrl(jsonObject.getString("checkUrl"));
|
|
@@ -95,7 +155,7 @@ public class GenerateHttpApiConfigService {
|
|
|
resultObj.put("status","#"+JSONObject.toJSONString(status));
|
|
|
httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
|
|
|
String jsonString = JSONObject.toJSONString(httpApiConfig);
|
|
|
- log.info("json input data {}",jsonString);
|
|
|
+ log.info("huiRon api {}",jsonString);
|
|
|
return httpApiConfig;
|
|
|
}
|
|
|
|