/** * 订单编码:日期时间毫秒+随机数共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)); } }