Improve external API logging readability

This commit is contained in:
wkc
2026-05-06 10:18:28 +08:00
parent 709a314107
commit abc8b127e1
7 changed files with 68 additions and 9 deletions

View File

@@ -2,11 +2,13 @@ package com.ruoyi.loanpricing.service;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.loanpricing.domain.vo.CustomerMapRecordVO;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -17,6 +19,7 @@ import org.springframework.web.util.UriComponentsBuilder;
* 客户号与客户内码映射查询服务。
*/
@Service
@Slf4j
public class LoanPricingCustomerMapService
{
private final RestTemplate restTemplate;
@@ -67,6 +70,10 @@ public class LoanPricingCustomerMapService
.encode()
.toUri();
CustomerMapResponse response = restTemplate.getForObject(uri, CustomerMapResponse.class);
log.info("后端外部接口调用完成\n请求URL{}\n请求参数\n{}\n返回参数\n{}",
uri,
HttpUtils.formatLogValue(Collections.singletonMap("cust_id", normalizedCustId)),
HttpUtils.formatLogValue(response));
if (response == null)
{
throw new ServiceException("客户号映射接口无返回");

View File

@@ -2,11 +2,13 @@ package com.ruoyi.loanpricing.service;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.loanpricing.domain.vo.HistoryLoanContractVO;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -14,6 +16,7 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
@Service
@Slf4j
public class LoanRateHistoryService
{
private final RestTemplate restTemplate;
@@ -50,6 +53,10 @@ public class LoanRateHistoryService
.encode()
.toUri();
HistoryLoanContractResponse response = restTemplate.getForObject(uri, HistoryLoanContractResponse.class);
log.info("后端外部接口调用完成\n请求URL{}\n请求参数\n{}\n返回参数\n{}",
uri,
HttpUtils.formatLogValue(Collections.singletonMap("cust_isn", normalizedCustIsn)),
HttpUtils.formatLogValue(response));
if (response == null)
{
throw new ServiceException("历史贷款合同接口无返回");