fix: 收票指定应付调试数据
This commit is contained in:
@@ -32,8 +32,10 @@ import feign.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -70,7 +72,32 @@ public class CustomFeignLogger extends Logger {
|
||||
bodyStr = new String(body, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
log.info("===> [{}] {} {} | Headers: {} | Body: {}", configKey, method, url, headers, flattenBody(bodyStr));
|
||||
String queryParams = extractQueryParams(url);
|
||||
if ("GET".equalsIgnoreCase(method) && !queryParams.isEmpty()) {
|
||||
log.info("===> [{}] {} {} | Headers: {} | Params: {} | Body: {}", configKey, method, url, headers, queryParams, flattenBody(bodyStr));
|
||||
} else {
|
||||
log.info("===> [{}] {} {} | Headers: {} | Body: {}", configKey, method, url, headers, flattenBody(bodyStr));
|
||||
}
|
||||
}
|
||||
|
||||
private String extractQueryParams(String url) {
|
||||
int queryStart = url.indexOf('?');
|
||||
if (queryStart < 0 || queryStart >= url.length() - 1) {
|
||||
return "";
|
||||
}
|
||||
String queryString = url.substring(queryStart + 1);
|
||||
Map<String, String> params = new LinkedHashMap<>();
|
||||
for (String pair : queryString.split("&")) {
|
||||
int eqPos = pair.indexOf('=');
|
||||
if (eqPos > 0) {
|
||||
String key = URLDecoder.decode(pair.substring(0, eqPos), StandardCharsets.UTF_8);
|
||||
String value = URLDecoder.decode(pair.substring(eqPos + 1), StandardCharsets.UTF_8);
|
||||
params.put(key, value);
|
||||
} else if (!pair.isEmpty()) {
|
||||
params.put(URLDecoder.decode(pair, StandardCharsets.UTF_8), "");
|
||||
}
|
||||
}
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user