优化 UserSession 的实现,将 id 变成自增,额外增加 token 字段

This commit is contained in:
YunaiV
2022-05-02 12:33:37 +08:00
parent 0f21b55e6d
commit 8606f5c605
24 changed files with 324 additions and 237 deletions

View File

@ -18,33 +18,33 @@ public interface UserSessionApi {
* @param loginUser 登录用户
* @param userIp 用户 IP
* @param userAgent 用户 UA
* @return Session 编号
* @return Token 令牌
*/
String createUserSession(@NotNull(message = "登录用户不能为空") LoginUser loginUser, String userIp, String userAgent);
/**
* 刷新在线用户 Session 的更新时间
*
* @param sessionId Session 编号
* @param token Token 令牌
* @param loginUser 登录用户
*/
void refreshUserSession(@NotEmpty(message = "Session编号不能为空") String sessionId,
void refreshUserSession(@NotEmpty(message = "Token 令牌不能为空") String token,
@NotNull(message = "登录用户不能为空") LoginUser loginUser);
/**
* 删除在线用户 Session
*
* @param sessionId Session 编号
* @param token Token 令牌
*/
void deleteUserSession(String sessionId);
void deleteUserSession(String token);
/**
* 获得 Session 编号对应的在线用户
* 获得 Token 令牌对应的在线用户
*
* @param sessionId Session 编号
* @param token Token 令牌
* @return 在线用户
*/
LoginUser getLoginUser(String sessionId);
LoginUser getLoginUser(String token);
/**
* 获得 Session 超时时间,单位:毫秒