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;

/**
 * 供应商表<br>
 * (搜索供应商资料)
 * 
 */
@Table(name = VendorSimpleInfo.TABLE_NAME)
@Entity
public class VendorSimpleInfo {

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

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

	public static final String STATUS_FIELD = "ve_status";

	public static final String ENTERPRISE_FIELD = "ve_myenuu";

	public static final String MYUSER_FIELD = "ve_myuseruu";

	public static final String VEND_FIELD = "ve_vendenuu";

	public static final String VENDUSER_FIELD = "ve_venduseruu";

	public static final String VENDSWITCH_FIELD = "ve_vendswitch";

	public static final String CUSTSWITCH_FIELD = "ve_custswitch";

	public static final String SERVICERSWITCH_FIELD = "ve_servicerswitch";

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

	/**
	 * 状态
	 */
	@Column(name = STATUS_FIELD)
	private String status;

	/**
	 * 我方联系人
	 */
	@OneToOne
	@JoinColumn(name = MYUSER_FIELD, insertable = false, updatable = false)
	private UserSimpleInfo myUser;

	/**
	 * 供应商联系人
	 */
	@OneToOne
	@JoinColumn(name = VENDUSER_FIELD, insertable = false, updatable = false)
	private UserSimpleInfo vendUser;

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

	/**
	 * 供应商企业
	 */
	@OneToOne
	@JoinColumn(name = VEND_FIELD, insertable = false, updatable = false)
	private EnterpriseSimpleInfo vend;

	/**
	 * 供应商开关，客户操作，因为是相对的，如果一个条件不能构成约束<br>
	 * 1. 启用<br>
	 * 0. 禁用
	 */
	@Column(name = VENDSWITCH_FIELD)
	private Short vendswitch;

	/**
	 * 服务商开关，供应商操作，因为是相对的，如果一个条件不能构成约束<br>
	 * 1. 启用<br>
	 * 0. 禁用
	 */
	@Column(name = SERVICERSWITCH_FIELD)
	private Short servicerswitch;

	/**
	 * 客户开关，供应商操作，因为是相对的，如果一个条件不能构成约束<br>
	 * 1. 启用<br>
	 * 0. 禁用
	 */
	@Column(name = CUSTSWITCH_FIELD)
	private Short custswitch;

	public Long getId() {
		return id;
	}

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

	public String getStatus() {
		return status;
	}

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

	public UserSimpleInfo getMyUser() {
		return myUser;
	}

	public void setMyUser(UserSimpleInfo myUser) {
		this.myUser = myUser;
	}

	public UserSimpleInfo getVendUser() {
		return vendUser;
	}

	public void setVendUser(UserSimpleInfo vendUser) {
		this.vendUser = vendUser;
	}

	public EnterpriseSimpleInfo getEnterprise() {
		return enterprise;
	}

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

	public EnterpriseSimpleInfo getVend() {
		return vend;
	}

	public void setVend(EnterpriseSimpleInfo vend) {
		this.vend = vend;
	}

	public Short getVendswitch() {
		return vendswitch;
	}

	public void setVendswitch(Short vendswitch) {
		this.vendswitch = vendswitch;
	}

	public Short getCustswitch() {
		return custswitch;
	}

	public void setCustswitch(Short custswitch) {
		this.custswitch = custswitch;
	}

	public Short getServicerswitch() {
		return servicerswitch;
	}

	public void setServicerswitch(Short servicerswitch) {
		this.servicerswitch = servicerswitch;
	}

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

	@Override
	public String toString() {
		return "VendorSimpleInfo [id=" + id + ", status=" + status + ", myUser=" + myUser + ", vendUser=" + vendUser
				+ ", enterprise=" + enterprise + ", vend=" + vend + ", vendswitch=" + vendswitch + ", servicerswitch="
				+ servicerswitch + ", custswitch=" + custswitch + "]";
	}


}