59 lines
3.0 KiB
Markdown
59 lines
3.0 KiB
Markdown
# INBOX
|
||
|
||
## [已处理] K84-A 列表卡片与后台补充收藏 / 点赞 / 评论数
|
||
|
||
### 背景
|
||
|
||
右侧互动栏要显示收藏、评论、喜欢的数量,但首页 feed 等列表卡片拿不到这三个数。
|
||
|
||
已确认:
|
||
|
||
- 数据库 `drama` 表有 `favorite_count`、`like_count`(无 comment_count 列,评论数按
|
||
`content_comment` 统计,见 `AppDramaDetailVO.commentCount`)
|
||
- `AppDramaDetailVO` 已返回 `likeCount / favoriteCount / commentCount`
|
||
- **`AppDramaCardVO`(列表卡片)只有 `viewCount`,缺这三个字段** → 客户端列表阶段拿不到
|
||
- 后台 `DramaRespVO` 只有 `views`,也缺这三个数
|
||
- 客户端 `Drama.fromJson` 已经解析 `likeCount / favoriteCount / commentCount`,**客户端无需改**
|
||
|
||
### 任务(FruitServer 仓库)
|
||
|
||
1. `fruitshorts-app-api/.../vo/AppDramaCardVO.java`
|
||
- 增加 `Long likeCount`、`Long favoriteCount`、`Long commentCount`
|
||
2. `fruitshorts-app-api/.../service/AppCatalogService.java`
|
||
- `cards()` 里一次性批量取评论数:`Map<Long, Long> commentCounts = commentService.countByDramas(ids)`
|
||
- `toCard()` 填充:
|
||
- `likeCount` ← `drama.getLikeCount()`
|
||
- `favoriteCount` ← `drama.getFavoriteCount()`
|
||
- `commentCount` ← `commentCounts.getOrDefault(drama.getId(), 0L)`
|
||
- 不要逐条 `countByDrama`(避免 N+1)
|
||
3. `fruitshorts-module-interaction/.../service/CommentService.java`
|
||
- 新增 `Map<Long, Long> countByDramas(Collection<Long> dramaIds)`:
|
||
`deleted = 0` 且 `drama_id in (...)`,按 `drama_id` 分组计数;空集合返回空 Map
|
||
- 现有 `countByDrama(Long)` 可复用该方法的单元素结果或保持不动
|
||
4. 后台管理端(注意模块依赖方向:`module-interaction` 依赖 `module-content`,不能反向依赖)
|
||
- `fruitshorts-module-content/.../vo/DramaRespVO.java` 增加 `likeCount / favoriteCount / commentCount`
|
||
- `DramaService`(module-content)只填充 `likeCount / favoriteCount`(取实体字段),
|
||
`commentCount` 先留空
|
||
- `fruitshorts-admin-api` 的 Drama 接口(`DramaController` 或 admin 侧小服务)在分页/详情返回前,
|
||
用 `CommentService.countByDramas(ids)` 批量回填 `commentCount`
|
||
(分页一次查询;详情单条)
|
||
5. 测试
|
||
- `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 仓库;完成后停住等待验收。
|