|  | @@ -1,17 +1,22 @@
 | 
	
		
			
				|  |  |  package com.yonge.cooleshow.config;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.serializer.SerializerFeature;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.support.config.FastJsonConfig;
 | 
	
		
			
				|  |  |  import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.config.LocalFastJsonHttpMessageConverter;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.config.jackson.JacksonConfig;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.config.jackson.MappingJSONHttpMessageConverter;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.config.EnumConverterFactory;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.interceptor.MDCInterceptor;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.interceptor.OperationLogInterceptor;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
 | 
	
		
			
				|  |  | -import org.springframework.context.annotation.Bean;
 | 
	
		
			
				|  |  |  import org.springframework.context.annotation.Configuration;
 | 
	
		
			
				|  |  |  import org.springframework.format.FormatterRegistry;
 | 
	
		
			
				|  |  |  import org.springframework.http.MediaType;
 | 
	
		
			
				|  |  | +import org.springframework.http.converter.HttpMessageConverter;
 | 
	
		
			
				|  |  |  import org.springframework.http.converter.StringHttpMessageConverter;
 | 
	
		
			
				|  |  | +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 | 
	
		
			
				|  |  |  import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 | 
	
		
			
				|  |  |  import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -52,21 +57,59 @@ public class WebMvcConfig implements WebMvcConfigurer {
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * @param converters List<HttpMessageConverter<?>>
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  | -	/*@Override
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  |  	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
 | 
	
		
			
				|  |  |  		//WebMvcConfigurer.super.configureMessageConverters(converters);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		// 如果存在fastJson的转换器,将其移除
 | 
	
		
			
				|  |  | -		converters.removeIf(httpMessageConverter -> httpMessageConverter instanceof FastJsonHttpMessageConverter);
 | 
	
		
			
				|  |  | +		converters.removeIf(httpMessageConverter -> httpMessageConverter instanceof MappingJackson2HttpMessageConverter);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		// 需要重新加入jackson的转换器,该处的objectMapper已经在配置中注册了
 | 
	
		
			
				|  |  |  		MappingJSONHttpMessageConverter converter = new MappingJSONHttpMessageConverter(new JacksonConfig.JacksonObjectMapper());
 | 
	
		
			
				|  |  |  		converter.setDefaultCharset(StandardCharsets.UTF_8); // 字符编号
 | 
	
		
			
				|  |  | -		converters.add(0, converter);
 | 
	
		
			
				|  |  | +		// converters.add(0, converter);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		// 添加String转换器
 | 
	
		
			
				|  |  | -		converters.add(utf8StringHttpMessageConverter());
 | 
	
		
			
				|  |  | -	}*/
 | 
	
		
			
				|  |  | +		//converters.add(utf8StringHttpMessageConverter());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		// 添加fastJson转换器
 | 
	
		
			
				|  |  | +		// 1. 配置fastjson
 | 
	
		
			
				|  |  | +		FastJsonConfig config = new FastJsonConfig();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		config.setDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  | +		config.setCharset(StandardCharsets.UTF_8);
 | 
	
		
			
				|  |  | +		config.setSerializerFeatures(
 | 
	
		
			
				|  |  | +				SerializerFeature.DisableCircularReferenceDetect,
 | 
	
		
			
				|  |  | +				SerializerFeature.QuoteFieldNames,
 | 
	
		
			
				|  |  | +				SerializerFeature.BrowserSecure,
 | 
	
		
			
				|  |  | +				SerializerFeature.WriteDateUseDateFormat,
 | 
	
		
			
				|  |  | +				//json格式化
 | 
	
		
			
				|  |  | +				SerializerFeature.PrettyFormat,
 | 
	
		
			
				|  |  | +				//输出map中value为null的数据
 | 
	
		
			
				|  |  | +				SerializerFeature.WriteMapNullValue,
 | 
	
		
			
				|  |  | +				//输出boolean 为 false
 | 
	
		
			
				|  |  | +				//SerializerFeature.WriteNullBooleanAsFalse,
 | 
	
		
			
				|  |  | +				//输出list 为 []
 | 
	
		
			
				|  |  | +				SerializerFeature.WriteNullListAsEmpty,
 | 
	
		
			
				|  |  | +				//输出number 为 0
 | 
	
		
			
				|  |  | +				SerializerFeature.WriteNullNumberAsZero,
 | 
	
		
			
				|  |  | +				//输出字符串 为 ""
 | 
	
		
			
				|  |  | +				SerializerFeature.WriteNullStringAsEmpty,
 | 
	
		
			
				|  |  | +				//对map进行排序
 | 
	
		
			
				|  |  | +				SerializerFeature.MapSortField
 | 
	
		
			
				|  |  | +		);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		// 2. 添加fastjson转换器
 | 
	
		
			
				|  |  | +		LocalFastJsonHttpMessageConverter fastJsonHttpMessageConverter = new LocalFastJsonHttpMessageConverter();
 | 
	
		
			
				|  |  | +		fastJsonHttpMessageConverter.setDefaultCharset(StandardCharsets.UTF_8);
 | 
	
		
			
				|  |  | +		fastJsonHttpMessageConverter.setFastJsonConfig(config);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		List<MediaType> fastMediaTypes = new ArrayList<>();
 | 
	
		
			
				|  |  | +		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
 | 
	
		
			
				|  |  | +		fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		converters.add(0, fastJsonHttpMessageConverter);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * 自定义String转换器
 | 
	
	
		
			
				|  | @@ -90,7 +133,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 | 
	
		
			
				|  |  |  		return converter;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Bean
 | 
	
		
			
				|  |  | +	//@Bean
 | 
	
		
			
				|  |  |  	public HttpMessageConverters fastJsonHttpMessageConverters() {
 | 
	
		
			
				|  |  |  		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
 | 
	
		
			
				|  |  |  		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
 |