package com.uas.platform.b2b.model;

import java.io.Serializable;

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

import com.uas.platform.core.persistence.Logger;
import com.uas.platform.core.persistence.OtherUserUU;
import com.uas.platform.core.persistence.StatusColumn;
import com.uas.platform.core.persistence.UserUU;

@Entity
@Table(name = "purc$vendors")
@Logger(enUU = "ve_myenuu", userUU = "ve_myuseruu")
public class Vendor implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "purc$vendors_gen")
	@SequenceGenerator(name = "purc$vendors_gen", sequenceName = "purc$vendors_seq", allocationSize = 1)
	@Column(name = "ve_id")
	private Long id;

	/**
	 * 状态
	 */
	@Column(name = "ve_status")
	@StatusColumn
	private Integer status;

	/**
	 * 我的企业UU
	 */
	@Column(name = "ve_myenuu")
	private Long myEnUU;

	/**
	 * 我的UU
	 */
	@Column(name = "ve_myuseruu")
	@UserUU
	private Long myUserUU;

	@Column(name = "ve_vendenuu")
	private Long vendEnUU;

	/**
	 * 供应商的企业UU
	 */
	@OneToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE })
	@JoinColumn(name = "ve_vendenuu", insertable = false, updatable = false)
	private Enterprise vendorEnterprise;

	@Column(name = "ve_venduseruu")
	private Long vendUserUU;

	/**
	 * 供应商联系人UU
	 */
	@OneToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE })
	@JoinColumn(name = "ve_venduseruu", insertable = false, updatable = false)
	@OtherUserUU
	private User vendorUser;

	public Long getId() {
		return id;
	}

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

	public Integer getStatus() {
		return status;
	}

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

	public Long getMyEnUU() {
		return myEnUU;
	}

	public void setMyEnUU(Long myEnUU) {
		this.myEnUU = myEnUU;
	}

	public Long getMyUserUU() {
		return myUserUU;
	}

	public void setMyUserUU(Long myUserUU) {
		this.myUserUU = myUserUU;
	}

	public Enterprise getVendorEnterprise() {
		return vendorEnterprise;
	}

	public void setVendorEnterprise(Enterprise vendorEnterprise) {
		this.vendorEnterprise = vendorEnterprise;
	}

	public User getVendorUser() {
		return vendorUser;
	}

	public void setVendorUser(User vendorUser) {
		this.vendorUser = vendorUser;
	}

	public Long getVendEnUU() {
		return vendEnUU;
	}

	public void setVendEnUU(Long vendEnUU) {
		this.vendEnUU = vendEnUU;
	}

	public Long getVendUserUU() {
		return vendUserUU;
	}

	public void setVendUserUU(Long vendUserUU) {
		this.vendUserUU = vendUserUU;
	}

	@Override
	public String toString() {
		return this.vendorEnterprise.getEnName();
	}

}
