Ver Fonte

中煤财险API 报价修改

wks há 3 anos atrás
pai
commit
689bd1a171

+ 42 - 42
src/main/java/com/ydtech/modules/order/components/ZhongmeiRequestApiComponents.java

@@ -41,61 +41,61 @@ public class ZhongmeiRequestApiComponents {
         this.restTemplate = restTemplate;
     }
 
-    private <Q extends BaseRequest, S extends BaseResponse> S post(Q q, String url, Class<S> tClass) {
-        String jsonString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
-        log.info("---------> 请求参数:{}", jsonString);
-
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.setContentType(MediaType.APPLICATION_JSON);
-
-        // 加密
-        String s = AESUtilsWithDataBase.encryptECBPK5Hex(jsonString);
-        log.info("---------> 加密后的参数:{}", s);
-        HttpEntity<String> httpEntity = new HttpEntity<>(s, httpHeaders);
-
-        ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
-        String body = response.getBody();
-        log.info("---------> 解密前的参数:{}", body);
-        // 解密
-        String s1 = AESUtilsWithDataBase.decryptECBPK5Hex(body);
-        log.info("---------> 响应参数:{}", s1);
-
-        S t = JSON.parseObject(s1, tClass);
-        if (ObjectUtils.isEmpty(t)) {
-            throw new SystemException("请求失败");
-        }
-        return t;
-    }
-
-
-//    /**
-//     * @param q      请求参数
-//     * @param url    请求url
-//     * @param tClass 响应类型
-//     * @param <Q>    Request 请求体
-//     * @param <S>    Response 响应体
-//     * @return <S>
-//     */
 //    private <Q extends BaseRequest, S extends BaseResponse> S post(Q q, String url, Class<S> tClass) {
-//        String jsonString = JSON.toJSONString(q);
+//        String jsonString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
 //        log.info("---------> 请求参数:{}", jsonString);
 //
 //        HttpHeaders httpHeaders = new HttpHeaders();
 //        httpHeaders.setContentType(MediaType.APPLICATION_JSON);
 //
-//        HttpEntity<Q> yaQuoteInfoVoHttpEntity = new HttpEntity<>(q, httpHeaders);
-//        ResponseEntity<String> response = restTemplate.postForEntity(url, yaQuoteInfoVoHttpEntity, String.class);
+//        // 加密
+//        String s = AESUtilsWithDataBase.encryptECBPK5Hex(jsonString);
+//        log.info("---------> 加密后的参数:{}", s);
+//        HttpEntity<String> httpEntity = new HttpEntity<>(s, httpHeaders);
+//
+//        ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
 //        String body = response.getBody();
-//        log.info("---------> 响应参数:{}", body);
+//        log.info("---------> 解密前的参数:{}", body);
+//        // 解密
+//        String s1 = AESUtilsWithDataBase.decryptECBPK5Hex(body);
+//        log.info("---------> 响应参数:{}", s1);
 //
-//        S t = JSON.parseObject(body, tClass);
+//        S t = JSON.parseObject(s1, tClass);
 //        if (ObjectUtils.isEmpty(t)) {
 //            throw new SystemException("请求失败");
 //        }
-//
 //        return t;
 //    }
 
+
+    /**
+     * @param q      请求参数
+     * @param url    请求url
+     * @param tClass 响应类型
+     * @param <Q>    Request 请求体
+     * @param <S>    Response 响应体
+     * @return <S>
+     */
+    private <Q extends BaseRequest, S extends BaseResponse> S post(Q q, String url, Class<S> tClass) {
+        String jsonString = JSON.toJSONString(q);
+        log.info("---------> 请求参数:{}", jsonString);
+
+        HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.setContentType(MediaType.APPLICATION_JSON);
+
+        HttpEntity<Q> yaQuoteInfoVoHttpEntity = new HttpEntity<>(q, httpHeaders);
+        ResponseEntity<String> response = restTemplate.postForEntity(url, yaQuoteInfoVoHttpEntity, String.class);
+        String body = response.getBody();
+        log.info("---------> 响应参数:{}", body);
+
+        S t = JSON.parseObject(body, tClass);
+        if (ObjectUtils.isEmpty(t)) {
+            throw new SystemException("请求失败");
+        }
+
+        return t;
+    }
+
     /**
      * @param <Q>     Request 请求体
      * @param <S>     Response 响应体
@@ -170,7 +170,7 @@ public class ZhongmeiRequestApiComponents {
      * 上传影像 传入订单信息,查询是否生成保单成功
      */
     public void uploadImage(UploadImageRequest request, Class<UploadImageResponse> tClass) {
-        routineRequest(request, tClass, true);
+        imageRequest(request, tClass, true);
     }
 
     /**

+ 13 - 20
src/main/java/com/ydtech/modules/order/controller/ZhongMeiOrderApiController.java

@@ -1,7 +1,6 @@
 package com.ydtech.modules.order.controller;
 
 
-import com.alibaba.fastjson.JSON;
 import com.ydtech.aop.request.RequestSingleParam;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.ins.model.vo.QuoteRespVo;
@@ -15,7 +14,6 @@ import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
 import com.ydtech.modules.order.entity.vo.PolicyPrintVo;
 import com.ydtech.modules.order.service.ZhongMeiOrderApiService;
-import com.ydtech.modules.order.utils.AESUtilsWithDataBase;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -82,30 +80,25 @@ public class ZhongMeiOrderApiController {
 
     @PostMapping("/underwritingCallback")
     @ApiOperation(value = "承保回调")
-    public HttpResult<Object> underwritingCallback(@RequestBody String s) {
-        log.info("---------> 解密前的参数:{}", s);
-        // 解密
-        String s1 = AESUtilsWithDataBase.decryptECBPK5Hex(s);
-        log.info("---------> 承保回调:{}", s1);
-        CoverageRequest coverageRequest = JSON.parseObject(s1, CoverageRequest.class);
+    public HttpResult<Object> underwritingCallback(@RequestBody CoverageRequest coverageRequest) {
+//        log.info("---------> 解密前的参数:{}", s);
+//        // 解密
+//        String s1 = AESUtilsWithDataBase.decryptECBPK5Hex(s);
+//        log.info("---------> 承保回调:{}", s1);
+//        CoverageRequest coverageRequest = JSON.parseObject(s1, CoverageRequest.class);
         return this.zhongMeiOrderApiService.underwritingCallback(coverageRequest);
     }
 
     @PostMapping("/auditCallback")
     @ApiOperation(value = "审核回调")
-    public HttpResult<Object> auditCallback(@RequestBody String s) {
-        log.info("---------> 解密前的参数:{}", s);
-        // 解密
-        String s1 = AESUtilsWithDataBase.decryptECBPK5Hex(s);
-        log.info("---------> 审核回调:{}", s1);
-        ApprovedRequest approvedRequest = JSON.parseObject(s1, ApprovedRequest.class);
+    public HttpResult<Object> auditCallback(@RequestBody ApprovedRequest approvedRequest) {
+//    public HttpResult<Object> auditCallback(@RequestBody String s) {
+//        log.info("---------> 解密前的参数:{}", s);
+//        // 解密
+//        String s1 = AESUtilsWithDataBase.decryptECBPK5Hex(s);
+//        log.info("---------> 审核回调:{}", s1);
+//        ApprovedRequest approvedRequest = JSON.parseObject(s1, ApprovedRequest.class);
         return this.zhongMeiOrderApiService.auditCallback(approvedRequest);
     }
 
-    @PostMapping("/test")
-    public HttpResult<Object> test(@RequestBody String s) {
-        return HttpResult.ok(s);
-    }
-
-
 }