feat(商城): 代码优化

1. 优化首页接口响应速度
2. 优化商品详情接口响应速度
3. 优化分类接口响应速度
4. 优化注释
master
wayn 3 years ago
parent 258d168b4e
commit f3d544d5f8

@ -14,6 +14,8 @@ public class LogMessage implements Serializable {
private Integer httpStatus;
private String httpMethod;
private String path;
private String reqParameter;
private long executionTime;
private String clientIp;
private String javaMethod;
@ -25,6 +27,7 @@ public class LogMessage implements Serializable {
.add("httpStatus=" + httpStatus)
.add("httpMethod='" + httpMethod + "'")
.add("path='" + path + "'")
.add("reqParameter=" + reqParameter)
.add("executionTime=" + executionTime)
.add("clientIp='" + clientIp + "'")
.add("javaMethod='" + javaMethod + "'")

@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* DispatcherServlet
@ -45,6 +46,22 @@ public class WaynDispatcherServlet extends DispatcherServlet {
LogMessage log = new LogMessage();
log.setHttpStatus(responseToCache.getStatus());
log.setHttpMethod(requestToCache.getMethod());
Map<String, String[]> parameterMap = requestToCache.getParameterMap();
StringBuilder parameter = new StringBuilder("[");
int size = parameterMap.size();
int count = 0;
for (Map.Entry<String, String[]> stringEntry : parameterMap.entrySet()) {
count++;
parameter.append(stringEntry.getKey());
parameter.append(":");
parameter.append(stringEntry.getValue()[0]);
if (count < size) {
parameter.append(",");
} else {
parameter.append("]");
}
}
log.setReqParameter(parameter.toString());
log.setPath(requestToCache.getRequestURI());
log.setClientIp(requestToCache.getRemoteAddr());
log.setJavaMethod(handler.toString());

Loading…
Cancel
Save