feat(auth): 新增大哥租户专属登出接口
This commit is contained in:
@@ -68,4 +68,9 @@ public class UserController {
|
|||||||
return ResultUtils.success(loginService.logout());
|
return ResultUtils.success(loginService.logout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/bigbrother-logout")
|
||||||
|
public BaseResponse<Boolean> bigBrotherLogout(@RequestBody SystemUsersDTO usersDTO){
|
||||||
|
return ResultUtils.success(loginService.bigBrotherLogout(usersDTO));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,6 +246,27 @@ public class LoginService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean bigBrotherLogout(SystemUsersDTO usersDTO) {
|
||||||
|
// 1. 删除 Redis 中该用户的 BIG_BROTHER 登录标记
|
||||||
|
Boolean bigBrother_login = redisTemplate.delete("bigbrother_login:" + usersDTO.getTenantId() + ":" + usersDTO.getUserId());
|
||||||
|
|
||||||
|
// 2. 使当前 Token 失效
|
||||||
|
String tokenValue = StpUtil.getTokenValue();
|
||||||
|
StpUtil.logoutByTokenValue(tokenValue);
|
||||||
|
|
||||||
|
log.info("删除租户:{} 登录状态:{}", usersDTO.getTenantId(), bigBrother_login);
|
||||||
|
|
||||||
|
// 3. 若该租户下已无 AI_CHAT 在线用户,则删除队列
|
||||||
|
if (!redisUtils.hasKeyByPrefix("bigbrother_login:" + usersDTO.getTenantId())) {
|
||||||
|
boolean b = rabbitAdmin.deleteQueue("b.tenant." + usersDTO.getTenantId());
|
||||||
|
log.info("删除大哥租户:{} 队列删除状态:{}", usersDTO.getTenantId(), b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用登出(不区分场景)
|
* 通用登出(不区分场景)
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user