package com.ssj.bean.sys.fx.domain;

import com.alibaba.fastjson.JSON;
import com.ssj.bean.common.framework.core.domain.BaseEntity;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Table(name="tb_materiel_template")
public class MaterielTemplate extends BaseEntity {
    private String templateName;//模板名称
    private String materielJson; //物料json数据
    private Date createTime; //创建时间
    private String createUser; //创建人
    private Integer state; //状态1正常2 删除

    private List<TemplateInfo> infoList = new ArrayList<TemplateInfo>();

    public String getTemplateName() {
        return templateName;
    }

    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }

    public String getMaterielJson() {
        return materielJson;
    }

    public void setMaterielJson(String materielJson) {
        this.materielJson = materielJson;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    @Transient
    public List<TemplateInfo> getInfoList() {
        if(!"".equals(materielJson)){
            return JSON.parseArray(materielJson,TemplateInfo.class);
        }else{
            return infoList;
        }

    }

    public void setInfoList(List<TemplateInfo> infoList) {
        this.infoList = infoList;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }
}
