|
|
@ -27,10 +27,6 @@ import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|
|
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|
|
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
|
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
|
|
|
|
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
|
|
|
|
|
|
import org.springframework.web.filter.CorsFilter;
|
|
|
|
|
|
|
|
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.PathMatchConfigurer;
|
|
|
|
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
@ -70,34 +66,10 @@ public class SpringWebMvcConfig implements WebMvcConfigurer, WebMvcRegistrations
|
|
|
|
.addPathPrefix(apiPathProperties.getGlobalPrefix(),c -> c.isAnnotationPresent(ApiRestController.class));
|
|
|
|
.addPathPrefix(apiPathProperties.getGlobalPrefix(),c -> c.isAnnotationPresent(ApiRestController.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 解决跨域问题
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param registry registry
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
|
|
|
|
// registry.addMapping("/**")
|
|
|
|
|
|
|
|
// .allowedOriginPatterns("*")
|
|
|
|
|
|
|
|
// .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
|
|
|
|
|
|
|
|
// .allowedHeaders("*")
|
|
|
|
|
|
|
|
// .allowCredentials(true)
|
|
|
|
|
|
|
|
// .maxAge(7200);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
// 加载特定拦截器
|
|
|
|
// 加载特定拦截器
|
|
|
|
registry.addInterceptor(new UserAuthInterceptor());
|
|
|
|
registry.addInterceptor(new UserAuthInterceptor());
|
|
|
|
WebMvcConfigurer.super.addInterceptors(registry);
|
|
|
|
WebMvcConfigurer.super.addInterceptors(registry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
|
|
|
|
|
|
|
|
.serializerByType(Long.class, ToStringSerializer.instance)
|
|
|
|
|
|
|
|
.serializerByType(Long.TYPE, ToStringSerializer.instance)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
return new MappingJackson2HttpMessageConverter(objectMapper);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|