package com.yonge.cooleshow.auth.api.entity;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * 对应数据库表(sys_user):
 */
@Data
public class SysUser implements Serializable{

	/**
	 *
	 */
	private static final long serialVersionUID = -1374403507360017093L;

	/** 主键ID */
	private Long id;
	
	/** 用户名 */
	@ApiModelProperty(value = "用户名")
	private String username;

	/**  */
	@ApiModelProperty(value = "密码")
	private String password;

	/** 随机盐 */
	@ApiModelProperty(value = "随机盐")
	private String salt;

	@ApiModelProperty(value = "手机号")
	private String phone;

	/** 头像 */
	@ApiModelProperty(value = "头像")
	private String avatar;

	/** 创建时间 */
	private java.util.Date createTime;

	/** 修改时间 */
	private java.util.Date updateTime;

	/** 0-正常， 1-锁定 */
	@ApiModelProperty(value = "0-正常， 1-锁定")
	private Integer lockFlag;

	/** 0-正常，1-删除 */
	@ApiModelProperty(value = "0-正常，1-删除")
	private Boolean delFlag;

	/** 微信openid */
	@ApiModelProperty(value = "微信openid")
	private String wxOpenid;

	/** QQ openid */
	@ApiModelProperty(value = "QQ openid")
	private String qqOpenid;

	/** 用户类型 */
//	@ApiModelProperty(value = "用户类型")
	//STUDENT("学生"), EDU_TEACHER("教务老师"), TEACHER("指导老师"), SYSTEM("系统內置"), ADMIN("管理员")
	private String userType;

	@ApiModelProperty(value = "性别0女1男")
	private Integer gender;

	@ApiModelProperty(value = "民族")
	private String nation;

	@ApiModelProperty(value = "生日")
	private Date birthdate;

	@ApiModelProperty(value = "邮箱")
	private String email;

	@ApiModelProperty(value = "融云token")
	private String imToken;

	@ApiModelProperty(value = "身份证号")
	private String idCardNo;

	@ApiModelProperty(value = "真实姓名")
	private String realName;

	@ApiModelProperty(value = "微信号")
	private String wechatId;

	@ApiModelProperty(value = "是否是超管")
	private Boolean isSuperAdmin = false;

	@ApiModelProperty(value = "用户角色")
	private List<Long> roles;

	@ApiModelProperty(value = "最近一次修改用户名称时间")
	private Date lastUsernameTime;

	private String certificateType = "IDENTITY";

	@ApiModelProperty(value = "机构编号")
	private Long tenantId;

	public void setUserType(String userType) {
		if(StringUtils.isNotEmpty(userType) && userType.startsWith(",")){
			userType = userType.substring(1);
		}
		this.userType = userType;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

	public String jsonString() {
		return JSON.toJSONString(this);
	}
}
