|
@@ -1,46 +1,46 @@
|
|
-package com.abi.qms.platform.infrastructure.config;
|
|
|
|
|
|
+package com.abi.qms.config;
|
|
|
|
+
|
|
|
|
|
|
import com.abi.qms.platform.infrastructure.interceptor.CorsInterceptor;
|
|
import com.abi.qms.platform.infrastructure.interceptor.CorsInterceptor;
|
|
-import com.abi.qms.platform.infrastructure.interceptor.IwepTokenInterceptor;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * @author lenovo
|
|
|
|
+ */
|
|
@Configuration
|
|
@Configuration
|
|
-public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
|
+public class WebMvcConfig extends WebMvcConfigurationSupport {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- CorsInterceptor corsInterceptor;
|
|
|
|
|
|
+ private CorsInterceptor corsInterceptor;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
- registry.addInterceptor(getTokenInterceptor())
|
|
|
|
- .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Bean
|
|
|
|
- public IwepTokenInterceptor getTokenInterceptor(){
|
|
|
|
- return new IwepTokenInterceptor();
|
|
|
|
|
|
+ protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
+ registry.addResourceHandler("/swagger-ui/**")
|
|
|
|
+ .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
|
|
|
|
+ super.addResourceHandlers(registry);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
- registry.addResourceHandler("swagger-ui.html")
|
|
|
|
- .addResourceLocations("classpath:/META-INF/resources/");
|
|
|
|
- registry.addResourceHandler("/webjars/**")
|
|
|
|
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
|
|
|
+ protected void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
+ registry.addInterceptor(corsInterceptor)
|
|
|
|
+ .addPathPatterns("/**")
|
|
|
|
+ .excludePathPatterns("/swagger**/**")
|
|
|
|
+ .excludePathPatterns("/webjars/**")
|
|
|
|
+ .excludePathPatterns("/v3/**")
|
|
|
|
+ .excludePathPatterns("/doc.html");
|
|
|
|
+ super.addInterceptors(registry);
|
|
}
|
|
}
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
registry.addMapping("/**")
|
|
registry.addMapping("/**")
|
|
.allowedOrigins("*")
|
|
.allowedOrigins("*")
|
|
.allowCredentials(true)
|
|
.allowCredentials(true)
|
|
- .allowedMethods("GET","POST", "DELETE", "PUT")
|
|
|
|
|
|
+ .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH")
|
|
.allowedHeaders("*")
|
|
.allowedHeaders("*")
|
|
.maxAge(3600 * 24);
|
|
.maxAge(3600 * 24);
|
|
}
|
|
}
|