Commit 03f40a9d by houseme

更新处理 优化fastjson的输出处理!!!

parent a02662fe
package com.lanren.huhu.partner.config; package com.lanren.huhu.partner.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
...@@ -81,13 +82,18 @@ public class WebMvcAutoConfiguration implements WebMvcConfigurer { ...@@ -81,13 +82,18 @@ public class WebMvcAutoConfiguration implements WebMvcConfigurer {
converter.setSupportedMediaTypes(supportedMediaTypes); converter.setSupportedMediaTypes(supportedMediaTypes);
//自定义配置... //自定义配置...
FastJsonConfig config = new FastJsonConfig(); FastJsonConfig config = new FastJsonConfig();
config.setDateFormat(JSON.DEFFAULT_DATE_FORMAT);
//config.set ... //config.set ...
SerializerFeature[] serializerFeatures = new SerializerFeature[]{ SerializerFeature[] serializerFeatures = new SerializerFeature[]{
SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullBooleanAsFalse, SerializerFeature.QuoteFieldNames, SerializerFeature.WriteBigDecimalAsPlain SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.WriteNullBooleanAsFalse, SerializerFeature.QuoteFieldNames,
SerializerFeature.WriteBigDecimalAsPlain,SerializerFeature.WriteDateUseDateFormat
}; };
config.setSerializerFeatures(serializerFeatures); config.setSerializerFeatures(serializerFeatures);
converter.setFastJsonConfig(config); converter.setFastJsonConfig(config);
converters.add(converter); converters.add(converter);
converters.add(0, converter);
// ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build(); // ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
......
...@@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.annotation.IdType; ...@@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import lombok.Data;
/**
* @author houseme
*/
@Data @Data
@TableName(value = "partner_account") @TableName(value = "partner_account")
public class PartnerAccount implements Serializable { public class PartnerAccount implements Serializable {
......
package com.lanren.huhu.partner.result; package com.lanren.huhu.partner.result;
import com.alibaba.fastjson.annotation.JSONField;
import com.lanren.huhu.partner.util.MessageUtil; import com.lanren.huhu.partner.util.MessageUtil;
/** /**
...@@ -10,7 +11,7 @@ import com.lanren.huhu.partner.util.MessageUtil; ...@@ -10,7 +11,7 @@ import com.lanren.huhu.partner.util.MessageUtil;
* @date 2016年7月18日 上午10:27:00 * @date 2016年7月18日 上午10:27:00
*/ */
public class Result<T> { public class Result<T> {
@JSONField(name="errorCode")
private int code; private int code;
private String message; private String message;
private T data; private T data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment