package org.cs.mgr.product.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Version;
import java.util.HashMap;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Date;
import org.cs.core.model.BaseEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 产品分类 
 * 产品有两级分类，一级和二级
 * @ClassName: MgmProductCategory 
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:09
 */
@Table(name = "mgm_product_category")
@Entity
@DynamicInsert
@DynamicUpdate
public class MgmProductCategory extends  BaseEntity {

    private static final Class<MgmProductCategory> ENTITY_CLASS = MgmProductCategory.class;
    
	public MgmProductCategory()
	{
	}

	@Id
	@SequenceGenerator(name="TB_MGM_PROJUCT_CATEGORY",sequenceName="PROJUCT_CATEGORY_SEQ")
	@GeneratedValue(generator="TB_MGM_PROJUCT_CATEGORY",strategy=GenerationType.SEQUENCE)
	@Column(name = "id", unique = true, nullable = false, precision = 11, scale = 0)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	/** 分类名称  */
	private String gcName;  
	/** 父ID  */
	private Integer gcParentId;  
	/** 分类图片，预留字段  */
	private String gcIcon;  
	/** 排序,越小越向前  */
	private Integer gcSort;  
	/** 关键字  */
	private String gcKeywords;  
	/** 描述  */
	private String gcDesc;  
	
	private Integer num;//分类当前数值（从零开始）
	
	private String type;//type="1" 地产2级分类   type="2" 产品2级分类  3产品三级分类
	
	private String twoType;//twoType 2级类目的级数 （2，3）
    private String showName;//微信，ios，android端类别查询展示  //非地产项目2级分类
    private Integer projectId;// type = "1"时有值，地产对应的地产项目

    
    @Column(name = "num",columnDefinition="INT default 0")
    public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	@Column(name = "show_name", columnDefinition="VARCHAR2(255) " )
	public String getShowName() {
		return showName;
	}

	public void setShowName(String showName) {
		this.showName = showName;
	}

	@Column(name = "two_type", columnDefinition="VARCHAR2(2) " )
	public String getTwoType() {
		return twoType;
	}

	public void setTwoType(String twoType) {
		this.twoType = twoType;
	}

