后台管理功能实现
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.emotion.config;
|
||||
|
||||
import com.emotion.interceptor.AuthInterceptor;
|
||||
import com.emotion.interceptor.AdminAuthInterceptor;
|
||||
import com.emotion.interceptor.UserContextInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -21,6 +22,9 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private AuthInterceptor authInterceptor;
|
||||
|
||||
@Autowired
|
||||
private AdminAuthInterceptor adminAuthInterceptor;
|
||||
|
||||
@Autowired
|
||||
private UserContextInterceptor userContextInterceptor;
|
||||
|
||||
@@ -29,11 +33,17 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 认证拦截器
|
||||
// 管理员认证拦截器 - 优先级最高
|
||||
registry.addInterceptor(adminAuthInterceptor)
|
||||
.addPathPatterns("/admin/**")
|
||||
.order(1);
|
||||
|
||||
// 用户认证拦截器
|
||||
registry.addInterceptor(authInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(
|
||||
"/auth/**",
|
||||
"/admin/**", // 排除管理员接口,由AdminAuthInterceptor处理
|
||||
"/error",
|
||||
"/favicon.ico",
|
||||
"/actuator/**",
|
||||
@@ -45,7 +55,8 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
"/doc.html",
|
||||
"/static/**",
|
||||
"/public/**"
|
||||
);
|
||||
)
|
||||
.order(2);
|
||||
|
||||
// 用户上下文拦截器
|
||||
registry.addInterceptor(userContextInterceptor)
|
||||
@@ -62,7 +73,8 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
"/doc.html",
|
||||
"/static/**",
|
||||
"/public/**"
|
||||
);
|
||||
)
|
||||
.order(3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user