package com.xunmei.common.core.json;


import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 图片前缀
 */
@Component
public class ImageSerializer extends JsonSerializer<String> {

    @Override
    public void serialize(final String s, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
        if (StringUtils.isBlank(s)) {
            jsonGenerator.writeString("");
            return;
        }
//        jsonGenerator.writeString(UploadProperties.INSTANCE.getResource(s));
        jsonGenerator.writeString(s);
    }
}
