package cn.com.qmth.examcloud.tool.vo.user;

import cn.com.qmth.examcloud.tool.enums.UserType;

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

/**
 * 用户
 */
public class User implements Serializable {

    private static final long serialVersionUID = 8766713125414955078L;

    private String serverUrl;

    /**
     * 全局唯一用户标识符
     */
    private String key;

    /**
     * 用户类型
     */
    private UserType userType;

    /**
     * 用户ID(包含普通用户ID,学生用户ID)
     */
    private Long userId;

    /**
     * 显示名
     */
    private String displayName;

    /**
     * 顶级机构ID
     */
    private Long rootOrgId;

    /**
     * 顶级机构名称
     */
    private String rootOrgName;

    /**
     * 顶级机构域名
     */
    private String rootOrgDomain;

    /**
     * 创建时间
     */
    private Date creationTime;

    /**
     * 角色集合
     */
    private List<Role> roleList;

    /**
     * 客户端IP
     */
    private String clientIp;

    /**
     * 鉴权token
     */
    private String token;

    /**
     * 会话失效时长
     */
    private Integer sessionTimeout;

    /**
     * 密码虚弱
     */
    private Boolean passwordWeak;

    /**
     * 加密方案组合
     */
    private String salt;

    /**
     * 构建key
     */
    public String buildKey() {
        this.key = new StringBuilder()
                .append("U_").append(userType.getCode())
                .append("_").append(rootOrgId)
                .append("_").append(userId)
                .toString();
        return this.key;
    }

    public String getServerUrl() {
        return serverUrl;
    }

    public void setServerUrl(String serverUrl) {
        this.serverUrl = serverUrl;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public UserType getUserType() {
        return userType;
    }

    public void setUserType(UserType userType) {
        this.userType = userType;
    }

    public Long getUserId() {
        return userId;
    }

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

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public Long getRootOrgId() {
        return rootOrgId;
    }

    public void setRootOrgId(Long rootOrgId) {
        this.rootOrgId = rootOrgId;
    }

    public String getRootOrgName() {
        return rootOrgName;
    }

    public void setRootOrgName(String rootOrgName) {
        this.rootOrgName = rootOrgName;
    }

    public String getRootOrgDomain() {
        return rootOrgDomain;
    }

    public void setRootOrgDomain(String rootOrgDomain) {
        this.rootOrgDomain = rootOrgDomain;
    }

    public Date getCreationTime() {
        return creationTime;
    }

    public void setCreationTime(Date creationTime) {
        this.creationTime = creationTime;
    }

    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    public String getClientIp() {
        return clientIp;
    }

    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Integer getSessionTimeout() {
        return sessionTimeout;
    }

    public void setSessionTimeout(Integer sessionTimeout) {
        this.sessionTimeout = sessionTimeout;
    }

    public Boolean getPasswordWeak() {
        return passwordWeak;
    }

    public void setPasswordWeak(Boolean passwordWeak) {
        this.passwordWeak = passwordWeak;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

}
