feat(log): 新增日志注解功能并集成到认证流程
- 新增 @Log 注解及其配置类 LogConfig - 在 AuthController 的 refreshToken 方法上添加 @Log 注解 - 创建 zkh-log 模块并引入 spring-boot-starter-aop 依赖 - 在 zkh-web 模块中引入 zkh-log 依赖 - 调整 GlobalExceptionHandler 和 RedisConfig 类中的代码缩进格式 - 更新 pom.xml 文件,加入 zkh-log 模块并调整依赖版本声明位置 - 修改 SpringDocConfig、WebSecurityConfig 等配置类的 bean 名称以避免冲突
This commit is contained in:
6
pom.xml
6
pom.xml
@ -38,6 +38,7 @@
|
||||
<module>zkh-common</module>
|
||||
<module>zkh-web</module>
|
||||
<module>zkh-data</module>
|
||||
<module>zkh-log</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
@ -71,6 +72,11 @@
|
||||
<artifactId>zkh-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>vip.jcfd</groupId>
|
||||
<artifactId>zkh-log</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-common</artifactId>
|
||||
|
||||
@ -13,12 +13,6 @@
|
||||
<name>ZKH Data</name>
|
||||
<description>Data layer components for ZKH framework</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>jakarta.persistence</groupId>
|
||||
|
||||
23
zkh-log/pom.xml
Normal file
23
zkh-log/pom.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>vip.jcfd</groupId>
|
||||
<artifactId>zkh-framework</artifactId>
|
||||
<version>1.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zkh-log</artifactId>
|
||||
<name>ZKH log</name>
|
||||
<description>Logging utilities for ZKH framework</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
10
zkh-log/src/main/java/vip/jcfd/log/annotation/Log.java
Normal file
10
zkh-log/src/main/java/vip/jcfd/log/annotation/Log.java
Normal file
@ -0,0 +1,10 @@
|
||||
package vip.jcfd.log.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Log {
|
||||
String value();
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package vip.jcfd.log.annotation.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration("_logConfiguration")
|
||||
public class LogConfig {
|
||||
}
|
||||
@ -19,6 +19,10 @@
|
||||
<groupId>vip.jcfd</groupId>
|
||||
<artifactId>zkh-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>vip.jcfd</groupId>
|
||||
<artifactId>zkh-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
||||
@ -13,7 +13,7 @@ import vip.jcfd.common.core.R;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestControllerAdvice
|
||||
@RestControllerAdvice("_globalExceptionHandler")
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
@ -10,7 +10,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import vip.jcfd.web.config.props.SecurityProps;
|
||||
import vip.jcfd.web.redis.TokenRedisStorage;
|
||||
|
||||
@Configuration
|
||||
@Configuration("_redisConfiguration")
|
||||
public class RedisConfig {
|
||||
|
||||
private final SecurityProps securityProps;
|
||||
|
||||
@ -10,7 +10,7 @@ import org.springdoc.core.customizers.OpenApiCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration("_springDocConfig")
|
||||
@Configuration("_springDocConfiguration")
|
||||
public class SpringDocConfig {
|
||||
|
||||
@Bean
|
||||
|
||||
@ -52,7 +52,7 @@ import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Configuration
|
||||
@Configuration("_webSecurityConfiguration")
|
||||
@EnableWebSecurity
|
||||
@ConfigurationPropertiesScan(basePackageClasses = {SecurityProps.class})
|
||||
@EnableJpaAuditing
|
||||
|
||||
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import vip.jcfd.common.core.R;
|
||||
import vip.jcfd.common.dto.TokenRefreshRequest;
|
||||
import vip.jcfd.common.dto.TokenRefreshResponse;
|
||||
import vip.jcfd.log.annotation.Log;
|
||||
import vip.jcfd.web.auth.RefreshTokenAuthenticationToken;
|
||||
import vip.jcfd.web.redis.TokenRedisStorage;
|
||||
|
||||
@ -37,6 +38,7 @@ public class AuthController {
|
||||
|
||||
@PostMapping("/refresh-token")
|
||||
@Operation(summary = "刷新Token", description = "使用Refresh Token获取新的Access Token和Refresh Token")
|
||||
@Log("刷新了token")
|
||||
public R<TokenRefreshResponse> refreshToken(
|
||||
@Valid @RequestBody TokenRefreshRequest request) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user