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

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

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

/**
 * 简单的器件索引
 * 
 * @author hejq
 * @time 创建时间：2016年12月28日
 */
@Entity
@Table(name = ProductComponentSimpleInfo.TABLE_NAME)
public class ProductComponentSimpleInfo {

	/**
	 * 表名
	 */
	public static final String TABLE_NAME = "PRODUCT$COMPONENT";

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

	public static final String CODE_FIELD = "cmp_code";

	public static final String UUID_FIELD = "cmp_uuid";

	public static final String BRAND_FIELD = "cmp_brid";

	public static final String KINDID_FIELD = "cmp_kiid";
	/**
	 * id
	 */
	@Id
	@Column(name = ID_FIELD)
	private Long id;

	/**
	 * 器件的uuid
	 */
	@Column(name = UUID_FIELD, unique = true, nullable = false)
	private String uuid;

	/**
	 * 原厂型号
	 */
	@Column(name = CODE_FIELD)
	private String code;

	/**
	 * 器件的品牌
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = BRAND_FIELD, insertable = false, updatable = false)
	private BrandSimpleInfo brand;

	/**
	 * 类目id
	 */
	@Column(name = KINDID_FIELD)
	private Long kindid;
	
	public Long getId() {
		return id;
	}

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

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getCode() {
		return code;
	}

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

	public BrandSimpleInfo getBrand() {
		return brand;
	}

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

	public Long getKindid() {
		return kindid;
	}

	public void setKindid(Long kindid) {
		this.kindid = kindid;
	}

	@Override
	public String toString() {
		return "ProductComponentSimpleInfo [id=" + id + ", uuid=" + uuid + ", code=" + code + ", brand=" + brand
				+ ", kindid=" + kindid + "]";
	}

	/**
	 * 获取除了status外的所有字段的列名（field名）
	 * 
	 * @return
	 */
	public static List<String> getKeywordFields() {
		List<String> fields = new ArrayList<>();
		fields.add(CODE_FIELD);
		fields.add(UUID_FIELD);
		fields.add(BRAND_FIELD);
		fields.add(KINDID_FIELD);
		return fields;
	}
}
