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

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * 平台里面，供应商针对客户打样申请的送样单
 * 
 * @author suntg
 *
 */
@Table(name = PurcProofingsendSimpleInfo.TABLE_NAME)
@Entity
public class PurcProofingsendSimpleInfo {

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

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

	public static final String CODE_FIELD = "pps_code";

	public static final String DATE_FIELD = "pps_date";

	public static final String ITEMS_FIELD = "pps_itemid";

	public static final String BRAND_FIELD = "pps_brand";
	@Id
	@Column(name = ID_FIELD)
	private Long id;

	/**
	 * 送样单号
	 */
	@Column(name = CODE_FIELD)
	private String code;

	/**
	 * 日期
	 */
	@Column(name = DATE_FIELD)
	private Date date;

	/**
	 * 客户打样申请
	 */
	@OneToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.EAGER)
	@JoinColumn(name = ITEMS_FIELD, insertable = false, updatable = false)
	private PurchaseProofingItemSimpleInfo proofingItem;

	/**
	 * 品牌
	 */
	@Column(name = BRAND_FIELD)
	private String brand;

	public Long getId() {
		return id;
	}

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

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Date getDate() {
		return date;
	}

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

	public PurchaseProofingItemSimpleInfo getProofingItem() {
		return proofingItem;
	}

	public void setProofingItem(PurchaseProofingItemSimpleInfo proofingItem) {
		this.proofingItem = proofingItem;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

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

	@Override
	public String toString() {
		return "PurcProofingsendSimpleInfo [id=" + id + ", code=" + code + ", date=" + date + ", proofingItem="
				+ proofingItem + ", brand=" + brand + "]";
	}

}