From f3ad2c48a9511ef611d414596539e838adef8e45 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 17 Jan 2024 21:35:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(log):=20=E4=BF=AE=E5=A4=8D=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E6=8E=A5=E5=8F=A3=E4=BB=8D=E7=84=B6=E8=A2=AB=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=AF=B7=E6=B1=82=E6=97=A5=E5=BF=97=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../log/httptracepro/handler/LogInterceptor.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java index c5b26def..edfb8c22 100644 --- a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java +++ b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java @@ -19,6 +19,7 @@ package top.charles7c.continew.starter.log.httptracepro.handler; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.alibaba.ttl.TransmittableThreadLocal; +import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; @@ -169,12 +170,20 @@ public class LogInterceptor implements HandlerInterceptor { if (null != methodOperation && methodOperation.hidden()) { return false; } + Hidden methodHidden = handlerMethod.getMethodAnnotation(Hidden.class); + if (null != methodHidden) { + return false; + } + Class handlerBeanType = handlerMethod.getBeanType(); + if (null != handlerBeanType.getDeclaredAnnotation(Hidden.class)) { + return false; + } // 如果接口方法或类上有 @Log 注解,且要求忽略该接口,则不记录日志 Log methodLog = handlerMethod.getMethodAnnotation(Log.class); if (null != methodLog && methodLog.ignore()) { return false; } - Log classLog = handlerMethod.getBeanType().getDeclaredAnnotation(Log.class); + Log classLog = handlerBeanType.getDeclaredAnnotation(Log.class); return null == classLog || !classLog.ignore(); } }