操作日志添加执行的模块和方法
This commit is contained in:
+6
@@ -270,6 +270,12 @@ public class AuthFilter extends BaseFilter implements Ordered, BootCommonConstan
|
||||
log.setTitle(tag.toString());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(log.getMemo())) {
|
||||
Object method = CommonHolder.get(SWAGGER_METHOD);
|
||||
if (Objects.nonNull(method)) {
|
||||
log.setMemo(method.toString());
|
||||
}
|
||||
}
|
||||
log.setGmtCreate(Instant.now());
|
||||
LogBus.init(LogLevel.INFO, LogBusBaseType.OPT_LOG).data(log).save();
|
||||
}
|
||||
|
||||
+13
-1
@@ -6,10 +6,10 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import static xtools.base.config.Constants.*;
|
||||
import xtools.boot.api.constant.BootCommonConstant;
|
||||
import xtools.boot.core.holder.CommonHolder;
|
||||
import xtools.core.StringUtils;
|
||||
@@ -17,6 +17,10 @@ import xtools.core.StringUtils;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import static xtools.base.config.Constants.CP_COLON;
|
||||
import static xtools.base.config.Constants.CP_LINE;
|
||||
import static xtools.base.config.Constants.CP_SPACE;
|
||||
|
||||
/**
|
||||
* <p>Title : SwaggerTagInterceptor</p>
|
||||
* <p>Description : SwaggerTagInterceptor</p>
|
||||
@@ -32,6 +36,9 @@ import java.util.StringJoiner;
|
||||
@Component
|
||||
public class SwaggerTagInterceptor implements HandlerInterceptor, BootCommonConstant {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* 进入Handler方法之前执行
|
||||
*
|
||||
@@ -54,6 +61,10 @@ public class SwaggerTagInterceptor implements HandlerInterceptor, BootCommonCons
|
||||
return true;
|
||||
}
|
||||
|
||||
// 获取方法名
|
||||
String method = appName + CP_COLON + CP_SPACE + handlerMethod.getMethod();
|
||||
|
||||
// 获取@Tag注解和@Operation注解
|
||||
StringJoiner joiner = new StringJoiner(CP_LINE);
|
||||
// 获取@Tag注解
|
||||
Tag tag = handlerMethod.getBeanType().getAnnotation(Tag.class);
|
||||
@@ -73,6 +84,7 @@ public class SwaggerTagInterceptor implements HandlerInterceptor, BootCommonCons
|
||||
}
|
||||
}
|
||||
CommonHolder.set(SWAGGER_TAG, joiner.toString());
|
||||
CommonHolder.set(SWAGGER_METHOD, method);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user