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 = "sale$customers")
@Logger(enUU = "cu_myenuu", userUU = "cu_myuseruu")
public class Customer implements Serializable {

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

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "cu_id")
	private Long id;

	/**
	 * 我的企业UU
	 */
	@Column(name = "cu_myenuu", nullable = false)
	private Long myEnUU;

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

	/**
	 * 客户企业UU
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "cu_custenuu", nullable = false)
	private Enterprise customerEnterprise;

	/**
	 * 客户联系人UU
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "cu_custuseruu", nullable = false)
	@OtherUserUU
	private UserBaseInfo customerUser;

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

	public Long getId() {
		return id;
	}

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

	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 getCustomerEnterprise() {
		return customerEnterprise;
	}

	public void setCustomerEnterprise(Enterprise customerEnterprise) {
		this.customerEnterprise = customerEnterprise;
	}

	public UserBaseInfo getCustomerUser() {
		return customerUser;
	}

	public void setCustomerUser(UserBaseInfo customerUser) {
		this.customerUser = customerUser;
	}

	public Integer getStatus() {
		return status;
	}

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

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