package org.cs.mgr.setting.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: SysAdv 
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:15
 */
@Table(name = "sys_adv")
@Entity
@DynamicInsert
@DynamicUpdate
public class SysAdv extends  BaseEntity {

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

	/** 对应广告位  */
	private Integer apId;  
	/** 广告描述  */
	private String advTitle;  
	/** 广告内容  */
	private String advContent;  
	/** 广告连接类型  */
	private String advType; //1 有url连接 2 单广告图片 
	/** 链接地址  */
	private String advSrc;
	/** 广告图片 */
	private String advPic;
	
	/** 广告排序*/
	private String advSort;
	
	/**是否公开*/
	private Boolean openFlag;

	@Id
	@SequenceGenerator(name="TB_MGM_PRODUCT",sequenceName="ADV_SEQ")
	@GeneratedValue(generator="TB_MGM_PRODUCT",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 = "adv_sort", columnDefinition="VARCHAR2(15) " )
	public String getAdvSort() {
		return advSort;
	}
	public void setAdvSort(String advSort) {
		this.advSort = advSort;
	}
	@Column(name = "adv_pic", columnDefinition="VARCHAR2(300) " )
	public String getAdvPic() {
		return advPic;
	}
	public void setAdvPic(String advPic) {
		this.advPic = advPic;
	}
	@Column(name = "ap_id", columnDefinition="NUMBER " )
	public Integer getApId()
	{
		return apId;
	}
	
	public void setApId(Integer apId)
	{
		this.apId= apId;
	}
	
	
	@Column(name = "adv_title", columnDefinition="VARCHAR2(100) " )
	public String getAdvTitle()
	{
		return advTitle;
	}
	
	public void setAdvTitle(String advTitle)
	{
		this.advTitle= advTitle;
	}
	
	
	@Column(name = "adv_content", columnDefinition="VARCHAR2(1000) " )
	public String getAdvContent()
	{
		return advContent;
	}
	
	public void setAdvContent(String advContent)
	{
		this.advContent= advContent;
	}
	
	
	@Column(name = "adv_type", columnDefinition="VARCHAR2(20) " )
	public String getAdvType()
	{
		return advType;
	}
	
	public void setAdvType(String advType)
	{
		this.advType= advType;
	}
	
	
	@Column(name = "adv_src", columnDefinition="VARCHAR2(100) " )
	public String getAdvSrc()
	{
		return advSrc;
	}
	
	public void setAdvSrc(String advSrc)
	{
		this.advSrc= advSrc;
	}
	
	@Column(name="open_flag", nullable = false, columnDefinition="number(1) default 0")
	public Boolean getOpenFlag() {
		return openFlag;
	}

	public void setOpenFlag(Boolean openFlag) {
		this.openFlag = openFlag;
	}
	 
	public Class entityClass()
	{
		return ENTITY_CLASS;
	}
	
	
 	protected StringBuilder toStringBuilder(StringBuilder sb)
 	{
 		return sb 
		.append(",id=").append(this.id)
		.append(",apId=").append(this.apId)
		.append(",advTitle=").append(this.advTitle)
		.append(",advContent=").append(this.advContent)
		.append(",advType=").append(this.advType)
		.append(",advSrc=").append(this.advSrc)
		.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("SysAdv[")).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.apId!=null){ map.put("apId",this.apId);}
	     if(this.advTitle!=null){ map.put("advTitle",this.advTitle);}
	     if(this.advContent!=null){ map.put("advContent",this.advContent);}
	     if(this.advType!=null){ map.put("advType",this.advType);}
	     if(this.advSrc!=null){ map.put("advSrc",this.advSrc);}
		 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(SysAdv en)
	{
		  if(this.id !=null){ en.setId(this.id);}
		  if(this.apId !=null){ en.setApId(this.apId);}
		  if(this.advTitle !=null){ en.setAdvTitle(this.advTitle);}
		  if(this.advContent !=null){ en.setAdvContent(this.advContent);}
		  if(this.advType !=null){ en.setAdvType(this.advType);}
		  if(this.advSrc !=null){ en.setAdvSrc(this.advSrc);}
		  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 SysAdv)) {
  	 		super.copyFrom(obj);
  	 	}else {
  	  		SysAdv bean=(SysAdv)obj;
			this.setId(bean.getId());
			this.setApId(bean.getApId());
			this.setAdvTitle(bean.getAdvTitle());
			this.setAdvContent(bean.getAdvContent());
			this.setAdvType(bean.getAdvType());
			this.setAdvSrc(bean.getAdvSrc());
     	this.setAttr1(bean.getAttr1());
     	this.setAttr2(bean.getAttr2());
     	this.setAttr3(bean.getAttr3());
     	this.setCreateDate(bean.getCreateDate());
     	this.setModifyDate(bean.getModifyDate());
     	this.setIsDelete(bean.getIsDelete());
     	}
 	 }
}
