| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| | | import cn.iocoder.yudao.framework.common.util.spring.SpringUtils; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | // 打印 request 日志 |
| | | if (!SpringUtils.isProd()) { |
| | | Map<String, String> queryString = ServletUtils.getParamMap(request); |
| | | String requestBody = ServletUtils.getBody(request); |
| | | if (CollUtil.isEmpty(queryString) && StrUtil.isEmpty(requestBody)) { |
| | | log.info("[preHandle][开始请求 URL({}) 无参数]", request.getRequestURI()); |
| | | ApiAccessLog accessLog = handlerMethod != null ? handlerMethod.getMethodAnnotation(ApiAccessLog.class) : null; |
| | | if (accessLog != null && !accessLog.requestEnable()) { |
| | | log.info("[preHandle][开始请求 URL({}) 敏感请求参数已隐藏]", request.getRequestURI()); |
| | | } else { |
| | | log.info("[preHandle][开始请求 URL({}) 参数({})]", request.getRequestURI(), |
| | | StrUtil.blankToDefault(requestBody, queryString.toString())); |
| | | Map<String, String> queryString = ServletUtils.getParamMap(request); |
| | | String requestBody = ServletUtils.getBody(request); |
| | | if (CollUtil.isEmpty(queryString) && StrUtil.isEmpty(requestBody)) { |
| | | log.info("[preHandle][开始请求 URL({}) 无参数]", request.getRequestURI()); |
| | | } else { |
| | | log.info("[preHandle][开始请求 URL({}) 参数({})]", request.getRequestURI(), |
| | | StrUtil.blankToDefault(requestBody, queryString.toString())); |
| | | } |
| | | } |
| | | // 计时 |
| | | StopWatch stopWatch = new StopWatch(); |