3.0 KiB
3.0 KiB
INBOX
[已处理] K84-A 列表卡片与后台补充收藏 / 点赞 / 评论数
背景
右侧互动栏要显示收藏、评论、喜欢的数量,但首页 feed 等列表卡片拿不到这三个数。
已确认:
- 数据库
drama表有favorite_count、like_count(无 comment_count 列,评论数按content_comment统计,见AppDramaDetailVO.commentCount) AppDramaDetailVO已返回likeCount / favoriteCount / commentCountAppDramaCardVO(列表卡片)只有viewCount,缺这三个字段 → 客户端列表阶段拿不到- 后台
DramaRespVO只有views,也缺这三个数 - 客户端
Drama.fromJson已经解析likeCount / favoriteCount / commentCount,客户端无需改
任务(FruitServer 仓库)
fruitshorts-app-api/.../vo/AppDramaCardVO.java- 增加
Long likeCount、Long favoriteCount、Long commentCount
- 增加
fruitshorts-app-api/.../service/AppCatalogService.javacards()里一次性批量取评论数:Map<Long, Long> commentCounts = commentService.countByDramas(ids)toCard()填充:likeCount←drama.getLikeCount()favoriteCount←drama.getFavoriteCount()commentCount←commentCounts.getOrDefault(drama.getId(), 0L)
- 不要逐条
countByDrama(避免 N+1)
fruitshorts-module-interaction/.../service/CommentService.java- 新增
Map<Long, Long> countByDramas(Collection<Long> dramaIds):deleted = 0且drama_id in (...),按drama_id分组计数;空集合返回空 Map - 现有
countByDrama(Long)可复用该方法的单元素结果或保持不动
- 新增
- 后台管理端(注意模块依赖方向:
module-interaction依赖module-content,不能反向依赖)fruitshorts-module-content/.../vo/DramaRespVO.java增加likeCount / favoriteCount / commentCountDramaService(module-content)只填充likeCount / favoriteCount(取实体字段),commentCount先留空fruitshorts-admin-api的 Drama 接口(DramaController或 admin 侧小服务)在分页/详情返回前, 用CommentService.countByDramas(ids)批量回填commentCount(分页一次查询;详情单条)
- 测试
AppCatalogControllerContractTest:列表卡片接口增加likeCount / favoriteCount / commentCount断言- 后台分页/详情如有测试,补充三个字段断言
CommentService.countByDramas补单测(空集合 / 多剧集分组)
验收
- 门禁:
mvn test全过。 - 接口自测:
GET /app/home/feed(或现有首页聚合接口)返回的每个卡片都带三个数字段。
Git
- 从
develop拉feat/drama-card-counts。 - 提交:
feat(content): 列表卡片与后台返回收藏点赞评论数,作者Zhou Weidong <502333560@qq.com>。 --no-ff合回develop并 push;FruitServer/docs/plans/PROGRESS.md追加 K84-A 留痕。
约束
- 全程中文;禁止
git add -A;不改客户端代码、不改 specs 仓库;完成后停住等待验收。