/**
* 文件：UserEntity.java
* 版本：1.0.0
* 日期：
* Copyright &reg; 
* All right reserved.
*/

package com.mortals.xhx.base.system.user.model;

import java.util.Date;
import java.util.Objects;

import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.service.IUser;

/**
 * <p>Title: 用户信息</p>
 * <p>Description: UserEntity  </p>
 * <p>Copyright: Copyright &reg;  </p>
 * <p>Company: </p>
 * @author 
 * @version 1.0.0
 */
public class UserEntity extends BaseEntityLong implements IUser {
	private static final long serialVersionUID = 1547777703377L;

	/** 登录名 */
	private String loginName;

	/** 登录密码，使用md5双次加密 */
	private String loginPwd;

	/** 最近一次使用密码，使用md5双次加密 */
	private String loginPwd1;

	/** 最近二次使用密码，使用md5双次加密 */
	private String loginPwd2;

	/** 最近三次使用密码，使用md5双次加密 */
	private String loginPwd3;

	/** 登录限制地址，多个IP地址用逗号分隔，可以使用IP段匹配，如：172.17.*非空：则只能该值内的IP可以登录 */
	private String loginLimitAddress;

	/** 用户名 */
	private String realName;

	/** 用户手机号 */
	private String mobile;

	/** 用户联系电话 */
	private String phone;

	/** 用户邮箱 */
	private String email;

	/** QQ号码 */
	private String qq;

	/** 用户类型，0：系统用户 1:代理商用户 2:品牌商用户 */
	private Integer userType;

	/** 用户状态，0：停用，1：正常，2：冻结，3：销户，4：离职，默认1 */
	private Integer status;

	/** 客户ID */
	private Long customerId;

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

	/** 创建用户 */
	private Long createUserId;

	/** 创建用户名称 */
	private String createUserName;

	/** 最后一次登录时间 */
	private Date lastLoginTime;

	/** 最后一次登录地址 */
	private String lastLoginAddress;

	/** 最后修改密码时间 */
	private Date lastModPwdTime;

	/** 最后修改密码地址 */
	private String lastModPwdAddr;


	@Override
	public String getLoginName() {
		return loginName;
	}

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

	public String getLoginPwd() {
		return loginPwd;
	}

	public void setLoginPwd(String loginPwd) {
		this.loginPwd = loginPwd;
	}

	public String getLoginPwd1() {
		return loginPwd1;
	}

	public void setLoginPwd1(String loginPwd1) {
		this.loginPwd1 = loginPwd1;
	}

	public String getLoginPwd2() {
		return loginPwd2;
	}

	public void setLoginPwd2(String loginPwd2) {
		this.loginPwd2 = loginPwd2;
	}

	public String getLoginPwd3() {
		return loginPwd3;
	}

	public void setLoginPwd3(String loginPwd3) {
		this.loginPwd3 = loginPwd3;
	}

	public String getLoginLimitAddress() {
		return loginLimitAddress;
	}

	public void setLoginLimitAddress(String loginLimitAddress) {
		this.loginLimitAddress = loginLimitAddress;
	}

	@Override
	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Override
	public Integer getUserType() {
		return userType;
	}

	@Override
	public String getToken() {
		return null;
	}

	@Override
	public Long getLoginTime() {
		return null;
	}

	@Override
	public Long getExpireTime() {
		return null;
	}

	@Override
	public void setExpireTime(Long expireTime) {

	}

	@Override
	public String getMenuUrl() {
		return null;
	}

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

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Override
	public Long getCustomerId() {
		return customerId;
	}

	@Override
	public Long getSiteId() {
		return null;
	}

	@Override
	public String getSiteIds() {
		return null;
	}

	@Override
	public String getAreaCodes() {
		return null;
	}

	public void setCustomerId(Long customerId) {
		this.customerId = customerId;
	}

	@Override
	public Date getCreateTime() {
		return createTime;
	}

	@Override
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public Long getCreateUserId() {
		return createUserId;
	}

	@Override
	public void setCreateUserId(Long createUserId) {
		this.createUserId = createUserId;
	}

	@Override
	public String getCreateUserName() {
		return createUserName;
	}

	@Override
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

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

	public String getLastLoginAddress() {
		return lastLoginAddress;
	}

	public void setLastLoginAddress(String lastLoginAddress) {
		this.lastLoginAddress = lastLoginAddress;
	}

	public Date getLastModPwdTime() {
		return lastModPwdTime;
	}

