refactor: 重命名 backend-single 目录为 server
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.emotion.config;
|
||||
|
||||
import com.emotion.interceptor.AdminAuthInterceptor;
|
||||
import com.emotion.interceptor.JwtAuthInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Web MVC配置
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private JwtAuthInterceptor jwtAuthInterceptor;
|
||||
|
||||
@Autowired
|
||||
private AdminAuthInterceptor adminAuthInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 管理员拦截器 - 优先级最高,只拦截 /admin/** 路径
|
||||
registry.addInterceptor(adminAuthInterceptor)
|
||||
.addPathPatterns("/admin/**")
|
||||
.excludePathPatterns(
|
||||
"/admin/auth/login", // 管理员登录接口
|
||||
"/admin/auth/refreshToken" // 管理员刷新token接口
|
||||
)
|
||||
.order(1); // 优先级1,最先执行
|
||||
|
||||
// 普通用户拦截器 - 拦截除管理员路径外的所有请求
|
||||
// 注意: 由于 context-path=/api, excludePathPatterns 需要包含 /api 前缀的路径
|
||||
registry.addInterceptor(jwtAuthInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(
|
||||
"/auth/login", // 登录接口
|
||||
"/auth/register", // 注册接口
|
||||
"/auth/captcha", // 图形验证码接口
|
||||
"/auth/sms-code", // 短信验证码接口(免登录)
|
||||
"/auth/refresh-token", // 刷新token接口
|
||||
"/auth/resetPassword", // 重置密码接口(免登录)
|
||||
"/analytics/events/batch", // Analytics event batch endpoint
|
||||
"/tts/audio/**", // Public generated TTS audio files
|
||||
"/health", // 健康检查接口
|
||||
"/ws/**", // WebSocket接口
|
||||
"/swagger-ui", // Swagger UI
|
||||
"/swagger-ui/**", // Swagger UI sub-paths
|
||||
"/v3/api-docs", // API docs root
|
||||
"/v3/api-docs/**", // API docs sub-paths
|
||||
"/doc.html", // Knife4j entry
|
||||
"/webjars", // Knife4j static resources
|
||||
"/webjars/**", // Knife4j static resources sub-paths
|
||||
"/swagger-resources", // Swagger resources root
|
||||
"/swagger-resources/**", // Swagger resources sub-paths
|
||||
"/actuator/**", // Actuator endpoints
|
||||
"/admin/**", // 排除管理员路径,由管理员拦截器处理
|
||||
"/auth/wechat/login", // WeChat mini program login endpoint
|
||||
"/auth/loginConfig", // 登录方式配置接口(免登录)
|
||||
"/error" // Spring Boot error page
|
||||
)
|
||||
.order(2); // 优先级2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user