hecheng 3 rokov pred
rodič
commit
850a352f72

+ 6 - 4
zd-common/zd-common-core/src/main/java/com/zd/common/core/config/JacksonObjectMapper.java

@@ -17,6 +17,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
+import java.util.TimeZone;
 
 import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
 
@@ -39,16 +40,17 @@ public class JacksonObjectMapper extends ObjectMapper {
 
         // 设置Date类型格式化
         this.setDateFormat(new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT));
+        this.setTimeZone(TimeZone.getDefault());
 
         SimpleModule simpleModule = new SimpleModule()
+                // 将大数字类型自动转换为String类型,防止前端精度丢失(也可以直接使用@JsonFormat(shape = JsonFormat.Shape.STRING)注解)
+                .addSerializer(BigInteger.class, ToStringSerializer.instance)
+                .addSerializer(Long.class, ToStringSerializer.instance)
                 // 反序列化(设置LocalDateTime等日期时间类型格式化)
                 .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
                 .addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
                 .addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)))
-                // 将大数字类型自动转换为String类型,防止前端精度丢失(也可以直接使用@JsonFormat(shape = JsonFormat.Shape.STRING)注解)
-                .addSerializer(BigInteger.class, ToStringSerializer.instance)
-                .addSerializer(Long.class, ToStringSerializer.instance)
-                // 序列化
+//                // 序列化
                 .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
                 .addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
                 .addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));

+ 0 - 3
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/ZdBottleApplication.java

@@ -9,8 +9,6 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
-import java.util.TimeZone;
-
 /**
  * Application
  *
@@ -25,7 +23,6 @@ import java.util.TimeZone;
 @Slf4j
 public class ZdBottleApplication {
     public static void main(String[] args) {
-        TimeZone.setDefault(TimeZone.getTimeZone("CTT"));
         SpringApplication.run(ZdBottleApplication.class, args);
         log.info("(♥◠‿◠)ノ゙  气瓶模块启动成功   ლ(´ڡ`ლ)゙");
     }