Commit Graph

10 Commits

Author SHA1 Message Date
c210e75996 style(backend): 清理幂等写入路径的注释
注释只保留一行级约束。
长段理由移入设计文档。
验证:go test -count=1 ./... 全绿。
2026-10-31 00:03:53 +08:00
953b609970 feat(video): 评论写路径按意图键幂等,HTTP 回显 request_id
同一条用户意图(同 author_id + request_id)在 comments 上只落一行:
唯一索引 uk_comments_author_key 是唯一的判重点,API 与 Worker 共用
同一个键,因此「MQ 假失败后兜底直写」与「消息稍后被消费」不再双写。

- comment_service: 引入 CommentStore/CommentPublisher/PopularityPublisher
  三个最小接口;Publish 先解析意图键,再把同一个键喂给评论事件、热度事件
  与兜底直写。只有评论事件没入队时才直写(闸 1),热度兜底独立门控。
- comment_repo: CreateIdempotentWithPopularity 在单事务内插入评论并按
  created 门控 videos.popularity;CreateMentions 显式补 CreatedAt 并按
  dedupe_key 去重;FindAccountIDs 一次 username IN ? 批量解析。
- commentworker: applyPublish 用 event_id 作幂等键并交给同一个事务,
  !created 记 dedupe=hit;applyDelete 改 DeleteByID,重复删除是空操作。
- comment_handler: 接收 request_id、响应回显,不返回评论 ID(MQ 路径上
  评论此刻可能尚未落库)。
- 提及通知带上绑定到意图键的 dedupe_key,重复投递只写一条。

验证:go test ./... 全绿;-tags integration 下 3 个用例在真实 MySQL 上
通过(重复事件 1 行评论 + 热度只加 1、空 event_id 落 NULL 键、重复删除)
2026-10-30 13:29:08 +08:00
leonincs
732e284369 style: 统一代码格式和行尾 2026-05-20 16:34:19 +08:00
Sisyphus
15f86f08ae fix(P2): 修复 import cycle — 将 apierror 移出 internal/http 避免循环依赖 2026-04-25 16:18:57 +08:00
Sisyphus
025be6dd78 refactor(P2): Handler 错误码精确化 — service 层引入哨兵错误,handler 层用 ClassifyHTTPStatus 分类 2026-04-25 16:03:29 +08:00
leonincs
d7a0e2a6b7 fix feed empty list rendering 2026-04-23 19:05:44 +08:00
Leon
631cb2203f feat: 评论相关rabbitMQ 2025-12-30 01:25:54 +08:00
Leon
fbd0cd38ec refactor: 将redis提取到middleware文件夹 2025-12-28 18:38:14 +08:00
Leon
328fae5f07 feat:添加热榜功能并添加了增加热度的方法。 2025-12-26 22:49:17 +08:00
Leon
9ba916643e move: 后端 2025-12-25 22:40:20 +08:00