Controller
@PostMapping("/logout")
public Result<Map<String, Object>> logout(@RequestHeader("X-Token") String token) {
userService.logout(token);
return Result.success(null, "用户退出成功");
}
Service
@Override
public void logout(String token) {
redisTemplate.delete(token);
}