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

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

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

/**
 * 物品信息表(用于建立物料搜索索引)
 * 
 */
@Entity
@Table(name = ProdSimpleInfo.TABLE_NAME)
public class ProdSimpleInfo {

	public static final String TABLE_NAME = "PRODUCTS";

	public static final String ID_FIELD = "pr_id";

	public static final String ENTERPRISE_FIELD = "pr_enuu";

	public static final String CODE_FIELD = "pr_code";

	public static final String TITLE_FIELD = "pr_title";

	public static final String SPEC_FIELD = "pr_spec";

	public static final String BRAND_FIELD = "pr_brand";

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

	/**
	 * 物料所属企业UU
	 */
	@OneToOne
	@JoinColumn(name = ENTERPRISE_FIELD, insertable = false, updatable = false)
	private EnterpriseSimpleInfo enterprise;

	/**
	 * 物料编号
	 * 
	 */
	@Column(name = CODE_FIELD)
	private String prodCode;

	/**
	 * 物料名称
	 */
	@Column(name = TITLE_FIELD)
	private String prodTitle;

	/**
	 * 物料规格
	 */
	@Column(name = SPEC_FIELD)
	private String prodSpec;

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

	public Long getId() {
		return id;
	}

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

	public EnterpriseSimpleInfo getEnterprise() {
		return enterprise;
	}

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

	public String getProdCode() {
		return prodCode;
	}

	public void setProdCode(String prodCode) {
		this.prodCode = prodCode;
	}

	public String getProdTitle() {
		return prodTitle;
	}

	public void setProdTitle(String prodTitle) {
		this.prodTitle = prodTitle;
	}

	public String getProdSpec() {
		return prodSpec;
	}

	public void setProdSpec(String prodSpec) {
		this.prodSpec = prodSpec;
	}

	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(ENTERPRISE_FIELD);
		fields.add(TITLE_FIELD);
		fields.add(SPEC_FIELD);
		fields.add(BRAND_FIELD);
		return fields;
	}

	@Override
	public String toString() {
		return "ProdSimpleInfo [id=" + id + ", enterprise=" + enterprise + ", prodCode=" + prodCode + ", prodTitle="
				+ prodTitle + ", prodSpec=" + prodSpec + ", brand=" + brand + "]";
	}

}
