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.EImportDetail;
import cn.estsh.i3plus.pojo.base.enumutil.ApsEnumUtil;
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;

/**
 * @Description :数据导入明细
 * @Reference :
 * @Author : jason.niu
 * @CreateDate : 2019-09-23
 * @Modify:
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "APS_IMPORT_DETAIL")
@Api("数据导入明细")
public class ImportDetail extends BaseAPS {

    private static final long serialVersionUID = 1264030397500660450L;
    @Column(name="OUT_NAME")
    @ApiParam(value ="外部表名")
    private String outName;

    @Column(name="IN_NAME")
    @ApiParam(value ="内部表名")
    private String inName;

    @Column(name="IMPORT_TYPE")
    @ApiParam(value ="导入类型")
    @FieldAnnotation(defaultValue = "REPLACE")
    private ApsEnumUtil.IMPORT_DETAIL_TYPE importType;

    @Column(name="SKIP_ROWS")
    @ApiParam(value ="跳过行数")
    @FieldAnnotation(defaultValue = "0")
    private Integer skipRows;

    @Column(name="ORDER_NUMBER")
    @ApiParam(value ="序号")
    @FieldAnnotation(property = false)
    private Integer orderNumber;

    @Column(name="PROJECT_ID")
    @ApiParam(value ="导入项目ID")
    @FieldAnnotation(relation = "Project")
    private Long projectId;

    public ImportProject getProject() {
        return BeanRelation.get(this, EImportDetail.Project);
    }

    public void setProject(ImportProject project) {
        this.projectId = project != null ? project.getId() : 0l;
        BeanRelation.set(this, EImportDetail.Project, project);
    }
}
