package com.gic.haoban.manage.web.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.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * Created 2021/12/23.
 *
 * @author hua
 */
public class LongHttpMessageConverter extends MappingJackson2HttpMessageConverter {

    public LongHttpMessageConverter() {
        super();
        //修复：前端js 精度问题
        ObjectMapper objectMapper = getObjectMapper();
        SimpleModule simpleModule = new SimpleModule();
        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
        simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
        objectMapper.registerModule(simpleModule);
        setObjectMapper(objectMapper);
    }
}
