|
@@ -1,26 +1,7 @@
|
|
|
package com.persagy.apm.energyalarmstarter.alarmdata;
|
|
|
|
|
|
-import com.alibaba.fastjson.PropertyNamingStrategy;
|
|
|
-import com.alibaba.fastjson.serializer.SerializeConfig;
|
|
|
-import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
-import com.alibaba.fastjson.serializer.ValueFilter;
|
|
|
-import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
|
-import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
-import org.springframework.beans.factory.ObjectFactory;
|
|
|
-import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
|
|
-import org.springframework.cloud.openfeign.support.ResponseEntityDecoder;
|
|
|
-import org.springframework.cloud.openfeign.support.SpringDecoder;
|
|
|
-import org.springframework.cloud.openfeign.support.SpringEncoder;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.http.converter.HttpMessageConverter;
|
|
|
-
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneOffset;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @description: 配置类
|
|
@@ -32,81 +13,5 @@ import java.util.List;
|
|
|
@Configuration
|
|
|
@ComponentScan(value = "com.persagy.apm.energyalarmstarter.alarmdata")
|
|
|
public class AutoConfiguration {
|
|
|
-// @Bean
|
|
|
-// public ResponseEntityDecoder feignDecoder() {
|
|
|
-// HttpMessageConverter fastJsonConverter = createFastJsonConverter();
|
|
|
-// ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(fastJsonConverter);
|
|
|
-// return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public SpringEncoder feignEncoder(){
|
|
|
-// HttpMessageConverter fastJsonConverter = createFastJsonConverter();
|
|
|
-// ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(fastJsonConverter);
|
|
|
-// return new SpringEncoder(objectFactory);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * Description: 添加支持的类型
|
|
|
-// *
|
|
|
-// * @return List<MediaType>
|
|
|
-// * @author luoguangyi
|
|
|
-// * @since 2019年9月3日: 下午6:20:33 Update By luoguangyi 2019年9月3日: 下午6:20:33
|
|
|
-// */
|
|
|
-// private HttpMessageConverter createFastJsonConverter() {
|
|
|
-// //===========替换框架json为fastjson
|
|
|
-// FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
|
|
-// 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 fastJsonConfig = new FastJsonConfig();
|
|
|
-// //---下划线转驼峰
|
|
|
-// SerializeConfig serializeConfig = new SerializeConfig();
|
|
|
-// serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
|
|
|
-// fastJsonConfig.setSerializeConfig(serializeConfig);
|
|
|
-// //---序列化格式
|
|
|
-// fastJsonConfig.setSerializerFeatures(
|
|
|
-// SerializerFeature.PrettyFormat,
|
|
|
-// SerializerFeature.WriteDateUseDateFormat,
|
|
|
-// // List字段如果为null,输出为[],而非null
|
|
|
-//// SerializerFeature.WriteNullListAsEmpty,
|
|
|
-// // 是否显示为null的字段,加上会显示,取消就不会显示为空的字段
|
|
|
-// // SerializerFeature.WriteMapNullValue,
|
|
|
-// // 禁止循环引用
|
|
|
-// SerializerFeature.DisableCircularReferenceDetect
|
|
|
-// // SerializerFeature.WriteNullStringAsEmpty
|
|
|
-// );
|
|
|
-// // 时间格式转换为时间戳
|
|
|
-// fastJsonConfig.setSerializeFilters((ValueFilter) (o, s, source) -> {
|
|
|
-// if (source == null) {
|
|
|
-// return "";
|
|
|
-// }
|
|
|
-// if (source instanceof LocalDateTime) {
|
|
|
-// return ((LocalDateTime) source).toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
-// }
|
|
|
-// return source;
|
|
|
-// });
|
|
|
-//
|
|
|
-// fastConverter.setFastJsonConfig(fastJsonConfig);
|
|
|
-//
|
|
|
-// return fastConverter;
|
|
|
-// }
|
|
|
+
|
|
|
}
|