Commit 650133dda4d1e54223fd85d3cc53df14851084b2

Authored by YunaiV
1 parent cb0daf3c

增加 NumberSerializer 注释

yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/NumberSerializer.java
... ... @@ -5,20 +5,26 @@ import com.fasterxml.jackson.databind.SerializerProvider;
5 5 import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
6 6  
7 7 import java.io.IOException;
  8 +
8 9 /**
9   - * Long序列化规则
10   - * <p>
11   - * 会将超长long值转换为string
  10 + * Long 序列化规则
  11 + *
  12 + * 会将超长 long 值转换为 string,解决前端 JavaScript 最大安全整数是 2^53-1 的问题
  13 + *
  14 + * @author 星语
12 15 */
13 16 @JacksonStdImpl
14 17 public class NumberSerializer extends com.fasterxml.jackson.databind.ser.std.NumberSerializer {
  18 +
15 19 private static final long MAX_SAFE_INTEGER = 9007199254740991L;
16 20 private static final long MIN_SAFE_INTEGER = -9007199254740991L;
17 21  
18 22 public static final NumberSerializer INSTANCE = new NumberSerializer(Number.class);
  23 +
19 24 public NumberSerializer(Class<? extends Number> rawType) {
20 25 super(rawType);
21 26 }
  27 +
22 28 @Override
23 29 public void serialize(Number value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
24 30 // 超出范围 序列化位字符串
... ...