|
|
@@ -42,37 +42,8 @@ public class ZhongmeiRequestApiComponents {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// /**
|
|
|
-// * 加密请求
|
|
|
-// * @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) {
|
|
|
-// HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
-// httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
-//
|
|
|
-// String jsonString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
-// log.info("---------> 请求参数:{}", jsonString);
|
|
|
-// // 加密
|
|
|
-// 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();
|
|
|
-// S t = AESUtilsWithDataBase.decryptMessage(body, tClass, "响应参数");
|
|
|
-// if (ObjectUtils.isEmpty(t)) {
|
|
|
-// throw new SystemException("请求失败");
|
|
|
-// }
|
|
|
-// return t;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
+ * 加密请求
|
|
|
* @param q 请求参数
|
|
|
* @param url 请求url
|
|
|
* @param tClass 响应类型
|
|
|
@@ -81,25 +52,55 @@ public class ZhongmeiRequestApiComponents {
|
|
|
* @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);
|
|
|
+ String jsonString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
+ log.info("---------> 请求参数:{}", jsonString);
|
|
|
+ // 加密
|
|
|
+ String sessionKey = properties.getSessionKey();
|
|
|
+ String s = AESUtilsWithDataBase.encryptECBPK5Hex(jsonString, sessionKey);
|
|
|
+ log.info("---------> 加密后的参数:{}", s);
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(s, httpHeaders);
|
|
|
|
|
|
- S t = JSON.parseObject(body, tClass);
|
|
|
+ ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
|
|
|
+ String body = response.getBody();
|
|
|
+ S t = AESUtilsWithDataBase.decryptMessage(body, tClass, "响应参数", sessionKey);
|
|
|
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 响应体
|