소스 검색

add 增加数据

GITZYY 7 달 전
부모
커밋
00cf34ab20

+ 1 - 1
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/api/ApiCheckIntoServiceImpl.java

@@ -1,8 +1,8 @@
 package com.hrsk.cloud.eg.app.api;
 import com.hrsk.cloud.eg.domain.api.ApiGateway;
-import com.hrsk.cloud.eg.domain.common.response.DefaultResponseVo;
 import com.hrsk.cloud.eg.dto.data.CheckIntoParamDto;
 import com.hrsk.cloud.eg.vo.response.DataVo;
+import com.hrsk.cloud.eg.vo.response.DefaultResponseVo;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

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

@@ -1,8 +1,8 @@
 package com.hrsk.cloud.eg.domain.api;
 
-import com.hrsk.cloud.eg.domain.common.response.DefaultResponseVo;
 import com.hrsk.cloud.eg.dto.data.CheckIntoParamDto;
 import com.hrsk.cloud.eg.vo.response.DataVo;
+import com.hrsk.cloud.eg.vo.response.DefaultResponseVo;
 
 /**
  * @author: bianlanzhou

+ 0 - 83
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/response/DefaultResponseVo.java

@@ -1,83 +0,0 @@
-package com.hrsk.cloud.eg.domain.common.response;
-
-import com.hrsk.cloud.eg.domain.common.constant.ResultCode;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.Serializable;
-
-/**
- * Author: zhangyy
- * Date: 2019/4/2
- * Description: No Description
- */
-public class DefaultResponseVo<T> implements Serializable {
-    private T data;
-
-    public T getData() {
-        return data;
-    }
-
-    public Integer code;
-
-    public String msg;
-
-    public String getMsg(){
-        return msg ;
-    }
-
-    public void setMsg(String msg){
-        this.msg = msg;
-    }
-
-    public Integer getCode(){
-       return code ;
-    }
-
-    public void setCode(Integer code){
-        this.code = code;
-    }
-
-    public void setData(T data) {
-        this.data = data;
-    }
-
-    public static DefaultResponseVo success(){
-        return createDefaultResponseVo(ResultCode.GLOBAL_REQUEST_OK.getCode(),"成功",null);
-    }
-    public static DefaultResponseVo success(String message){
-        return createDefaultResponseVo(ResultCode.GLOBAL_REQUEST_OK.getCode(),message,null);
-    }
-    public static <T> DefaultResponseVo<T> success(T data){
-        return createDefaultResponseVo(ResultCode.GLOBAL_REQUEST_OK.getCode(),"成功",data);
-    }
-    public static <T> DefaultResponseVo<T> success(String message, T object){
-        return createDefaultResponseVo(ResultCode.GLOBAL_REQUEST_OK.getCode(),message,object);
-    }
-
-    public static <T> DefaultResponseVo<T> fail(String message, T data){
-        return createDefaultResponseVo(ResultCode.GLOBAL_REQUEST_FAIL.getCode(),message,data);
-    }
-
-    public static DefaultResponseVo fail(String message){
-        return createDefaultResponseVo(ResultCode.GLOBAL_REQUEST_FAIL.getCode(),message,null);
-    }
-
-    public static DefaultResponseVo fail(int code,String message){
-        return createDefaultResponseVo(code,message,null);
-    }
-
-    public static DefaultResponseVo other(int code,String message){
-        return createDefaultResponseVo(code,message,null);
-    }
-
-    public static <T> DefaultResponseVo<T> createDefaultResponseVo(Integer code, String message, T data){
-        DefaultResponseVo<T> responseVo = new DefaultResponseVo<T>();
-        if(code!=null)
-            responseVo.setCode(code);
-        if(StringUtils.isNotBlank(message))
-            responseVo.setMsg(message);
-        if(data!=null)
-            responseVo.setData(data);
-        return responseVo;
-    }
-}

+ 1 - 3
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/ApiGateWayImpl/ApiGatewayImpl.java

@@ -1,12 +1,10 @@
 package com.hrsk.cloud.eg.infrastructure.ApiGateWayImpl;
 
-import com.alibaba.fastjson2.JSONObject;
 import com.hrsk.cloud.eg.domain.api.ApiGateway;
-import com.hrsk.cloud.eg.domain.common.response.DefaultResponseVo;
 import com.hrsk.cloud.eg.dto.data.CheckIntoParamDto;
 import com.hrsk.cloud.eg.infrastructure.business.HttpRequestCheckIntoService;
-import com.hrsk.cloud.eg.infrastructure.config.client.HttpTemPlateClient;
 import com.hrsk.cloud.eg.vo.response.DataVo;
+import com.hrsk.cloud.eg.vo.response.DefaultResponseVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 

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

@@ -76,6 +76,136 @@ public class GenerateCheckIntoHttpApiConfigService {
         egApiEndpointService.save(egApiEndpointDo);
     }
 
+    /**
+     * @description: 对接我们openapiAes文档转化
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/4 10:42
+     */
+    public void  generateOpenApiAesConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":OPEN_API_AES:13");
+        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(createOpenApiAesCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    /** 
+     * @description: 庆鱼api转化
+     * @param:
+     * @return:  
+     * @author zhangyy
+     * @date: 2024/9/4 14:58
+     */ 
+    public void  generateQinYuConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":CRM_QY:4");
+        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(createQinYuCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    /**
+     * @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");
+        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("data","#"+JSONObject.toJSONString(attackPhone));
+        body.put("sign","#"+JSONObject.toJSONString(merchantNo));
+        body.put("trafficPlatformId","#"+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("qin yu api  {}",jsonString);
+        return httpApiConfig;
+    }
+
+    /**
+     * @description: openapi Rsa 信息
+     * @author zhangyy
+     * @date 2024/9/4 10:56
+     * @version 1.0
+     */
+    private HttpApiConfig createOpenApiAesCheckIntoBean(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: openapi Rsa 信息
      * @author zhangyy

+ 0 - 1
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/exception/ExceptionAdvice.java

@@ -1,7 +1,6 @@
 package com.hrsk.cloud.eg.infrastructure.exception;
 
 import com.hrsk.cloud.eg.domain.common.constant.ResultCode;
-import com.hrsk.cloud.eg.domain.common.response.DefaultResponseVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.context.properties.bind.BindException;
 import org.springframework.http.HttpStatus;

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

@@ -105,6 +105,8 @@ public class StartTest {
         StandardEvaluationContext context = new StandardEvaluationContext(map);
         // 这里很关键,如果没有配置MapAccessor,那么只能用['c']['a']这种解析方式
         System.out.println(parser.parseExpression(spel).getValue(context));
+
+
     }