	public void setLastModPwdTime(Date lastModPwdTime) {
		this.lastModPwdTime = lastModPwdTime;
	}

	public String getLastModPwdAddr() {
		return lastModPwdAddr;
	}

	public void setLastModPwdAddr(String lastModPwdAddr) {
		this.lastModPwdAddr = lastModPwdAddr;
	}

	@Override
	public boolean isAdmin() {
		return super.getId() == null ? false : super.getId().longValue() == SysConstains.ADMIN_ID;
	}

	@Override
	public boolean isManager() {
		return false;
	}

	@Override
	public Long getDeptId() {
		return null;
	}

	@Override
	public String getDeptName() {
		return null;
	}

	@Override
	public Long getCustomerJoinId() {
		return null;
	}

	@Override
	public String getCustomerNum() {
		return null;
	}

	@Override
	public void initAttrValue(){
		this.loginName = null;
		this.loginPwd = null;
		this.loginPwd1 = null;
		this.loginPwd2 = null;
		this.loginPwd3 = null;
		this.loginLimitAddress = null;
		this.realName = null;
		this.mobile = null;
		this.phone = null;
		this.email = null;
		this.qq = null;
		this.userType = null;
		this.status = 1;
		this.customerId = null;
		this.createTime = null;
		this.createUserId = null;
		this.createUserName = null;
		this.lastLoginTime = null;
		this.lastLoginAddress = null;
		this.lastModPwdTime = null;
		this.lastModPwdAddr = null;
	}

	@Override
	public boolean isSystemUser() {
		return userType != null && userType.intValue() == 0;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		if (!super.equals(o)) {
			return false;
		}
		UserEntity that = (UserEntity) o;
		return Objects.equals(loginName, that.loginName) &&
				Objects.equals(loginPwd, that.loginPwd) &&
				Objects.equals(loginPwd1, that.loginPwd1) &&
				Objects.equals(loginPwd2, that.loginPwd2) &&
				Objects.equals(loginPwd3, that.loginPwd3) &&
				Objects.equals(loginLimitAddress, that.loginLimitAddress) &&
				Objects.equals(realName, that.realName) &&
				Objects.equals(mobile, that.mobile) &&
				Objects.equals(phone, that.phone) &&
				Objects.equals(email, that.email) &&
				Objects.equals(qq, that.qq) &&
				Objects.equals(userType, that.userType) &&
				Objects.equals(status, that.status) &&
				Objects.equals(customerId, that.customerId) &&
				Objects.equals(createTime, that.createTime) &&
				Objects.equals(createUserId, that.createUserId) &&
				Objects.equals(createUserName, that.createUserName) &&
				Objects.equals(lastLoginTime, that.lastLoginTime) &&
				Objects.equals(lastLoginAddress, that.lastLoginAddress) &&
				Objects.equals(lastModPwdTime, that.lastModPwdTime) &&
				Objects.equals(lastModPwdAddr, that.lastModPwdAddr);
	}

	@Override
	public int hashCode() {

		return Objects.hash(super.hashCode(), loginName, loginPwd, loginPwd1, loginPwd2, loginPwd3, loginLimitAddress, realName, mobile, phone, email, qq, userType, status, customerId, createTime, createUserId, createUserName, lastLoginTime, lastLoginAddress, lastModPwdTime, lastModPwdAddr);
	}

	@Override
	public String toString() {
		return "UserEntity{" +
				"loginName='" + loginName + '\'' +
				", loginPwd='" + loginPwd + '\'' +
				", loginPwd1='" + loginPwd1 + '\'' +
				", loginPwd2='" + loginPwd2 + '\'' +
				", loginPwd3='" + loginPwd3 + '\'' +
				", loginLimitAddress='" + loginLimitAddress + '\'' +
				", realName='" + realName + '\'' +
				", mobile='" + mobile + '\'' +
				", phone='" + phone + '\'' +
				", email='" + email + '\'' +
				", qq='" + qq + '\'' +
				", userType=" + userType +
				", status=" + status +
				", customerId=" + customerId +
				", createTime=" + createTime +
				", createUserId=" + createUserId +
				", createUserName='" + createUserName + '\'' +
				", lastLoginTime=" + lastLoginTime +
				", lastLoginAddress='" + lastLoginAddress + '\'' +
				", lastModPwdTime=" + lastModPwdTime +
				", lastModPwdAddr='" + lastModPwdAddr + '\'' +
				'}';
	}
}