/**
 * 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 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 Auth extends DataEntity<Auth> {
	
	private static final long serialVersionUID = 1L;
	private String routeId;		// 路由ID
	private String appId;		// 应用ID
	private String userId;		// 用户ID
	private String remark;		// 备注
	private Date createdAt;		// 创建时间
	private String createdBy;		// 创建人
	private Date deletedAt;		// 删除时间
	private String deletedBy;		// 删除人
	
	public Auth() {
		super();
	}

	public Auth(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;
	}
	
	@Length(min=0, max=255, message="用户ID长度必须介于 0 和 255 之间")
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@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 auth
	 * @return
	 */
	public String ifNotNull(Auth auth) {
		if (Strings.isNullOrEmpty(auth.appId)) {
			return "应用Id不可为空!";
		}
		if (Strings.isNullOrEmpty(auth.userId)) {
			return "用户Id不可为空";
		}
		if (Strings.isNullOrEmpty(auth.routeId)) {
			return "路由Id不可为空";
		}
		return "";
	}
	
}