|
@@ -0,0 +1,103 @@
|
|
|
+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.HttpApiConfig;
|
|
|
+import com.hrsk.cloud.eg.domain.api.KeyValueObject;
|
|
|
+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;
|
|
|
+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: GenerateCheckIntoHttpApiConfigV2Service
|
|
|
+ * @date 2024/9/9 16:35
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class GenerateCheckIntoHttpApiConfigV2Service {
|
|
|
+ @Resource
|
|
|
+ private EgApiService egApiService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private EgApiEndpointService egApiEndpointService;
|
|
|
+ /**
|
|
|
+ * @description: 灏瀚无崟
|
|
|
+ * @author zhangyy
|
|
|
+ * @date 2024/9/9 16:22
|
|
|
+ * @version 1.0
|
|
|
+ */
|
|
|
+ public void generateGexinjinfuConfig(String openApiConfig) {
|
|
|
+ EgApiDo egApiDo=new EgApiDo();
|
|
|
+ egApiDo.setApiCode("EG:"+ BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":Gexinjinfu");
|
|
|
+ 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(createGexinjinfuCheckIntoBean(openApiConfig)));
|
|
|
+ egApiEndpointService.save(egApiEndpointDo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private HttpApiConfig createGexinjinfuCheckIntoBean(String openApiConfig) {
|
|
|
+ JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
|
|
|
+ HttpApiConfig httpApiConfig = new HttpApiConfig();
|
|
|
+ httpApiConfig.setUrl(jsonObject.getString("url")+"/api/rsatg/checkmobile");
|
|
|
+ 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/x-www-form-urlencoded; charset=UTF-8");
|
|
|
+ headers.add(head);
|
|
|
+ httpApiConfig.setHeader(headers);
|
|
|
+ List<KeyValueObject> search = Lists.newArrayList();
|
|
|
+ KeyValueObject searchKey=new KeyValueObject();
|
|
|
+ searchKey.setType(ValueObjectTypeEnum.SPEL.getType());
|
|
|
+ searchKey.setKey("mobnum_md5");
|
|
|
+ searchKey.setValue("#param.user.phoneMd5");
|
|
|
+ search.add(searchKey);
|
|
|
+ httpApiConfig.setSearch(search);
|
|
|
+// JSONObject body=new JSONObject();
|
|
|
+// body.put("channelSource",jsonObject.getString("channelSource"));
|
|
|
+// body.put("channelCode",jsonObject.getString("channelCode"));
|
|
|
+// KeyValueObject attackPhone=new KeyValueObject();
|
|
|
+// attackPhone.setType("spel");
|
|
|
+// attackPhone.setValue("#param.user.phoneMd5");
|
|
|
+// body.put("md5_phone","#"+JSONObject.toJSONString(attackPhone));
|
|
|
+// body.put("channel_code",jsonObject.getString("channelCode"));
|
|
|
+// body.put("channel_secret_key",jsonObject.getString("channelSecretKey"));
|
|
|
+// //主体
|
|
|
+// httpApiConfig.setContent(JSONObject.toJSONString(body));
|
|
|
+ httpApiConfig.setContent("");
|
|
|
+ JSONObject resultObj=new JSONObject();
|
|
|
+ KeyValueObject status=new KeyValueObject();
|
|
|
+ status.setType("spel");
|
|
|
+ status.setValue("#root[status]==200?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("Gexinjinfu api {}",jsonString);
|
|
|
+ return httpApiConfig;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|