package cn.estsh.i3plus.pojo.aps.bean;

import cn.estsh.i3plus.pojo.aps.annotation.FieldAnnotation;
import cn.estsh.i3plus.pojo.aps.common.BaseAPS;
import cn.estsh.i3plus.pojo.aps.common.BeanRelation;
import cn.estsh.i3plus.pojo.aps.holders.EImportProject;
import com.fasterxml.jackson.annotation.JsonBackReference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;

/**
 * @Description :数据导入明细集合
 * @Reference :
 * @Author : jason.niu
 * @CreateDate : 2019-09-23
 * @Modify:
 **/
@Data
@Entity
@Table(name = "APS_IMPORT_PROJECT")
@Api("数据导入明细集合")
public class ImportProject extends BaseAPS {
    @Column(name="NAME")
    @ApiParam(value ="标识名")
    private String name;

    @Column(name="LINK_ID")
    @ApiParam(value ="数据连接对象")
    @FieldAnnotation(property = false)
    private Long linkId;

    public DataLink getLink() {
        return BeanRelation.get(this, EImportProject.Link);
    }

    public void setLink(DataLink link) {
        this.linkId = link != null ? link.getId() : 0l;
        BeanRelation.set(this, EImportProject.Link, link);
    }

    @JsonBackReference
    public List<ImportDetail> getDetails() {
        return BeanRelation.list(this, EImportProject.Details);
    }
}
