提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.security.core; |
H |
2 |
|
|
3 |
import cn.hutool.core.map.MapUtil; |
|
4 |
import com.iailab.framework.common.enums.UserTypeEnum; |
|
5 |
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
6 |
import lombok.Data; |
|
7 |
|
325d2f
|
8 |
import java.time.LocalDateTime; |
e7c126
|
9 |
import java.util.HashMap; |
H |
10 |
import java.util.List; |
|
11 |
import java.util.Map; |
|
12 |
|
|
13 |
/** |
|
14 |
* 登录用户信息 |
|
15 |
* |
|
16 |
* @author iailab |
|
17 |
*/ |
|
18 |
@Data |
|
19 |
public class LoginUser { |
|
20 |
|
|
21 |
public static final String INFO_KEY_NICKNAME = "nickname"; |
|
22 |
public static final String INFO_KEY_DEPT_ID = "deptId"; |
|
23 |
|
|
24 |
/** |
|
25 |
* 用户编号 |
|
26 |
*/ |
|
27 |
private Long id; |
|
28 |
/** |
|
29 |
* 用户类型 |
|
30 |
* |
|
31 |
* 关联 {@link UserTypeEnum} |
|
32 |
*/ |
|
33 |
private Integer userType; |
|
34 |
/** |
|
35 |
* 额外的用户信息 |
|
36 |
*/ |
|
37 |
private Map<String, String> info; |
|
38 |
/** |
|
39 |
* 租户编号 |
|
40 |
*/ |
|
41 |
private Long tenantId; |
|
42 |
/** |
|
43 |
* 授权范围 |
|
44 |
*/ |
|
45 |
private List<String> scopes; |
325d2f
|
46 |
/** |
H |
47 |
* 过期时间 |
|
48 |
*/ |
|
49 |
private LocalDateTime expiresTime; |
e7c126
|
50 |
|
H |
51 |
// ========== 上下文 ========== |
|
52 |
/** |
|
53 |
* 上下文字段,不进行持久化 |
|
54 |
* |
|
55 |
* 1. 用于基于 LoginUser 维度的临时缓存 |
|
56 |
*/ |
|
57 |
@JsonIgnore |
|
58 |
private Map<String, Object> context; |
|
59 |
|
|
60 |
public void setContext(String key, Object value) { |
|
61 |
if (context == null) { |
|
62 |
context = new HashMap<>(); |
|
63 |
} |
|
64 |
context.put(key, value); |
|
65 |
} |
|
66 |
|
|
67 |
public <T> T getContext(String key, Class<T> type) { |
|
68 |
return MapUtil.get(context, key, type); |
|
69 |
} |
|
70 |
|
|
71 |
} |