feat(relation): 实现关注列表分页查询及异步同步到Redis

- 在 PageResponse 中新增 getOffset 方法用于计算分页偏移量
- 优化关注列表分页逻辑,支持从 Redis 和数据库双重查询
- 添加线程池配置,用于异步同步关注列表至 Redis
- 实现全量同步关注列表到 Redis 的方法,并设置随机过期时间
- 封装 RPC 调用用户服务并将 DTO 转换为 VO 的公共方法
-修复分页查询边界条件判断,避免无效查询
- 使用 Lua 脚本批量操作 Redis 提高同步效率和原子性
This commit is contained in:
2025-10-14 23:31:25 +08:00
parent 1e350a4af5
commit aca7c657fa
3 changed files with 156 additions and 21 deletions

View File

@@ -53,4 +53,18 @@ public class PageResponse<T> extends Response<List<T>> {
public static long getTotalPage(long totalCount, long pageSize) {
return pageSize == 0 ? 0 : (totalCount + pageSize - 1) / pageSize;
}
/**
* 计算分页查询的 offset
* @param pageNo 页码
* @param pageSize 每页展示的数据量
* @return offset
*/
public static long getOffset(long pageNo, long pageSize) {
// 如果页码小于 1默认返回第一页的 offset
if (pageNo < 1) {
pageNo = 1;
}
return (pageNo - 1) * pageSize;
}
}