Long 类型格式化成String 传给前端

 

 

/**
     * 订单编码:日期时间毫秒+随机数共19位
     */
    @ApiModelProperty(value = "订单编码:日期时间毫秒+随机数共19位")
    @JsonSerialize(using = JsonLongSerializer.class )
    private Long orderNo;

 

 

 

package com.yq.utils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author: wensm
 * @date: 2021/5/13 0013
 * @description: TODO
 **/
public class JsonLongSerializer extends JsonSerializer<Long> {
    @Override
    public void serialize(Long aLong, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(Long.toString(aLong));
    }
}

 

posted @ 2021-05-19 17:43  残星  阅读(425)  评论(0编辑  收藏  举报