|
|
@@ -1,124 +1,41 @@
|
|
|
-//package com.citupro.flames.config;
|
|
|
-//
|
|
|
-////import com.alibaba.fastjson.serializer.JavaBeanSerializer;
|
|
|
-//
|
|
|
-//import com.alibaba.fastjson.serializer.*;
|
|
|
-//import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
|
-//import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
-//import com.bing.digitalparadigm.model.Result;
|
|
|
-//import com.citupro.flames.component.HeaderRequestInterceptor;
|
|
|
-//import com.citupro.flames.filter.DictFastJsonFilter;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
|
|
-//import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
|
|
-//import org.springframework.context.annotation.Bean;
|
|
|
-//import org.springframework.context.annotation.Configuration;
|
|
|
-//import org.springframework.http.MediaType;
|
|
|
-//import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
-//import org.springframework.http.converter.HttpMessageConverter;
|
|
|
-//import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
-//import org.springframework.web.client.RestTemplate;
|
|
|
-//
|
|
|
-//import java.nio.charset.Charset;
|
|
|
-//import java.util.ArrayList;
|
|
|
-//import java.util.Arrays;
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.Map;
|
|
|
-//
|
|
|
-//@Configuration
|
|
|
-//public class RestTmplateConfig {
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// HeaderRequestInterceptor headerRequestInterceptor;
|
|
|
-//
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// @LoadBalanced
|
|
|
-// public RestTemplate getRestTemplate(FastJsonHttpMessageConverter fastConverter){ //设置转发的编码格式UTF-8
|
|
|
-// HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
|
|
-// httpComponentsClientHttpRequestFactory.setConnectionRequestTimeout(15000);
|
|
|
-// httpComponentsClientHttpRequestFactory.setConnectTimeout(15000);
|
|
|
-// httpComponentsClientHttpRequestFactory.setReadTimeout(15000);
|
|
|
-// RestTemplate restTemplate = new RestTemplate();
|
|
|
-// restTemplate.setInterceptors( Arrays.asList(headerRequestInterceptor) );
|
|
|
-//
|
|
|
-// List<HttpMessageConverter<?>> httpMessageConverters = restTemplate.getMessageConverters();
|
|
|
-// httpMessageConverters.stream().forEach(httpMessageConverter -> {
|
|
|
-// if(httpMessageConverter instanceof StringHttpMessageConverter){
|
|
|
-// StringHttpMessageConverter messageConverter = (StringHttpMessageConverter) httpMessageConverter;
|
|
|
-// messageConverter.setDefaultCharset(Charset.forName("UTF-8"));
|
|
|
-// }
|
|
|
-// });
|
|
|
-// httpMessageConverters.add(fastConverter);
|
|
|
-// return restTemplate;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public FastJsonHttpMessageConverter initFastJsonHttpMessageConverter(DictFastJsonFilter dictFastJsonFilter) {
|
|
|
-// FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
|
|
-// FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
|
|
-// fastJsonConfig.getParserConfig().setSafeMode(true);
|
|
|
-// List<MediaType> supportedMediaTypes = new ArrayList<>();
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
|
|
-//// supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_ATOM_XML);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_PDF);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_RSS_XML);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_XHTML_XML);
|
|
|
-// supportedMediaTypes.add(MediaType.APPLICATION_XML);
|
|
|
-// supportedMediaTypes.add(MediaType.IMAGE_GIF);
|
|
|
-// supportedMediaTypes.add(MediaType.IMAGE_JPEG);
|
|
|
-// supportedMediaTypes.add(MediaType.IMAGE_PNG);
|
|
|
-// supportedMediaTypes.add(MediaType.TEXT_EVENT_STREAM);
|
|
|
-// supportedMediaTypes.add(MediaType.TEXT_HTML);
|
|
|
-// supportedMediaTypes.add(MediaType.TEXT_MARKDOWN);
|
|
|
-// supportedMediaTypes.add(MediaType.TEXT_PLAIN);
|
|
|
-// supportedMediaTypes.add(MediaType.TEXT_XML);
|
|
|
-// fastConverter.setSupportedMediaTypes(supportedMediaTypes);
|
|
|
-// fastJsonConfig.setSerializerFeatures(
|
|
|
-// SerializerFeature.DisableCircularReferenceDetect,
|
|
|
-// /*是否输出值为null的字段,默认为false,我们将它打开*/
|
|
|
-// SerializerFeature.WriteMapNullValue,
|
|
|
-// /*将Collection类型字段的字段空值输出为[]*/
|
|
|
-// SerializerFeature.WriteNullListAsEmpty,
|
|
|
-// /*将字符串类型字段的空值输出为空字符串*/
|
|
|
-// SerializerFeature.WriteNullStringAsEmpty,
|
|
|
-// /*将数值类型字段的空值输出为0*/
|
|
|
-// SerializerFeature.WriteNullNumberAsZero,
|
|
|
-// /*自定义日期格式*/
|
|
|
-// SerializerFeature.WriteDateUseDateFormat,
|
|
|
-// SerializerFeature.PrettyFormat,
|
|
|
-// SerializerFeature.DisableCircularReferenceDetect,
|
|
|
-// SerializerFeature.WriteNullListAsEmpty
|
|
|
-// );
|
|
|
-// fastConverter.setFastJsonConfig(fastJsonConfig);
|
|
|
-// // fastjson的值过滤器ValueFilter 可以对序列化的值做统一处理,此处我将为null的空值全部统一处理为空字符串
|
|
|
-// ValueFilter valueFilter = (o, s, o1) -> {
|
|
|
-// if (null == o1) {
|
|
|
-// o1 = "";
|
|
|
-// }
|
|
|
-// return o1;
|
|
|
-// };
|
|
|
-// fastJsonConfig.setSerializeFilters(valueFilter);
|
|
|
-// SerializeConfig config = new SerializeConfig();
|
|
|
-//// config.
|
|
|
-// config.put(Result.class, new JavaBeanSerializer(Result.class));
|
|
|
-// config.put(Map.class, new JavaBeanSerializer(Map.class));
|
|
|
-// config.put(Long.class, new ToStringSerializer());
|
|
|
-// fastJsonConfig.setSerializeConfig(config);
|
|
|
-// fastJsonConfig.setSerializeFilters(dictFastJsonFilter);
|
|
|
-// fastConverter.setFastJsonConfig(fastJsonConfig);
|
|
|
-// return fastConverter;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public HttpMessageConverters fastJsonHttpMessageConverters(FastJsonHttpMessageConverter fastConverter) {
|
|
|
-// return new HttpMessageConverters(fastConverter);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//}
|
|
|
+package com.citupro.module.menduner.flames.config;
|
|
|
+
|
|
|
+//import com.alibaba.fastjson.serializer.JavaBeanSerializer;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.serializer.*;
|
|
|
+import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
|
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
|
|
+import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
|
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
+import org.springframework.http.converter.HttpMessageConverter;
|
|
|
+import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Configuration
|
|
|
+public class RestTmplateConfig {
|
|
|
+
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder,TenantIdInterceptor feignClientsConfigurationCustom) {
|
|
|
+ RestTemplate restTemplate = restTemplateBuilder.additionalInterceptors(feignClientsConfigurationCustom).build();
|
|
|
+ return restTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|