package com.ifish.entity;

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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ifish.enums.GoldGetTypeEnum;
import com.ifish.serializer.CustomDateSerializer;

/**
 * 获取金币记录
 * @author Administrator
 *
 */
@Entity
@Table(name="tbl_gold_get_record")
public class GoldGetRecord implements Serializable{
	
	private static final long serialVersionUID = 8682996968614095485L;
	/**
	 * 记录ID
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="record_id")
	private Integer recordId;
	/**
	 * 用户ID
	 */
	@Column(name="user_id",nullable=false)
	private Integer userId;
	/**
	 * 获取方式
	 */
	@Column(name="get_type",nullable=false,length=20)
	private String ruleType;
	/**
	 * 金币值
	 */
	@Column(name="get_value",nullable=false,precision=3,scale=2)
	private BigDecimal addValue;
	/**
	 * 问题ID
	 */
	@Column(name="relation_id")
	private Integer relationId;
	/**
	 * 记录描述
	 */
	@Column(name="record_remark",nullable=false,length=50)
	private String recordRemark;
	/**
	 * 创建时间
	 */
	@JsonSerialize(using = CustomDateSerializer.class)
	@Column(name="create_time",nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;
	
	public GoldGetRecord() {}
	
	public GoldGetRecord(Integer userId, String ruleType,
			BigDecimal addValue, String recordRemark) {
		this.userId = userId;
		this.ruleType = ruleType;
		this.addValue = addValue;
		this.recordRemark = recordRemark;
		this.createTime = new Date();
	}
	public GoldGetRecord(Integer userId,BigDecimal addValue,GoldGetTypeEnum goldGetTypeEnum) {
		this.userId = userId;
		this.addValue = addValue;
		this.ruleType = goldGetTypeEnum.getKey();
		this.recordRemark = goldGetTypeEnum.getValue();
		this.createTime = new Date();
	}
	
	public Integer getRecordId() {
		return recordId;
	}
	public void setRecordId(Integer recordId) {
		this.recordId = recordId;
	}
	public String getRecordRemark() {
		return recordRemark;
	}
	public void setRecordRemark(String recordRemark) {
		this.recordRemark = recordRemark;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	public String getRuleType() {
		return ruleType;
	}
	public void setRuleType(String ruleType) {
		this.ruleType = ruleType;
	}
	public BigDecimal getAddValue() {
		return addValue;
	}
	public void setAddValue(BigDecimal addValue) {
		this.addValue = addValue;
	}
	public Integer getRelationId() {
		return relationId;
	}

	public void setRelationId(Integer relationId) {
		this.relationId = relationId;
	}


}
