package com.bocloud.ims.entity.common;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.common.utils.DateDeserializer;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 服务使用记录
 * 
 * @author Administrator
 *
 */
@Table("service_usage")
public class ServiceUsage {
	// id
	@PK(value = PKStrategy.AUTO)
	private Long id;

	@Column("gmt_create")
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtCreate;

	/**
	 * 服务id
	 */
	@Column("service_id")
	private Long serviceId;

	/**
	 * 用户id
	 */
	@Column("creater_id")
	private Long createrId;

	/**
	 * 用户名称
	 */
	@IgnoreAll
	private String userName;

	/**
	 * 租户名称
	 */
	@IgnoreAll
	private String tenantName;

	public ServiceUsage() {
		super();
	}

	public ServiceUsage(Date gmtCreate, Long serviceId, Long createrId) {
		super();
		this.gmtCreate = gmtCreate;
		this.serviceId = serviceId;
		this.createrId = createrId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getGmtCreate() {
		return gmtCreate;
	}

	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}

	public Long getServiceId() {
		return serviceId;
	}

	public void setServiceId(Long serviceId) {
		this.serviceId = serviceId;
	}

	public Long getCreaterId() {
		return createrId;
	}

	public void setCreaterId(Long createrId) {
		this.createrId = createrId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getTenantName() {
		return tenantName;
	}

	public void setTenantName(String tenantName) {
		this.tenantName = tenantName;
	}

	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}
}
