package com.uas.search.console.b2b.model;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 平台里面，以供应商的角度来查看客户打样申请明细
 * 
 * @author suntg
 *
 */
@Table(name = PurchaseProofingItemSimpleInfo.TABLE_NAME)
@Entity
public class PurchaseProofingItemSimpleInfo {

	/**
	 * 表名
	 */
	public static final String TABLE_NAME = "PURC$PROOFINGITEMS";

	/**
	 * 各字段列名（也是存储索引时的field名）
	 */
	public static final String ID_FIELD = "ppi_id";

	public static final String SOURCE_FIELD = "ppi_sourceid";

	public static final String STATUS_FIELD = "ppi_status";

	public static final String VEND_FIELD = "ppi_venduu";

	public static final String PROOFING_FIELD = "ppi_ppid";

	public static final String DATE_FIELD = "ppi_date";

	@Id
	@Column(name = ID_FIELD)
	private Long id;

	/**
	 * 来源（买家ERP采购询价明细）的ID
	 */
	@Column(name = SOURCE_FIELD, updatable = false)
	private Long sourceId;

	/**
	 * 送样状态（未送样 401、已送样 400）
	 */
	@Column(name = STATUS_FIELD)
	private Short status;

	/**
	 * 企业UU
	 */
	@OneToOne
	@JoinColumn(name = VEND_FIELD, insertable = false, updatable = false)
	private EnterpriseSimpleInfo enterprise;

	/**
	 * 客户打样申请
	 */
	@ManyToOne(cascade = CascadeType.ALL, optional = true)
	@JoinColumn(name = PROOFING_FIELD, nullable = false)
	private PurchaseProofingSimpleInfo proofing;

	/**
	 * 录入时间
	 */
	@Column(name = DATE_FIELD)
	private Date date;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getSourceId() {
		return sourceId;
	}

	public void setSourceId(Long sourceId) {
		this.sourceId = sourceId;
	}

	public Short getStatus() {
		return status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	public EnterpriseSimpleInfo getEnterprise() {
		return enterprise;
	}

	public void setEnterprise(EnterpriseSimpleInfo enterprise) {
		this.enterprise = enterprise;
	}

	public PurchaseProofingSimpleInfo getProofing() {
		return proofing;
	}

	public void setProofing(PurchaseProofingSimpleInfo proofing) {
		this.proofing = proofing;
	}

	public Date getDate() {
		return this.getProofing().getDate();
	}

	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * 获取所有可以搜索的字段列名（索引的field名）
	 * 
	 * @return 可以搜索的字段列名
	 */
	public static List<String> getKeywordFields() {
		List<String> fields = new ArrayList<>();
		fields.add(VEND_FIELD);
		fields.add(PROOFING_FIELD);
		return fields;
	}

	@Override
	public String toString() {
		return "PurchaseProofingItemSimpleInfo{" +
				"id=" + id +
				", sourceId=" + sourceId +
				", status=" + status +
				", enterprise=" + enterprise +
				", proofing=" + proofing +
				", date=" + date +
				'}';
	}
}