From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 02 七月 2025 16:43:13 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service --- src/main/java/com/lf/server/config/WebConfig.java | 37 +++++++++++++++++++++++++++++++++---- 1 files changed, 33 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..3d11745 100644 --- a/src/main/java/com/lf/server/config/WebConfig.java +++ b/src/main/java/com/lf/server/config/WebConfig.java @@ -3,8 +3,12 @@ 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.core.Ordered; 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 +16,40 @@ import java.util.List; /** - * WebConfig + * Web閰嶇疆绫� * @author WWW */ -@Component +@Configuration public class WebConfig extends WebMvcConfigurationSupport { + @Autowired + private SysService sysService; + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + // 璁剧疆璁块棶璺緞涓� 鈥�/鈥� 璺宠浆鍒版寚瀹氶〉闈� + registry.addViewController("/").setViewName("redirect:/sign/toIndex"); + // 璁剧疆涓烘渶楂樹紭鍏堢骇 + registry.setOrder(Ordered.HIGHEST_PRECEDENCE); + } + + /** + * 鑾峰彇鎷︽埅鍣ㄥ璞� + * + * @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 +81,9 @@ */ @Override protected void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(getAuthBean()) + // .excludePathPatterns("/swagger", "/webjars/**", "/v2/**", "/sign/**") + .addPathPatterns("/**"); super.addInterceptors(registry); } -- Gitblit v1.9.3