|
@@ -1,217 +1,217 @@
|
|
|
-package com.futu.course.common.config;
|
|
|
-
|
|
|
-import com.fasterxml.jackson.annotation.JsonInclude;
|
|
|
-import com.fasterxml.jackson.core.JsonGenerator;
|
|
|
-import com.fasterxml.jackson.core.JsonParser;
|
|
|
-import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
-import com.fasterxml.jackson.databind.JsonSerializer;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.fasterxml.jackson.databind.SerializerProvider;
|
|
|
-
|
|
|
-import com.futu.course.common.handle.CurrentUserHandler;
|
|
|
-import com.futu.course.common.intercepter.AuthIntercepter;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.context.annotation.Primary;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|
|
-import org.springframework.web.filter.HttpPutFormContentFilter;
|
|
|
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
|
|
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-@Configuration
|
|
|
-@Slf4j
|
|
|
-
|
|
|
-public class IntercepterConfig extends WebMvcConfigurationSupport {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
|
|
- log.info("IntercepterConfig--------------------");
|
|
|
- resolvers.add(new CurrentUserHandler());
|
|
|
- }
|
|
|
- @Autowired
|
|
|
- AuthIntercepter authIntercepter;
|
|
|
- @Autowired
|
|
|
- protected RedisTemplate redisTemplate;
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addInterceptors(InterceptorRegistry registry) {
|
|
|
-
|
|
|
- registry.addInterceptor(authenticationInterceptor()).excludePathPatterns("**.html").excludePathPatterns("**.txt")
|
|
|
- .excludePathPatterns("/webjars/**")
|
|
|
- .excludePathPatterns("/api/goods-detail")
|
|
|
- .excludePathPatterns("/api/home")
|
|
|
- .excludePathPatterns("/api/cate")
|
|
|
- .excludePathPatterns("/api/goods")
|
|
|
- .excludePathPatterns("/api/boss/home")
|
|
|
- .excludePathPatterns("/api/boss/team-detail")
|
|
|
- .excludePathPatterns("/api/boss/home-detail")
|
|
|
- .excludePathPatterns("/api/boss/supplier")
|
|
|
- .excludePathPatterns("/api/boss/lottery")
|
|
|
- .excludePathPatterns("/api/boss/lottery-detail")
|
|
|
- .excludePathPatterns("/api/team-buy")
|
|
|
- .excludePathPatterns("/api/cart")
|
|
|
- .excludePathPatterns("/api/order")
|
|
|
- .excludePathPatterns("/api/keywords")
|
|
|
- .excludePathPatterns("/api/share-detail")
|
|
|
- .excludePathPatterns("/dashboard/list")
|
|
|
- .excludePathPatterns("/swagger-ui.html")
|
|
|
- .excludePathPatterns("/swagger-resources/**").excludePathPatterns("/error").addPathPatterns("/**");
|
|
|
- super.addInterceptors(registry);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
- super.addResourceHandlers(registry);
|
|
|
- registry.addResourceHandler("/**")
|
|
|
- .addResourceLocations("classpath:/static/")
|
|
|
- .addResourceLocations("classpath:/templates/")
|
|
|
- .addResourceLocations("classpath:/resources/");
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- registry.addResourceHandler("swagger-ui.html")
|
|
|
- .addResourceLocations("classpath:/META-INF/resources/");
|
|
|
- registry.addResourceHandler("/webjars/**")
|
|
|
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
- registry.addResourceHandler("SFLMPwcUTv.txt")
|
|
|
- .addResourceLocations("classpath:/resources/");
|
|
|
-
|
|
|
- }
|
|
|
- @Override
|
|
|
- public void addCorsMappings(CorsRegistry registry) {
|
|
|
- super.addCorsMappings(registry);
|
|
|
- registry
|
|
|
- .addMapping("/**")
|
|
|
- .allowedHeaders("*")
|
|
|
- .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
|
|
- .allowedOrigins("*");
|
|
|
- }
|
|
|
-
|
|
|
- @Bean
|
|
|
- public AuthIntercepter authenticationInterceptor() {
|
|
|
- return new AuthIntercepter(redisTemplate);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- * @Description 解决使用put请求 服务器接收不到参数
|
|
|
- * @author DengKaiTao
|
|
|
- * @date 2018/12/4 16:35
|
|
|
- * @return org.springframework.web.filter.HttpPutFormContentFilter
|
|
|
- * @version v1.0
|
|
|
- **/
|
|
|
- @Bean
|
|
|
- public HttpPutFormContentFilter httpPutFormContentFilter() {
|
|
|
- return new HttpPutFormContentFilter();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- @Bean
|
|
|
- @Primary
|
|
|
- @ConditionalOnMissingBean(ObjectMapper.class)
|
|
|
- public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder)
|
|
|
- {
|
|
|
- ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
|
|
|
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
-
|
|
|
- objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
|
|
|
-
|
|
|
- objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
|
|
|
-
|
|
|
- objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>()
|
|
|
- {
|
|
|
- @Override
|
|
|
- public void serialize(Object o, JsonGenerator jsonGenerator,
|
|
|
- SerializerProvider serializerProvider)
|
|
|
- throws IOException
|
|
|
- {
|
|
|
- jsonGenerator.writeString("");
|
|
|
- }
|
|
|
- });
|
|
|
- return objectMapper;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|