
com.luues.security.core.entity.SysUser Maven / Gradle / Ivy
package com.luues.security.core.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.Date;
@Getter
@Setter
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class SysUser implements UserDetails {
private String id; //用户id
private String username; //用户名
private String name; //昵称
private String password; //密码
private String info; //其他自定义信息
/**
* 账号是否已成功注册/认证
* 如通过微信登录并注册后,平台需要的某些数据用户还未填写,通过该字段判断
* true: 是
* false: 否
*/
private boolean ok = true;
/**
* 是否锁定
* true: 锁定
* false: 未锁定
*/
private boolean locked = false;
/**
* 用户账号是否过期
* true: 已过期
* false: 未过期
* @return
*/
private boolean accountExpired = false;
/**
* 用户账号凭证(密码)是否过期
* 简单的说就是可能会因为修改了密码导致凭证过期这样的场景
* true: 过期
* false: 未过期
* @return
*/
private boolean credentialsExpired = false;
/**
* 用户账号是否被启用
* true: 启用
* false: 未启用
* @return
*/
private boolean enabled = true;
//security存储权限认证用的
private Collection extends SimpleGrantedAuthority> authorities;
@Override
public Collection extends SimpleGrantedAuthority> getAuthorities() {
return authorities;
}
private Collection extends SimpleGrantedAuthority> permissions;
public Collection extends SimpleGrantedAuthority> getPermissions() {
return permissions;
}
@Override
public String getPassword() {
return password;
}
@Override
public String getUsername() {
return username;
}
/**
* 账号是否未过期
* @return true:是 false:否
*/
@Override
public boolean isAccountNonExpired() {
return !this.accountExpired;
}
/**
* 账号是否未锁定
* @return true:是 false:否
*/
@Override
public boolean isAccountNonLocked() {
return !locked;
}
/**
* 身份凭证是否已过期
* @return true:是 false:否
*/
@Override
public boolean isCredentialsNonExpired() {
return !this.credentialsExpired;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
/**
* 其他自定义数据
*/
public String getInfo(){
return this.info;
}
public SysUser delPassword(){
this.password = null;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy