/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.lightinit.hsdatagateway.modules.gateway.entity;

import com.google.common.base.Strings;
import com.lightinit.hsdatagateway.common.persistence.DataEntity;
import org.hibernate.validator.constraints.Length;
import com.lightinit.hsdatagateway.modules.sys.entity.User;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.lightinit.hsdatagateway.common.persistence.DataEntity;

/**
 * 计费Entity
 * @Author: yangrui
 * @version 2019-03-05
 */
public class Charge extends DataEntity<Charge> {
	
	private static final long serialVersionUID = 1L;
	private String routeId;		// 路由ID
	private String appId;		// 应用ID
	private String userId;		// 用户ID
	private String chargeMethod;		// 计费方式
	private Long chargeValue;		// 计费值（次数/时长）
	private Long usedValue;		// 已使用值
	private Long restValue;		// 剩余值
	private Date expiredTime;		// 过期时间
	private Date effectiveTime;		// 生效时间
	private String remark;		// 备注
	private Date createdAt;		// 创建时间
	private String createdBy;		// 创建人
	private Date deletedAt;		// 删除时间
	private String deletedBy;		// 删除人
	
	public Charge() {
		super();
	}

	public Charge(Long id){
		super(id);
	}

	@Length(min=0, max=255, message="路由ID长度必须介于 0 和 255 之间")
	public String getRouteId() {
		return routeId;
	}

	public void setRouteId(String routeId) {
		this.routeId = routeId;
	}
	
	@Length(min=1, max=255, message="应用ID长度必须介于 1 和 255 之间")
	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Length(min=0, max=64, message="计费方式长度必须介于 0 和 64 之间")
	public String getChargeMethod() {
		return chargeMethod;
	}

	public void setChargeMethod(String chargeMethod) {
		this.chargeMethod = chargeMethod;
	}
	
	public Long getChargeValue() {
		return chargeValue;
	}

	public void setChargeValue(Long chargeValue) {
		this.chargeValue = chargeValue;
	}
	
	public Long getUsedValue() {
		return usedValue;
	}

	public void setUsedValue(Long usedValue) {
		this.usedValue = usedValue;
	}
	
	public Long getRestValue() {
		return restValue;
	}

	public void setRestValue(Long restValue) {
		this.restValue = restValue;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getExpiredTime() {
		return expiredTime;
	}

	public void setExpiredTime(Date expiredTime) {
		this.expiredTime = expiredTime;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getEffectiveTime() {
		return effectiveTime;
	}

	public void setEffectiveTime(Date effectiveTime) {
		this.effectiveTime = effectiveTime;
	}
	
	@Length(min=0, max=255, message="备注长度必须介于 0 和 255 之间")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
	
	@Length(min=0, max=255, message="创建人长度必须介于 0 和 255 之间")
	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getDeletedAt() {
		return deletedAt;
	}

	public void setDeletedAt(Date deletedAt) {
		this.deletedAt = deletedAt;
	}
	
	@Length(min=0, max=255, message="删除人长度必须介于 0 和 255 之间")
	public String getDeletedBy() {
		return deletedBy;
	}

	public void setDeletedBy(String deletedBy) {
		this.deletedBy = deletedBy;
	}

	/**
	 * 判断通过api新增接口参数不为空
	 * @param charge
	 * @return
	 */
	public String ifNotNull(Charge charge) {
		if (Strings.isNullOrEmpty(charge.appId)) {
			return "应用Id不可为空!";
		}
		if (Strings.isNullOrEmpty(charge.userId)) {
			return "用户Id不可为空";
		}
		if (Strings.isNullOrEmpty(charge.routeId)) {
			return "路由Id不可为空";
		}
		if (Strings.isNullOrEmpty(charge.routeId)) {
			return "计费方式不可为空";
		}
		if (charge.chargeValue == null) {
			return "计费值不可为空";
		}
		if (charge.effectiveTime == null) {
			return "生效时间不可为空";
		}
		return "";
	}
}