feat(content): 列表卡片与后台返回收藏点赞评论数
This commit is contained in:
1 parent
f90336963b
commit
256821b824
13 files changed
+324
-50
No files matched your search
@@ -173,6 +173,10 @@ app.register.max-per-device-per-day
|
||||
|
||||
> 卡片(`AppDramaCardVO`)统一新增 `language` 字段(取值如 `zh-CN` / `id`),
|
||||
> 首页、发现页、分类、收藏、搜索等所有下发卡片的场景都带该字段,客户端可据此做语言筛选。
|
||||
>
|
||||
> 卡片同时下发 `likeCount` / `favoriteCount` / `commentCount`(均为 JSON 字符串),
|
||||
> 点赞、收藏取 `drama` 冗余计数字段,评论数由 `content_comment` 按 `drama_id` 批量统计,
|
||||
> 排除逻辑删除与 `status = 'deleted'` 的记录。首页、发现、分类、收藏、搜索等列表卡片结构一致。
|
||||
|
||||
#### 短剧详情响应(`GET /app/dramas/{id}`)
|
||||
|
||||
|
||||
+40
-41
@@ -1,59 +1,58 @@
|
||||
# INBOX
|
||||
|
||||
## [已处理] K83-A 右侧互动栏改用参考图同款图标资源
|
||||
## [已处理] K84-A 列表卡片与后台补充收藏 / 点赞 / 评论数
|
||||
|
||||
### 背景
|
||||
|
||||
K82-A 用 Material 图标替换后,形状与参考图仍不一致(星形/气泡/心形/分享箭头细节不同),
|
||||
且 Material 字形自带内边距,视觉上比参考图小。
|
||||
右侧互动栏要显示收藏、评论、喜欢的数量,但首页 feed 等列表卡片拿不到这三个数。
|
||||
|
||||
已从产品提供的参考图中提取出四个图标(白色 + 透明通道,保留原始形状与相对大小),
|
||||
放在仓库 `assets/icon/rail/`:
|
||||
已确认:
|
||||
|
||||
- `rail_save.png`(收藏,实心星)
|
||||
- `rail_comment.png`(评论,带三个点的气泡)
|
||||
- `rail_like.png`(喜欢,实心心形)
|
||||
- `rail_share.png`(分享,弯向右的箭头)
|
||||
- 数据库 `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. `pubspec.yaml`
|
||||
- `flutter.assets` 增加 `assets/icon/rail/`(目录)
|
||||
2. `lib/pages/player/widgets/interaction_rail.dart`
|
||||
- `InteractionRailItem` 的 `IconData icon / activeIcon` 改为 `String asset`
|
||||
(`selected` 只决定颜色,不再切换图标)
|
||||
- 渲染改为:
|
||||
```dart
|
||||
Image.asset(
|
||||
item.asset,
|
||||
width: _iconSize,
|
||||
height: _iconSize,
|
||||
fit: BoxFit.contain,
|
||||
color: item.selected ? AppColors.blue : Colors.white,
|
||||
colorBlendMode: BlendMode.srcIn,
|
||||
)
|
||||
```
|
||||
- `_iconSize`:`30` → `32`;`_buttonSize` 保持 `44`;`_itemGap`:`22` → `24`
|
||||
- 删除 K82-A 引入的 `mirrorIcon`(新资源本身已朝右)
|
||||
3. `lib/pages/player/widgets/home_feed_overlay.dart` 与 `player_overlay.dart`
|
||||
- 四项分别传:`assets/icon/rail/rail_save.png`、`rail_comment.png`、`rail_like.png`、`rail_share.png`
|
||||
4. 测试
|
||||
- 把 `find.byIcon(Icons.star_rounded / favorite_rounded / reply_rounded / ios_share_rounded …)` 类断言
|
||||
改为查找对应 `Image.asset`(或用 Key 定位后断言 `Image.image` 的 asset 名)
|
||||
- Key(`rail-save`、`rail-comments`、`rail-like`、`rail-share`、`player-rail-*`、计数 Key)保持不变
|
||||
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` 补单测(空集合 / 多剧集分组)
|
||||
|
||||
### 验收
|
||||
|
||||
- 门禁:`dart analyze lib test` 零告警、`flutter test` 全过、`flutter build apk --debug` 成功。
|
||||
- 真机自查:首页 feed 与全屏播放页右侧四个图标与参考图形状一致,大小一致,无深色圆底。
|
||||
- 门禁:`mvn test` 全过。
|
||||
- 接口自测:`GET /app/home/feed`(或现有首页聚合接口)返回的每个卡片都带三个数字段。
|
||||
|
||||
### Git
|
||||
|
||||
- 从 `develop` 拉 `feat/rail-icon-assets`。
|
||||
- 提交:`feat(player): 互动栏改用参考图同款图标资源`,作者 `Zhou Weidong <502333560@qq.com>`。
|
||||
- `--no-ff` 合回 `develop` 并 push;`FruitServer/docs/plans/PROGRESS.md` 追加 K83-A 留痕。
|
||||
- 从 `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`;图标资源已放到 `assets/icon/rail/`,不要重新绘制或改动形状;
|
||||
不改互动逻辑与 Key;完成后停住等待验收。
|
||||
- 全程中文;禁止 `git add -A`;不改客户端代码、不改 specs 仓库;完成后停住等待验收。
|
||||
@@ -22884,3 +22884,31 @@ Running Gradle task 'assembleDebug'...
|
||||
```
|
||||
|
||||
解读:静态检查零告警,490 条测试全部通过,debug APK 构建成功。真机验收由用户执行。
|
||||
|
||||
## 2026-10-21 FruitServer:K84-A 列表卡片与后台补充互动计数
|
||||
|
||||
- 前置状态:K83-A 文档留痕完成,FruitServer develop 提交 `f903369`。
|
||||
- 分支:`feat/drama-card-counts`
|
||||
- `AppDramaCardVO` 新增 `likeCount` / `favoriteCount` / `commentCount`,首页、发现、分类、收藏、搜索等复用卡片的接口统一返回三个字段。
|
||||
- `AppCatalogService.cards()` 对每批卡片只调用一次 `CommentService.countByDramas(ids)`,点赞/收藏取 `Drama` 实体冗余字段,评论缺失时回填 0,避免逐条查询。
|
||||
- `CommentService` 新增按 `drama_id` 分组批量统计,过滤逻辑删除与 `status = 'deleted'`,空集合不查询数据库。
|
||||
- 后台 `DramaRespVO` 新增三个字段;`module-content` 只填点赞/收藏,`admin-api` 的分页和详情接口从 `module-interaction` 批量回填评论数,模块依赖方向保持不变。
|
||||
- `docs/api-phase1.md` 已同步卡片互动计数契约;未修改 Flutter 客户端、specs 仓库或其它业务逻辑。
|
||||
- 测试覆盖列表卡片三个字段契约、单次批量查询、空集合、多剧分组统计,以及后台分页/详情三个字段回填。
|
||||
|
||||
门禁说明:本机默认 JDK 27 不兼容既有 Mockito inline 测试,首次尝试在既有 commerce 模块失败;按项目要求固定 JDK 21 后完整重跑通过。
|
||||
|
||||
门禁原始输出:
|
||||
|
||||
```text
|
||||
$ JAVA_HOME=/opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home mvn test
|
||||
[INFO] Reactor Summary for fruitshorts 1.0.0-SNAPSHOT:
|
||||
[INFO] fruitshorts-module-interaction ..................... SUCCESS
|
||||
[INFO] fruitshorts-admin-api ............................... SUCCESS
|
||||
[INFO] fruitshorts-app-api ................................. SUCCESS
|
||||
[INFO] fruitshorts-transcode-worker ........................ SUCCESS
|
||||
[INFO] BUILD SUCCESS
|
||||
[INFO] Total time: 14.294 s
|
||||
```
|
||||
|
||||
解读:JDK 21 下完整 Maven 测试通过,App/Admin 互动计数契约与既有模块测试均保持绿色。接口联调验收由用户执行。
|
||||
Reference in new issue
Block a user