2 Commit-ok fc8682a322 ... 8c270a9bde

Szerző SHA1 Üzenet Dátum
  shuhao 8c270a9bde shuhao 1 hónapja
  shuhao 874cd4cbb2 shuhao 1 hónapja

+ 4 - 1
src/main/java/com/xiesx/fastboot/core/body/GlobalBodyAdvice.java

@@ -9,7 +9,7 @@ import org.springframework.http.server.ServerHttpRequest;
 import org.springframework.http.server.ServerHttpResponse;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
-
+import java.io.Serializable;
 import com.xiesx.fastboot.base.pagination.PaginationResult;
 import com.xiesx.fastboot.base.result.BaseResult;
 import com.xiesx.fastboot.base.result.R;
@@ -35,6 +35,9 @@ public class GlobalBodyAdvice implements ResponseBodyAdvice<Object> {
         log.debug("beforeBodyWrite ......");
         Object res = null;
         // 按需使用,如果有改动,务必兼容之前代码
+        if(returnValue instanceof Serializable){
+            return returnValue;
+        }
         if (returnValue instanceof BaseResult || returnValue instanceof PaginationResult) {
             res = returnValue;
         } else if (returnValue instanceof Map<?, ?> || returnValue instanceof Iterable<?>) {

+ 13 - 14
src/main/java/com/xiesx/fastboot/core/fastjson/cfg/FastJsonCfg.java

@@ -1,9 +1,11 @@
 package com.xiesx.fastboot.core.fastjson.cfg;
 
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.List;
-
+import com.alibaba.fastjson.serializer.SerializeConfig;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import com.xiesx.fastboot.core.fastjson.cfg.FastJsonProperties;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
@@ -11,11 +13,8 @@ import org.springframework.http.MediaType;
 import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import com.alibaba.fastjson.serializer.SerializeConfig;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.alibaba.fastjson.serializer.ToStringSerializer;
-import com.alibaba.fastjson.support.config.FastJsonConfig;
-import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import java.math.BigInteger;
+import java.util.List;
 
 @Configuration
 @EnableConfigurationProperties(FastJsonProperties.class)
@@ -25,15 +24,15 @@ public class FastJsonCfg implements WebMvcConfigurer {
             // 字符类型字段如果为null,输出为"",而不是null
             SerializerFeature.WriteNullStringAsEmpty,
             // 数值字段如果为null,输出为0,而不是null
-            SerializerFeature.WriteNullNumberAsZero,
+//            SerializerFeature.WriteNullNumberAsZero,
             // Boolean字段如果为null,输出为false,而不是null
-            SerializerFeature.WriteNullBooleanAsFalse,
+//            SerializerFeature.WriteNullBooleanAsFalse,
             // 枚举类型用ToString输出为
-            SerializerFeature.WriteEnumUsingToString,
+//            SerializerFeature.WriteEnumUsingToString,
             // 是否输出值为null的字段
-            // SerializerFeature.WriteMapNullValue,
+            SerializerFeature.WriteMapNullValue,
             // list字段如果为null,输出为[],而不是null
-            // SerializerFeature.WriteNullListAsEmpty,
+            SerializerFeature.WriteNullListAsEmpty,
             // 输出格式后的日期
             SerializerFeature.WriteDateUseDateFormat,
             // 禁用循环引用