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.GoldExpendTypeEnum;
import com.ifish.serializer.CustomDateSerializer;

/**
 * 获取金币记录
 * @author Administrator
 *
 */
@Entity
@Table(name="tbl_gold_expend_record")
public class GoldExpendRecord 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="expend_type",nullable=false,length=20)
	private String expendType;
	/**
	 * 消耗值
	 */
	@Column(name="expend_value",nullable=false,precision=6,scale=2)
	private BigDecimal expendValue;
	/**
	 * 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 GoldExpendRecord() {}

	public GoldExpendRecord(Integer userId,BigDecimal expendValue,GoldExpendTypeEnum goldExpendType) {
		this.userId = userId;
		this.expendValue = expendValue;
		this.expendType = goldExpendType.getKey();
		this.recordRemark = goldExpendType.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 getExpendType() {
		return expendType;
	}

	public void setExpendType(String expendType) {
		this.expendType = expendType;
	}

	public BigDecimal getExpendValue() {
		return expendValue;
	}

	public void setExpendValue(BigDecimal expendValue) {
		this.expendValue = expendValue;
	}

	public Integer getRelationId() {
		return relationId;
	}

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

}
