提交 | 用户 | 时间
|
71e81e
|
1 |
/** |
懒 |
2 |
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) |
|
3 |
* <p> |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* <p> |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* <p> |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package cn.stylefeng.guns.base.auth.model; |
|
17 |
|
|
18 |
import cn.stylefeng.roses.core.util.ToolUtil; |
|
19 |
import lombok.Data; |
|
20 |
import org.springframework.security.core.userdetails.UserDetails; |
|
21 |
|
|
22 |
import java.io.Serializable; |
|
23 |
import java.util.ArrayList; |
|
24 |
import java.util.List; |
|
25 |
import java.util.Map; |
|
26 |
import java.util.Set; |
|
27 |
|
|
28 |
/** |
|
29 |
* 当前登录用户信息 |
|
30 |
* |
|
31 |
* @author fengshuonan |
|
32 |
* @Date 2019/7/18 22:29 |
|
33 |
*/ |
|
34 |
@Data |
|
35 |
public class LoginUser implements UserDetails, Serializable { |
|
36 |
|
|
37 |
private static final long serialVersionUID = 1L; |
|
38 |
|
|
39 |
/** |
|
40 |
* 用户主键ID |
|
41 |
*/ |
|
42 |
private Long id; |
|
43 |
|
|
44 |
/** |
|
45 |
* 账号 |
|
46 |
*/ |
|
47 |
private String account; |
|
48 |
|
|
49 |
/** |
|
50 |
* 姓名 |
|
51 |
*/ |
|
52 |
private String name; |
|
53 |
|
|
54 |
/** |
|
55 |
* 邮箱 |
|
56 |
*/ |
|
57 |
private String email; |
|
58 |
|
|
59 |
/** |
|
60 |
* 头像 |
|
61 |
*/ |
|
62 |
private String avatar; |
|
63 |
|
|
64 |
/** |
|
65 |
* 部门id |
|
66 |
*/ |
|
67 |
private Long deptId; |
|
68 |
|
|
69 |
/** |
|
70 |
* 角色集 |
|
71 |
*/ |
|
72 |
private List<Long> roleList; |
|
73 |
|
|
74 |
/** |
|
75 |
* 部门名称 |
|
76 |
*/ |
|
77 |
private String deptName; |
|
78 |
|
|
79 |
/** |
|
80 |
* 角色名称集 |
|
81 |
*/ |
|
82 |
private List<String> roleNames; |
|
83 |
|
|
84 |
public List<Long> getRoleList() { |
|
85 |
return roleList; |
|
86 |
} |
|
87 |
|
|
88 |
public void setRoleList(List<Long> roleList) { |
|
89 |
this.roleList = roleList; |
|
90 |
} |
|
91 |
|
|
92 |
public String getDeptName() { |
|
93 |
return deptName; |
|
94 |
} |
|
95 |
|
|
96 |
public void setDeptName(String deptName) { |
|
97 |
this.deptName = deptName; |
|
98 |
} |
|
99 |
|
|
100 |
public List<String> getRoleNames() { |
|
101 |
return roleNames; |
|
102 |
} |
|
103 |
|
|
104 |
public void setRoleNames(List<String> roleNames) { |
|
105 |
this.roleNames = roleNames; |
|
106 |
} |
|
107 |
|
|
108 |
public List<String> getRoleTips() { |
|
109 |
return roleTips; |
|
110 |
} |
|
111 |
|
|
112 |
public void setRoleTips(List<String> roleTips) { |
|
113 |
this.roleTips = roleTips; |
|
114 |
} |
|
115 |
|
|
116 |
public List<Map<String, Object>> getSystemTypes() { |
|
117 |
return systemTypes; |
|
118 |
} |
|
119 |
|
|
120 |
public void setSystemTypes(List<Map<String, Object>> systemTypes) { |
|
121 |
this.systemTypes = systemTypes; |
|
122 |
} |
|
123 |
|
|
124 |
public Set<String> getPermissions() { |
|
125 |
return permissions; |
|
126 |
} |
|
127 |
|
|
128 |
public void setPermissions(Set<String> permissions) { |
|
129 |
this.permissions = permissions; |
|
130 |
} |
|
131 |
|
|
132 |
public String getTenantCode() { |
|
133 |
return tenantCode; |
|
134 |
} |
|
135 |
|
|
136 |
public void setTenantCode(String tenantCode) { |
|
137 |
this.tenantCode = tenantCode; |
|
138 |
} |
|
139 |
|
|
140 |
public String getTenantDataSourceName() { |
|
141 |
return tenantDataSourceName; |
|
142 |
} |
|
143 |
|
|
144 |
public void setTenantDataSourceName(String tenantDataSourceName) { |
|
145 |
this.tenantDataSourceName = tenantDataSourceName; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* 角色备注(code) |
|
150 |
*/ |
|
151 |
private List<String> roleTips; |
|
152 |
|
|
153 |
/** |
|
154 |
* 系统标识集合 |
|
155 |
*/ |
|
156 |
private List<Map<String, Object>> systemTypes; |
|
157 |
|
|
158 |
/** |
|
159 |
* 拥有的权限 |
|
160 |
*/ |
|
161 |
private Set<String> permissions; |
|
162 |
|
|
163 |
/** |
|
164 |
* 租户编码 |
|
165 |
*/ |
|
166 |
private String tenantCode; |
|
167 |
|
|
168 |
public static long getSerialVersionUID() { |
|
169 |
return serialVersionUID; |
|
170 |
} |
|
171 |
|
|
172 |
public Long getId() { |
|
173 |
return id; |
|
174 |
} |
|
175 |
|
|
176 |
public void setId(Long id) { |
|
177 |
this.id = id; |
|
178 |
} |
|
179 |
|
|
180 |
public String getAccount() { |
|
181 |
return account; |
|
182 |
} |
|
183 |
|
|
184 |
public void setAccount(String account) { |
|
185 |
this.account = account; |
|
186 |
} |
|
187 |
|
|
188 |
public String getName() { |
|
189 |
return name; |
|
190 |
} |
|
191 |
|
|
192 |
public void setName(String name) { |
|
193 |
this.name = name; |
|
194 |
} |
|
195 |
|
|
196 |
public String getEmail() { |
|
197 |
return email; |
|
198 |
} |
|
199 |
|
|
200 |
public void setEmail(String email) { |
|
201 |
this.email = email; |
|
202 |
} |
|
203 |
|
|
204 |
public String getAvatar() { |
|
205 |
return avatar; |
|
206 |
} |
|
207 |
|
|
208 |
public void setAvatar(String avatar) { |
|
209 |
this.avatar = avatar; |
|
210 |
} |
|
211 |
|
|
212 |
public Long getDeptId() { |
|
213 |
return deptId; |
|
214 |
} |
|
215 |
|
|
216 |
public void setDeptId(Long deptId) { |
|
217 |
this.deptId = deptId; |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* 租户的数据源名称 |
|
222 |
*/ |
|
223 |
private String tenantDataSourceName; |
|
224 |
|
|
225 |
@Override |
|
226 |
public List<MyRole> getAuthorities() { |
|
227 |
ArrayList<MyRole> grantedAuthorities = new ArrayList<>(); |
|
228 |
if (ToolUtil.isNotEmpty(this.roleNames)) { |
|
229 |
for (String roleName : this.roleNames) { |
|
230 |
grantedAuthorities.add(new MyRole(roleName)); |
|
231 |
} |
|
232 |
} |
|
233 |
return grantedAuthorities; |
|
234 |
} |
|
235 |
|
|
236 |
@Override |
|
237 |
public String getPassword() { |
|
238 |
return null; |
|
239 |
} |
|
240 |
|
|
241 |
@Override |
|
242 |
public String getUsername() { |
|
243 |
return this.account; |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public boolean isAccountNonExpired() { |
|
248 |
//能生成loginUser就是jwt解析成功,没锁定 |
|
249 |
return true; |
|
250 |
} |
|
251 |
|
|
252 |
@Override |
|
253 |
public boolean isAccountNonLocked() { |
|
254 |
//能生成loginUser就是jwt解析成功,没锁定 |
|
255 |
return true; |
|
256 |
} |
|
257 |
|
|
258 |
@Override |
|
259 |
public boolean isCredentialsNonExpired() { |
|
260 |
//能生成loginUser就是jwt解析成功,没锁定 |
|
261 |
return true; |
|
262 |
} |
|
263 |
|
|
264 |
@Override |
|
265 |
public boolean isEnabled() { |
|
266 |
//能生成loginUser就是jwt解析成功,没锁定 |
|
267 |
return true; |
|
268 |
} |
|
269 |
} |