package com.izouma.wenlvju.converter;

import com.alibaba.fastjson.JSON;
import com.izouma.wenlvju.domain.RateAudit;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.AttributeConverter;
import java.util.List;

public class RateAuditListConverter implements AttributeConverter<List<RateAudit>, String> {
    @Override
    public String convertToDatabaseColumn(List<RateAudit> list) {
        if (list != null)
            return JSON.toJSONString(list);
        return null;
    }

    @Override
    public List<RateAudit> convertToEntityAttribute(String s) {
        if (StringUtils.isNotEmpty(s)) {
            return JSON.parseArray(s, RateAudit.class);
        }
        return null;
    }
}
