mirror of https://github.com/elunez/eladmin
在System模块的ConfigurerAdapter类中添加 解决Long 类型在 前端精度丢失的实现
parent
07f6f28bd9
commit
8a88f90367
|
@ -1,10 +1,19 @@
|
|||
package me.zhengjie.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* WebMvcConfigurer
|
||||
|
@ -26,6 +35,25 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
|||
|
||||
}
|
||||
|
||||
// 可解决Long 类型在 前端精度丢失的问题, 如不想全局 直接添加注解 @JsonSerialize(using= ToStringSerializer.class) 到相应的字段上
|
||||
|
||||
// @Override
|
||||
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
//
|
||||
// MappingJackson2HttpMessageConverter jackson2HttpMessageConverter =
|
||||
// new MappingJackson2HttpMessageConverter();
|
||||
//
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// SimpleModule simpleModule = new SimpleModule();
|
||||
// simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
|
||||
// simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
// simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
// objectMapper.registerModule(simpleModule);
|
||||
// jackson2HttpMessageConverter.setObjectMapper(objectMapper);
|
||||
// converters.add(jackson2HttpMessageConverter);
|
||||
// converters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.zhengjie.modules.system.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue