package com.bocloud.ims.entity.middleware;

import com.alibaba.fastjson.annotation.JSONField;
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.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 数据库用户类
 *
 * @author weiwei
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("cms_user")
public class CmsUser extends GenericEntity {

	@PK(PKStrategy.AUTO)
	private Long id;// ID
	@Column("name")
	private String name;// 用户名
	@Column("password")
	private String password;// 密码
	@Column("host")
	private String host;// 主机
	@Column("mq_id")
	private Long mqId;// 消息队列ID
	@Column("dbs")
	private String dbs;// 数据库实例ID集合
	@Column("permission")
	private String permission;
	@IgnoreAll
	private String newPassword;// 密码
	@IgnoreAll
	private List<RdsDb> grantDbs;
	@IgnoreAll
	private List<RdsDb> revokeDbs;
	@Column("tracing")
	private Boolean tracing;
	@Column("tags")
	private String tags;
	@JSONField(name = "password_hash")
	@IgnoreAll
	private String passwordHash;
	private String user;
	private String vhost;
	private String configure;
	private String write;
	private String read;

	/**
	 * @param name
	 * @param password
	 * @param host
	 * @param mqId
	 */
	public CmsUser(String name, String password, String host, Long mqId) {
		super();
		this.name = name;
		this.password = password;
		this.host = host;
		this.mqId = mqId;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public void setName(String name) {
		this.name = name;
	}
}
