Commit 0547671c9e6d406ecf211845cd38df75824f407c
1 parent
a426384d
修复 API 访问日志不记录的问题
Showing
2 changed files
with
13 additions
and
17 deletions
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java
| ... | ... | @@ -2,21 +2,18 @@ package cn.iocoder.yudao.framework.apilog.core.filter; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.exceptions.ExceptionUtil; |
| 4 | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | -import cn.hutool.core.util.StrUtil; | |
| 6 | 5 | import cn.hutool.extra.servlet.ServletUtil; |
| 7 | -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | |
| 8 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 9 | 6 | import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; |
| 10 | 7 | import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; |
| 8 | +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | |
| 9 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 10 | +import cn.iocoder.yudao.framework.common.util.date.DateUtils; | |
| 11 | 11 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; |
| 12 | +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | |
| 12 | 13 | import cn.iocoder.yudao.framework.web.config.WebProperties; |
| 14 | +import cn.iocoder.yudao.framework.web.core.filter.ApiRequestFilter; | |
| 13 | 15 | import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; |
| 14 | -import cn.iocoder.yudao.framework.common.util.date.DateUtils; | |
| 15 | -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 16 | -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | |
| 17 | -import lombok.RequiredArgsConstructor; | |
| 18 | 16 | import lombok.extern.slf4j.Slf4j; |
| 19 | -import org.springframework.web.filter.OncePerRequestFilter; | |
| 20 | 17 | |
| 21 | 18 | import javax.servlet.FilterChain; |
| 22 | 19 | import javax.servlet.ServletException; |
| ... | ... | @@ -26,27 +23,24 @@ import java.io.IOException; |
| 26 | 23 | import java.util.Date; |
| 27 | 24 | import java.util.Map; |
| 28 | 25 | |
| 29 | -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.*; | |
| 26 | +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | |
| 30 | 27 | |
| 31 | 28 | /** |
| 32 | 29 | * API 访问日志 Filter |
| 33 | 30 | * |
| 34 | 31 | * @author 芋道源码 |
| 35 | 32 | */ |
| 36 | -@RequiredArgsConstructor | |
| 37 | 33 | @Slf4j |
| 38 | -public class ApiAccessLogFilter extends OncePerRequestFilter { | |
| 34 | +public class ApiAccessLogFilter extends ApiRequestFilter { | |
| 39 | 35 | |
| 40 | - private final WebProperties webProperties; | |
| 41 | 36 | private final String applicationName; |
| 42 | 37 | |
| 43 | 38 | private final ApiAccessLogFrameworkService apiAccessLogFrameworkService; |
| 44 | 39 | |
| 45 | - @Override | |
| 46 | - protected boolean shouldNotFilter(HttpServletRequest request) { | |
| 47 | - // 只过滤 API 请求的地址 | |
| 48 | - return !StrUtil.startWithAny(request.getRequestURI(), webProperties.getAppApi().getPrefix(), | |
| 49 | - webProperties.getAppApi().getPrefix()); | |
| 40 | + public ApiAccessLogFilter(WebProperties webProperties, String applicationName, ApiAccessLogFrameworkService apiAccessLogFrameworkService) { | |
| 41 | + super(webProperties); | |
| 42 | + this.applicationName = applicationName; | |
| 43 | + this.apiAccessLogFrameworkService = apiAccessLogFrameworkService; | |
| 50 | 44 | } |
| 51 | 45 | |
| 52 | 46 | @Override | ... | ... |