package cc.smtweb.framework.core.util.jackson;

import cc.smtweb.framework.core.db.impl.BaseBean;
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 java.io.IOException;

public class BaseBeanSerializer extends JsonSerializer<BaseBean> {

    @Override
    public void serialize(BaseBean value, JsonGenerator gen,
                          SerializerProvider serializers) throws IOException,
            JsonProcessingException {
        if (value == null) {
            gen.writeNull();
        } else {
            gen.writeObject(value.getData());
        }
    }
}
