暂存提交
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.baiyue.common.web;
|
||||
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* 统一将 Java 长整型序列化为 JSON 字符串,避免浏览器对雪花 ID 产生精度截断。
|
||||
*
|
||||
* <p>请求反序列化仍兼容 JSON 字符串和安全范围内的 JSON 数字;数据库与领域模型继续使用
|
||||
* {@code BIGINT}/{@code Long},本配置只改变 HTTP JSON 表达。</p>
|
||||
*/
|
||||
@AutoConfiguration
|
||||
public class LongIdJacksonConfiguration {
|
||||
|
||||
@Bean
|
||||
Jackson2ObjectMapperBuilderCustomizer longAsStringJacksonCustomizer() {
|
||||
return builder -> builder
|
||||
.serializerByType(Long.class, ToStringSerializer.instance)
|
||||
.serializerByType(Long.TYPE, ToStringSerializer.instance);
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
com.baiyue.common.web.LongIdJacksonConfiguration
|
||||
Reference in New Issue
Block a user