|
@@ -0,0 +1,130 @@
|
|
|
|
+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.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;
|
|
|
|
+import com.hrsk.cloud.eg.infrastructure.service.EgApiEndpointService;
|
|
|
|
+import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author zhangyy
|
|
|
|
+ * @version 1.0
|
|
|
|
+ * @description: GenerateHttpApiConfig 迁移api配置的处理类
|
|
|
|
+ * @date 2024/8/29 17:54
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+public class GenerateHttpApiConfigService {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private EgApiService egApiService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private EgApiEndpointService egApiEndpointService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description: 原始惠融对接api转化
|
|
|
|
+ * @param:
|
|
|
|
+ * @return:
|
|
|
|
+ * @author zhangyy
|
|
|
|
+ * @date: 2024/8/29 17:58
|
|
|
|
+ */
|
|
|
|
+ public void generateHuiRonHuiRonApiConfig(String huiRonApiConfig){
|
|
|
|
+ EgApiDo egApiDo=new EgApiDo();
|
|
|
|
+ egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":HUIRONG_CRM");
|
|
|
|
+ egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
|
|
|
|
+ egApiService.save(egApiDo);
|
|
|
|
+ EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
|
|
|
|
+ egApiEndpointDo.setApiCode(egApiDo.getApiCode());
|
|
|
|
+ egApiEndpointDo.setApiId(egApiDo.getId());
|
|
|
|
+ egApiEndpointDo.setApiConfig(HessianUtils.serialize(createCheckIntoBean(huiRonApiConfig)));
|
|
|
|
+ egApiEndpointService.save(egApiEndpointDo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description: 创建撞库httpApi信息
|
|
|
|
+ * @param:
|
|
|
|
+ * @return:
|
|
|
|
+ * @author zhangyy
|
|
|
|
+ * @date: 2024/8/30 09:31
|
|
|
|
+ */
|
|
|
|
+ public HttpApiConfig createCheckIntoBean(String param){
|
|
|
|
+ JSONObject jsonObject=JSONObject.parseObject(param);
|
|
|
|
+ HttpApiConfig httpApiConfig = new HttpApiConfig();
|
|
|
|
+ httpApiConfig.setUrl(jsonObject.getString("checkUrl"));
|
|
|
|
+ httpApiConfig.setMethod("post");
|
|
|
|
+ httpApiConfig.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
|
|
|
|
+ List<KeyValueObject> header = Lists.newArrayList();
|
|
|
|
+ httpApiConfig.setHeader(header);
|
|
|
|
+ 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.merchantNo");
|
|
|
|
+ body.put("attackPhone",JSONObject.toJSONString(attackPhone));
|
|
|
|
+ body.put("merchantNo",JSONObject.toJSONString(merchantNo));
|
|
|
|
+ //主体
|
|
|
|
+ httpApiConfig.setContent(JSONObject.toJSONString(body));
|
|
|
|
+ String jsonString = JSONObject.toJSONString(httpApiConfig);
|
|
|
|
+ log.info("json input data {}",jsonString);
|
|
|
|
+ return httpApiConfig;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+// FunctionObject md5 = new FunctionObject();
|
|
|
|
+// md5.setCode("md5");
|
|
|
|
+// HttpApiConfig hac = new HttpApiConfig()
|
|
|
|
+// .setUrl("https://baidu.com");
|
|
|
|
+// hac.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
|
|
|
|
+// hac.setType("http");
|
|
|
|
+// List<KeyValueObject> h = Lists.newArrayList();
|
|
|
|
+// KeyValueObject h1 = new KeyValueObject();
|
|
|
|
+// h1.setKey("secretKey");
|
|
|
|
+// h1.setType("text");
|
|
|
|
+// h1.setValue("Khw99%$l%-2gF7P4jXglp_-jQqQirtYnOY5D");
|
|
|
|
+// h.add(h1);
|
|
|
|
+// KeyValueObject h2 = new KeyValueObject();
|
|
|
|
+// h2.setKey("merchantNo");
|
|
|
|
+// h2.setType("spel");
|
|
|
|
+// h2.setValue("#param.realName");
|
|
|
|
+// h.add(h2);
|
|
|
|
+// List<ValueObject> p = Lists.newArrayList();
|
|
|
|
+// ValueObject p1 = new ValueObject();
|
|
|
|
+// p1.setType("text");
|
|
|
|
+// p1.setValue("123");
|
|
|
|
+// ValueObject p2 = new ValueObject();
|
|
|
|
+// p2.setType("text");
|
|
|
|
+// p2.setValue("456");
|
|
|
|
+// p2.getFunctions().add(md5);
|
|
|
|
+// p.add(p1);
|
|
|
|
+// p.add(p2);
|
|
|
|
+// List<KeyValueObject> s = Lists.newArrayList();
|
|
|
|
+// KeyValueObject s1 = new KeyValueObject();
|
|
|
|
+// s1.setKey("username");
|
|
|
|
+// s1.setType("spel");
|
|
|
|
+// s1.setValue("#param.username");
|
|
|
|
+// KeyValueObject s2 = new KeyValueObject();
|
|
|
|
+// s2.setKey("channel");
|
|
|
|
+// s2.setType("spel");
|
|
|
|
+// s2.setValue("#param.channel");
|
|
|
|
+// s.add(s2);
|
|
|
|
+// hac.setPath(p).setSearch(s).setHeader(h).setMethod("GET");
|
|
|
|
+// hac.setContent("{\"merchant\":\"xxxxxxfffff\",\"phone\":\"{\\\"value\\\":\\\"#param.userMobile\\\",\\\"type\\\": \\\"spel\\\",\\\"functions\\\":[ {\\\"code\\\": \\\"md5\\\"}]}\"}");
|
|
|
|
+}
|