shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
package com.walker.web;
 
/**
 * 用户在线状态提供者接口规范定义。
 * <pre>
 *     1.通过该定义,可以根据token获取用户信息
 *     2.判断用户是否存在多个(相同)账号同时登录
 *     3.判断是否存在同一用户在不同设备上登录
 *     4.更新(或删除)用户登录缓存信息
 * </pre>
 * @author 时克英
 * @date 2022-11-01
 */
public interface UserOnlineProvider {
 
    /**
     * 根据token返回用户登录凭证对象
     * @param token
     * @return
     */
    UserPrincipal<?> getUserPrincipal(String token);
 
    /**
     * 缓存一个用户登录凭证与token关联信息
     * @param token
     * @param userPrincipal
     * @return
     */
    @Deprecated
    boolean cacheUserPrincipal(String token, UserPrincipal<?> userPrincipal);
 
    /**
     * 缓存登录信息,添加失效时间参数。
     * @param token
     * @param userPrincipal
     * @param expiredMintues 失效时间:分钟
     * @return
     * @date 2023-12-29
     */
    boolean cacheUserPrincipal(String token, UserPrincipal<?> userPrincipal, long expiredMintues);
 
    /**
     * 更新用户访问时间
     * @param token
     * @return
     */
    boolean updateUserPrincipalTimeStamp(String token);
 
    /**
     * 删除用户缓存登录信息。
     * @param token 客户端存储的token,其实目前是 'uuid'
     * @return
     */
    boolean removeUserPrincipal(String token);
}