|
|
|
|
@ -1,23 +1,33 @@
|
|
|
|
|
package cn.iocoder.mall.admin.config;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.common.framework.config.GlobalExceptionHandler;
|
|
|
|
|
import cn.iocoder.mall.admin.sdk.interceptor.AdminSecurityInterceptor;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
|
|
|
|
@EnableWebMvc
|
|
|
|
|
@Configuration
|
|
|
|
|
//@Import(value = {GlobalExceptionHandler.class, // 统一全局返回
|
|
|
|
|
// ) // TODO 安全拦截器,实现认证和授权功能。
|
|
|
|
|
@Import(value = {GlobalExceptionHandler.class, // 统一全局返回
|
|
|
|
|
AdminSecurityInterceptor.class})
|
|
|
|
|
public class MVCConfiguration implements WebMvcConfigurer {
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private UserSecurityInterceptor securityInterceptor;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AdminSecurityInterceptor adminSecurityInterceptor;
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
|
@Override
|
|
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
|
// registry.addInterceptor(securityInterceptor).addPathPatterns("/user/**", "/admin/**"); // 只拦截我们定义的接口
|
|
|
|
|
// }
|
|
|
|
|
registry.addInterceptor(adminSecurityInterceptor).addPathPatterns("/admin/**")
|
|
|
|
|
.excludePathPatterns("/admin/passport/login"); // 排除登陆接口
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
|
|