/*CopyRright (c)2014: <www.usoftchina.com>
 */
package com.uas.platform.b2b.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Cacheable;
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 javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.uas.platform.core.model.Constant;

/**
 * 企业信息
 * 
 * @author yingp
 */
@Entity
@Table(name = "sec$enterprises")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "com.uas.platform.b2b.model.Enterprise")
public class Enterprise implements Serializable {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "enterprises_gen")
	@SequenceGenerator(name = "enterprises_gen", sequenceName = "enterprises_seq", allocationSize = 1)
	@Column(name = "en_uu")
	private Long uu;
	/**
	 * 公司名称
	 */
	@NotNull
	@Column(name = "en_name")
	private String enName;
	/**
	 * 简称
	 */
	@Column(name = "en_shortname")
	private String enShortname;
	/**
	 * 公司类型
	 */
	@Column(name = "en_type")
	private String enType;
	/**
	 * 状态
	 */
	@Column(name = "en_status")
	private String enStatus;
	/**
	 * 注册地址
	 */
	@Column(name = "en_address")
	private String enAddress;
	/**
	 * 默认送货地址
	 */
	@Column(name = "en_deliveraddr")
	private String enDeliverAddr;
	/**
	 * 公司电话
	 */
	@Column(name = "en_tel")
	private String enTel;
	/**
	 * 传真
	 */
	@Column(name = "en_fax")
	private String enFax;
	/**
	 * 公司邮箱
	 */
	@Column(name = "en_email")
	private String enEmail;
	/**
	 * 公司法人
	 */
	@Column(name = "en_corporation")
	private String enCorporation;
	/**
	 * 商业登记证号
	 */
	@Column(name = "en_businesscode")
	private String enBussinessCode;
	/**
	 * 营业执照图片路径id
	 */
	@OneToOne(cascade = { CascadeType.ALL })
	@JoinColumn(name = "en_bussinesscodeattach")
	private Attach enBussinessCodeAttach;
	/**
	 * 纳税人识别号
	 */
	@Column(name = "en_taxcode")
	private String enTaxcode;
	/**
	 * 注册资本
	 */
	@Column(name = "en_registercapital")
	private String enRegistercapital;
	/**
	 * 公司主页地址
	 */
	@Column(name = "en_url")
	private String enUrl;
	/**
	 * 注册时间
	 */
	@Column(name = "en_time")
	private Date enDate;

	/**
	 * 管理员
	 */
	@Column(name = "en_adminuu")
	private Long enAdminuu;

	@Transient
	private User admin;
	
	@Transient
	private Long enBussinesscodeImg;
	
	@Transient
	private String enAdminTel;
	
	@Transient
	private String enAdminEmail;

	public Long getEnAdminuu() {
		return enAdminuu;
	}

	public void setEnAdminuu(Long enAdminuu) {
		this.enAdminuu = enAdminuu;
	}

	private Short enable;

	public Long getUu() {
		return uu;
	}

	public void setUu(Long uu) {
		this.uu = uu;
	}

	public String getEnName() {
		return enName;
	}

	public void setEnName(String enName) {
		this.enName = enName;
	}

	public String getEnShortname() {
		return enShortname;
	}

	public void setEnShortname(String enShortname) {
		this.enShortname = enShortname;
	}

	public String getEnType() {
		return enType;
	}

	public void setEnType(String enType) {
		this.enType = enType;
	}

	public String getEnStatus() {
		return enStatus;
	}

	public void setEnStatus(String enStatus) {
		this.enStatus = enStatus;
	}

	public String getEnAddress() {
		return enAddress;
	}

	public void setEnAddress(String enAddress) {
		this.enAddress = enAddress;
	}

	public String getEnDeliverAddr() {
		return enDeliverAddr;
	}

	public void setEnDeliverAddr(String enDeliverAddr) {
		this.enDeliverAddr = enDeliverAddr;
	}

	public String getEnTel() {
		return enTel;
	}

	public void setEnTel(String enTel) {
		this.enTel = enTel;
	}

	public String getEnFax() {
		return enFax;
	}

	public void setEnFax(String enFax) {
		this.enFax = enFax;
	}

	public String getEnCorporation() {
		return enCorporation;
	}

	public void setEnCorporation(String enCorporation) {
		this.enCorporation = enCorporation;
	}

	public String getEnBussinessCode() {
		return enBussinessCode;
	}

	public void setEnBussinessCode(String enBussinessCode) {
		this.enBussinessCode = enBussinessCode;
	}

	public String getEnTaxcode() {
		return enTaxcode;
	}

	public void setEnTaxcode(String enTaxcode) {
		this.enTaxcode = enTaxcode;
	}

	public String getEnRegistercapital() {
		return enRegistercapital;
	}

	public void setEnRegistercapital(String enRegistercapital) {
		this.enRegistercapital = enRegistercapital;
	}

	public String getEnUrl() {
		return enUrl;
	}

	public void setEnUrl(String enUrl) {
		this.enUrl = enUrl;
	}

	public Date getEnDate() {
		return enDate;
	}

	public void setEnDate(Date enDate) {
		this.enDate = enDate;
	}

	public User getAdmin() {
		return admin;
	}

	public void setAdmin(User admin) {
		this.admin = admin;
	}

	public Short getEnable() {
		return enable;
	}

	public void setEnable(Short enable) {
		this.enable = enable;
	}

	public String getEnEmail() {
		return enEmail;
	}

	public void setEnEmail(String enEmail) {
		this.enEmail = enEmail;
	}

	public Attach getEnBussinessCodeAttach() {
		return enBussinessCodeAttach;
	}

	public void setEnBussinessCodeAttach(Attach enBussinessCodeAttach) {
		this.enBussinessCodeAttach = enBussinessCodeAttach;
	}

	public String getEnAdminTel() {
		return enAdminTel;
	}

	public void setEnAdminTel(String enAdminTel) {
		this.enAdminTel = enAdminTel;
	}

	public String getEnAdminEmail() {
		return enAdminEmail;
	}

	public void setEnAdminEmail(String enAdminEmail) {
		this.enAdminEmail = enAdminEmail;
	}

	public Long getEnBussinesscodeImg() {
		return enBussinesscodeImg;
	}

	public void setEnBussinesscodeImg(Long enBussinesscodeImg) {
		this.enBussinesscodeImg = enBussinesscodeImg;
	}

	@JsonIgnore
	public boolean isEnabled() {
		return this.getEnable() != null && this.getEnable() == Constant.YES;
	}
}
