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.EExportProject;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;

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
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "APS_EXPORT_PROJECT")
@Api("数据导出明细集合")
public class ExportProject extends BaseAPS {
    private static final long serialVersionUID = -7281303629295174330L;
    @Column(name="NAME")
    @ApiParam(value ="标识名")
    private String name;

    @Column(name="LINK_ID")
    @ApiParam(value ="数据连接对象")
    @FieldAnnotation(relation = "Link", notEmpty = true)
    private Long linkId;

    @ApiParam(value ="当前执行的明细序号")
    private transient Integer curDetailNumber;

    @ApiParam(value ="当前执行的明细名称")
    private transient String curDetailName;

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

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

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