SAMS/src/main/java/com/bruce/sams/domain/sys/User.java

132 lines
4.2 KiB
Java

package com.bruce.sams.domain.sys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.List;
/**
* 系统用户表
* @TableName sys_user
*/
@TableName(value ="sys_user")
@Data
public class User implements UserDetails {
/**
* 用户ID
*/
@TableId(type = IdType.AUTO)
private Long userId;
/**
* 用户昵称
*/
private String nickName;
/**
* 真实姓名
*/
private String username;
/**
* 用户密码
*/
private String password;
/**
* 学号/教职工号
*/
private String schoolId;
/**
* 所属院系
*/
private Long collegeId;
/**
* 用户邮箱
*/
private String email;
/**
* 头像地址
*/
private String avatar;
/**
* 账号状态
*/
private Object status;
// 不映射到数据库
private List<GrantedAuthority> authorities;
public User(String username, String password, List<GrantedAuthority> authorities) {
this.username = username;
this.password = password;
this.authorities = authorities;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
User other = (User) that;
return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getNickName() == null ? other.getNickName() == null : this.getNickName().equals(other.getNickName()))
&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
&& (this.getSchoolId() == null ? other.getSchoolId() == null : this.getSchoolId().equals(other.getSchoolId()))
&& (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId()))
&& (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getNickName() == null) ? 0 : getNickName().hashCode());
result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
result = prime * result + ((getSchoolId() == null) ? 0 : getSchoolId().hashCode());
result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode());
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
return result;
}
@Override
public String toString() {
return getClass().getSimpleName() +
" [" +
"Hash = " + hashCode() +
", userId=" + userId +
", nickName=" + nickName +
", userName=" + username +
", password=" + password +
", schoolId=" + schoolId +
", collegeId=" + collegeId +
", email=" + email +
", avatar=" + avatar +
", status=" + status +
"]";
}
}