	@Column(name = "type", columnDefinition="VARCHAR2(2) " )
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name = "project_id",columnDefinition="INT default 0")
	public Integer getProjectId() {
		return projectId;
	}

	public void setProjectId(Integer projectId) {
		this.projectId = projectId;
	}
    

	@Column(name = "gc_name", columnDefinition="VARCHAR2(20) " )
	public String getGcName()
	{
		return gcName;
	}
	
	public void setGcName(String gcName)
	{
		this.gcName= gcName;
	}
	
	
	@Column(name = "gc_parent_id", columnDefinition="NUMBER " )
	public Integer getGcParentId()
	{
		return gcParentId;
	}
	
	public void setGcParentId(Integer gcParentId)
	{
		this.gcParentId= gcParentId;
	}
	
	
	@Column(name = "gc_icon", columnDefinition="VARCHAR2(100) " )
	public String getGcIcon()
	{
		return gcIcon;
	}
	
	public void setGcIcon(String gcIcon)
	{
		this.gcIcon= gcIcon;
	}
	
	
	@Column(name = "gc_sort", columnDefinition="NUMBER(3) " )
	public Integer getGcSort()
	{
		return gcSort;
	}
	
	public void setGcSort(Integer gcSort)
	{
		this.gcSort= gcSort;
	}
	
	
	@Column(name = "gc_keywords", columnDefinition="VARCHAR2(50) " )
	public String getGcKeywords()
	{
		return gcKeywords;
	}
	
	public void setGcKeywords(String gcKeywords)
	{
		this.gcKeywords= gcKeywords;
	}
	
	
	@Column(name = "gc_desc", columnDefinition="VARCHAR2(200) " )
	public String getGcDesc()
	{
		return gcDesc;
	}
	
	public void setGcDesc(String gcDesc)
	{
		this.gcDesc= gcDesc;
	}
	
	
	 
	public Class entityClass()
	{
		return ENTITY_CLASS;
	}
	
	
 	protected StringBuilder toStringBuilder(StringBuilder sb)
 	{
 		return sb 
		.append(",id=").append(this.id)
		.append(",gcName=").append(this.gcName)
		.append(",gcParentId=").append(this.gcParentId)
		.append(",gcIcon=").append(this.gcIcon)
		.append(",gcSort=").append(this.gcSort)
		.append(",gcKeywords=").append(this.gcKeywords)
		.append(",gcDesc=").append(this.gcDesc)
		.append(",attr1=").append(this.attr1)
		.append(",attr2=").append(this.attr2)
		.append(",attr3=").append(this.attr3)
		.append(",createDate=").append(this.createDate)
		.append(",modifyDate=").append(this.modifyDate)
		.append(",isDelete=").append(this.isDelete)
		;
 	}
 	
 	
 	@Override
	public String toString()
	{
		return toStringBuilder(new StringBuilder().append("MgmProductCategory[")).append(']').toString();
	}
	 
	
	public Map<String,Object> mapValue()
	{
	    Map<String,Object> map=new HashMap<String,Object>();
	     if(this.id!=null){ map.put("id",this.id);}
	     if(this.gcName!=null){ map.put("gcName",this.gcName);}
	     if(this.gcParentId!=null){ map.put("gcParentId",this.gcParentId);}
	     if(this.gcIcon!=null){ map.put("gcIcon",this.gcIcon);}
	     if(this.gcSort!=null){ map.put("gcSort",this.gcSort);}
	     if(this.gcKeywords!=null){ map.put("gcKeywords",this.gcKeywords);}
	     if(this.gcDesc!=null){ map.put("gcDesc",this.gcDesc);}
		 if(this.attr1 !=null){ map.put("attr1", this.attr1);}
		 if(this.attr2 !=null){ map.put("attr2", this.attr2);}
		 if(this.attr3 !=null){ map.put("attr3", this.attr3);}
		 if(this.createDate != null){ map.put("createDate", this.createDate);}
		 if(this.modifyDate != null){ map.put("modifyDate", this.modifyDate);}
		 if(this.isDelete != null){ map.put("isDelete", this.isDelete);}
		return map;
	}
	
	public void mergeTo(MgmProductCategory en)
	{
		  if(this.id !=null){ en.setId(this.id);}
		  if(this.gcName !=null){ en.setGcName(this.gcName);}
		  if(this.gcParentId !=null){ en.setGcParentId(this.gcParentId);}
		  if(this.gcIcon !=null){ en.setGcIcon(this.gcIcon);}
		  if(this.gcSort !=null){ en.setGcSort(this.gcSort);}
		  if(this.gcKeywords !=null){ en.setGcKeywords(this.gcKeywords);}
		  if(this.gcDesc !=null){ en.setGcDesc(this.gcDesc);}
		  if(this.attr1!=null){ en.setAttr1(this.attr1);}
		  if(this.attr2!=null){ en.setAttr2(this.attr2);}
		  if(this.attr3!=null){ en.setAttr3(this.attr3);}
		  if(this.createDate != null){ en.setCreateDate(this.createDate);}
		  if(this.modifyDate != null){ en.setModifyDate(this.modifyDate);}
		  if(this.isDelete != null){ en.setIsDelete(this.isDelete);}
	}
	
  	@Override
  	public void copyFrom(Object obj)
  	{  
  		 if(!(obj instanceof MgmProductCategory)) {
  	 		super.copyFrom(obj);
  	 	}else {
  	  		MgmProductCategory bean=(MgmProductCategory)obj;
			this.setId(bean.getId());
			this.setGcName(bean.getGcName());
			this.setGcParentId(bean.getGcParentId());
			this.setGcIcon(bean.getGcIcon());
			this.setGcSort(bean.getGcSort());
			this.setGcKeywords(bean.getGcKeywords());
			this.setGcDesc(bean.getGcDesc());
     	this.setAttr1(bean.getAttr1());
     	this.setAttr2(bean.getAttr2());
     	this.setAttr3(bean.getAttr3());
     	this.setCreateDate(bean.getCreateDate());
     	this.setModifyDate(bean.getModifyDate());
     	this.setIsDelete(bean.getIsDelete());
     	}
 	 }
}
