打印日志

This commit is contained in:
Guoqs
2024-11-21 15:17:15 +08:00
parent 55f53ebb70
commit 2be6b4a4e1

View File

@@ -129,12 +129,10 @@ public class HttpRequestUtil {
if(StringUtils.isBlank(label)) { if(StringUtils.isBlank(label)) {
label = operatorId + "(" + url + ")"; label = operatorId + "(" + url + ")";
} }
log.info(label + "发送请求 data:{}", data);
//加密 //加密
byte[] encryptText = Cryptos.aesEncrypt(data.getBytes(), byte[] encryptText = Cryptos.aesEncrypt(data.getBytes(),
dataSecret.getBytes(), dataSecretIV.getBytes()); dataSecret.getBytes(), dataSecretIV.getBytes());
String encryptData = Encodes.encodeBase64(encryptText); String encryptData = Encodes.encodeBase64(encryptText);
log.info(label + "发送请求 加密数据:" + encryptData);
Map<String, String> params = Maps.newLinkedHashMap(); Map<String, String> params = Maps.newLinkedHashMap();
params.put("OperatorID", operatorId); params.put("OperatorID", operatorId);
@@ -151,17 +149,18 @@ public class HttpRequestUtil {
params.put("Sig", sign); params.put("Sig", sign);
String postData = JSON.toJSONString(params); String postData = JSON.toJSONString(params);
log.info(label + "发送请求 最终提交数据:{}, 加密数据:{}", params, postData); // log.info(label + "发送请求 最终提交数据:{}, 加密数据:{}", params, postData);
// System.out.println("最终提交数据:" + postData); log.info("[{}]发送请求, 原始data:{}, 请求param:{}", label, data, postData);
String hutoolRequest = HttpRequest.post(url).header("Authorization", "Bearer " + token).body(postData).execute().body(); String response = HttpRequest.post(url).header("Authorization", "Bearer " + token).body(postData).execute().body();
log.info(label + "发送请求 接收到返回数据:{}", hutoolRequest); // log.info(label + "发送请求 接收到返回数据:{}", response);
log.info("[{}]发送请求成功, params:{}, response:{}", label, postData, response);
if (StringUtils.isBlank(hutoolRequest)) { if (StringUtils.isBlank(response)) {
return "返回数据为空"; return "返回数据为空";
} }
Map<String, Object> map = (Map<String, Object>) JSON.parse(hutoolRequest); Map<String, Object> map = (Map<String, Object>) JSON.parse(response);
// log.info("联联平台发送请求 返回数据map:{}", JSON.toJSONString(map)); // log.info("联联平台发送请求 返回数据map:{}", JSON.toJSONString(map));
@@ -182,7 +181,7 @@ public class HttpRequestUtil {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
log.info(label + "发送请求 返回数据map:{}, 解密数据:{}", JSON.toJSONString(map), plainData); log.info("[{}]发送请求 返回数据map:{}, 解密数据:{}", label, JSON.toJSONString(map), plainData);
return resultMsg; return resultMsg;
} }