package cn.com.qmth.stmms.ms.core.domain.user;

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

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created by zhengmin on 2016/8/15.
 */

@MappedSuperclass
public abstract class AbstractUser implements Serializable {


    @Id
    @GeneratedValue
    private Long id;

    @NotNull
    @Column(name = "login_name", unique = true)
    private String loginName;

    private String password;

    private String name;

    private boolean enabled;

    @Temporal(value = TemporalType.TIMESTAMP)
    private Date lastLoginTime;

    @Transient
    private String token;
    
    private String sessionId;

    private int pwChangedCount = 0;

    public AbstractUser(String loginName, String password) {
        this.loginName = loginName;
        this.password = password;
        this.enabled = true;
    }

    public AbstractUser(){
        this.enabled = true;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public String getToken() {
        return token;
    }

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

    public String getName() {
        return name;
    }

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

	public String getSessionId() {
		return sessionId;
	}

	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}

    public int getPwChangedCount() {
        return pwChangedCount;
    }

    public void setPwChangedCount(int pwChangedCount) {
        this.pwChangedCount = pwChangedCount;
    }
}


