package org.cs.mgr.user.model;
import javax.persistence.*;
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: MgmMessage 
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:28:56
 */
@Table(name = "mgm_message")
@Entity
@DynamicInsert
@DynamicUpdate
public class MgmMessage extends  BaseEntity {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final Class<MgmMessage> ENTITY_CLASS = MgmMessage.class;
    
	public MgmMessage()
	{
	}

	/** 标题  */
	private String title;  
	/** 消息详情  */
	private String content;  
	/** 用户id  */
	private Integer userId;  
	/** 是否已读  */
	private String state;  //0.未读  1.已读

	@Id
	@SequenceGenerator(name="sequenceGenerator",sequenceName="MSG_SEQ")
	@GeneratedValue(generator="sequenceGenerator",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;
	}

	@Column(name = "title", columnDefinition="VARCHAR2(50) " )
	public String getTitle()
	{
		return title;
	}
	
	public void setTitle(String title)
	{
		this.title= title;
	}
	
	
	@Column(name = "content", columnDefinition="VARCHAR2(512) " )
	public String getContent()
	{
		return content;
	}
	
	public void setContent(String content)
	{
		this.content= content;
	}
	
	
	@Column(name = "user_id", columnDefinition="NUMBER " )
	public Integer getUserId()
	{
		return userId;
	}
	
	public void setUserId(Integer userId)
	{
		this.userId= userId;
	}
	
	
	@Column(name = "state", columnDefinition="CHAR(1) " )
	public String getState()
	{
		return state;
	}
	
	public void setState(String state)
	{
		this.state= state;
	}
	
	
	 
	public Class entityClass()
	{
		return ENTITY_CLASS;
	}
	
	
 	protected StringBuilder toStringBuilder(StringBuilder sb)
 	{
 		return sb 
		.append(",id=").append(this.id)
		.append(",title=").append(this.title)
		.append(",content=").append(this.content)
		.append(",userId=").append(this.userId)
		.append(",state=").append(this.state)
		.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("MgmMessage[")).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.title!=null){ map.put("title",this.title);}
	     if(this.content!=null){ map.put("content",this.content);}
	     if(this.userId!=null){ map.put("userId",this.userId);}
	     if(this.state!=null){ map.put("state",this.state);}
		 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(MgmMessage en)
	{
		  if(this.id !=null){ en.setId(this.id);}
		  if(this.title !=null){ en.setTitle(this.title);}
		  if(this.content !=null){ en.setContent(this.content);}
		  if(this.userId !=null){ en.setUserId(this.userId);}
		  if(this.state !=null){ en.setState(this.state);}
		  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 MgmMessage)) {
  	 		super.copyFrom(obj);
  	 	}else {
  	  		MgmMessage bean=(MgmMessage)obj;
			this.setId(bean.getId());
			this.setTitle(bean.getTitle());
			this.setContent(bean.getContent());
			this.setUserId(bean.getUserId());
			this.setState(bean.getState());
     	this.setAttr1(bean.getAttr1());
     	this.setAttr2(bean.getAttr2());
     	this.setAttr3(bean.getAttr3());
     	this.setCreateDate(bean.getCreateDate());
     	this.setModifyDate(bean.getModifyDate());
     	this.setIsDelete(bean.getIsDelete());
     	}
 	 }
}
