package org.cs.mgr.product.model;
import java.util.HashMap;
import java.util.Map;

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

import org.cs.core.model.BaseEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 产品浏览数量 
 * 
 * @ClassName: MgmProductView 
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:10
 */
@Table(name = "mgm_product_view")
@Entity
@DynamicInsert
@DynamicUpdate
public class MgmProductView extends  BaseEntity {

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

	@Id
	@SequenceGenerator(name="TB_MGM_PRODUCT_VIEW",sequenceName="PRODUCT_VIEW_SEQ")
	@GeneratedValue(generator="TB_MGM_PRODUCT_VIEW",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 Integer userId;  
	/** 浏览产品  */
	private Integer productId;  
	/** 浏览时间  */
	private java.util.Date viewTime; 
	
	//ip
	private String ip;
	
	@Column(name = "ip", columnDefinition="VARCHAR2(50)" )
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@Column(name = "user_id", columnDefinition="NUMBER" )
	public Integer getUserId()
	{
		return userId;
	}
	
	public void setUserId(Integer userId)
	{
		this.userId= userId;
	}
	
	
	@Column(name = "product_id", columnDefinition="NUMBER " )
	public Integer getProductId()
	{
		return productId;
	}
	
	public void setProductId(Integer productId)
	{
		this.productId= productId;
	}
	
	
	@Column(name = "view_time", columnDefinition="DATE " )
	public java.util.Date getViewTime()
	{
		return viewTime;
	}
	
	public void setViewTime(java.util.Date viewTime)
	{
		this.viewTime= viewTime;
	}
	
	
	 
	public Class entityClass()
	{
		return ENTITY_CLASS;
	}
	
	
 	protected StringBuilder toStringBuilder(StringBuilder sb)
 	{
 		return sb 
		.append(",id=").append(this.id)
		.append(",userId=").append(this.userId)
		.append(",productId=").append(this.productId)
		.append(",viewTime=").append(this.viewTime)
		.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("MgmProductView[")).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.userId!=null){ map.put("userId",this.userId);}
	     if(this.productId!=null){ map.put("productId",this.productId);}
	     if(this.viewTime!=null){ map.put("viewTime",this.viewTime);}
		 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(MgmProductView en)
	{
		  if(this.id !=null){ en.setId(this.id);}
		  if(this.userId !=null){ en.setUserId(this.userId);}
		  if(this.productId !=null){ en.setProductId(this.productId);}
		  if(this.viewTime !=null){ en.setViewTime(this.viewTime);}
		  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 MgmProductView)) {
  	 		super.copyFrom(obj);
  	 	}else {
  	  		MgmProductView bean=(MgmProductView)obj;
			this.setId(bean.getId());
			this.setUserId(bean.getUserId());
			this.setProductId(bean.getProductId());
			this.setViewTime(bean.getViewTime());
     	this.setAttr1(bean.getAttr1());
     	this.setAttr2(bean.getAttr2());
     	this.setAttr3(bean.getAttr3());
     	this.setCreateDate(bean.getCreateDate());
     	this.setModifyDate(bean.getModifyDate());
     	this.setIsDelete(bean.getIsDelete());
     	}
 	 }
}
