From 07a68b8d93aa059968a9709f2c81e6625338032c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 21 十一月 2022 20:19:49 +0800 Subject: [PATCH] 12 --- src/main/java/com/lf/server/config/WebConfig.java | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lf/server/config/WebConfig.java b/src/main/java/com/lf/server/config/WebConfig.java index a74cf90..529efac 100644 --- a/src/main/java/com/lf/server/config/WebConfig.java +++ b/src/main/java/com/lf/server/config/WebConfig.java @@ -3,8 +3,11 @@ import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import com.lf.server.interceptor.AuthInterceptor; +import com.lf.server.service.all.SysService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.stereotype.Component; import org.springframework.util.AntPathMatcher; import org.springframework.web.servlet.config.annotation.*; @@ -12,18 +15,32 @@ import java.util.List; /** - * WebConfig + * Web閰嶇疆绫� * @author WWW */ -@Component +@Configuration public class WebConfig extends WebMvcConfigurationSupport { + @Autowired + private SysService sysService; + + /** + * 鑾峰彇鎷︽埅鍣ㄥ璞� + * + * @return + */ + public AuthInterceptor getAuthBean() { + return new AuthInterceptor(sysService); + } + /** * swagger鎺у埗 */ @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); + super.addResourceHandlers(registry); } /** @@ -55,6 +72,9 @@ */ @Override protected void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(getAuthBean()) + // .excludePathPatterns("/swagger", "/webjars/**", "/v2/**", "/sign/**") + .addPathPatterns("/**"); super.addInterceptors(registry); } -- Gitblit v1.9.3