唐耀东
2021-12-31 0b977fb16e8272739bbe25973947f45a55ebe842
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.ruoyi.common.core.domain.model;
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
 
import java.util.Collection;
import java.util.Set;
 
/**
 * 登录用户身份权限
 *
 * @author Lion Li
 */
 
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class LoginUser implements UserDetails {
 
    private static final long serialVersionUID = 1L;
 
    /**
     * 用户ID
     */
    private Long userId;
 
    /**
     * 部门ID
     */
    private Long deptId;
 
    /**
     * 用户唯一标识
     */
    private String token;
 
    /**
     * 登录时间
     */
    private Long loginTime;
 
    /**
     * 过期时间
     */
    private Long expireTime;
 
    /**
     * 登录IP地址
     */
    private String ipaddr;
 
    /**
     * 登录地点
     */
    private String loginLocation;
 
    /**
     * 浏览器类型
     */
    private String browser;
 
    /**
     * 操作系统
     */
    private String os;
 
    /**
     * 权限列表
     */
    private Set<String> permissions;
 
    /**
     * 用户名
     */
    private String username;
 
    /**
     * 密码
     */
    private String password;
 
    public LoginUser(String username, String password, Set<String> permissions) {
        this.username = username;
        this.password = password;
        this.permissions = permissions;
    }
 
    public LoginUser(Long userId, Long deptId, String username, String password, Set<String> permissions) {
        this.userId = userId;
        this.deptId = deptId;
        this.username = username;
        this.password = password;
        this.permissions = permissions;
    }
 
    @JsonIgnore
    @Override
    public String getPassword() {
        return password;
    }
 
    @Override
    public String getUsername() {
        return username;
    }
 
    /**
     * 账户是否未过期,过期无法验证
     */
    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
 
    /**
     * 指定用户是否解锁,锁定的用户无法进行身份验证
     */
    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }
 
    /**
     * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
     */
    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }
 
    /**
     * 是否可用 ,禁用的用户不能身份验证
     */
    @JsonIgnore
    @Override
    public boolean isEnabled() {
        return true;
    }
 
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }
}