From a38267caf7ac47e2c93ca93758b276bebf19d8b9 Mon Sep 17 00:00:00 2001 From: qzl Date: Fri, 10 Apr 2026 18:51:30 +0800 Subject: [PATCH] chore: record journal --- .trellis/workspace/zl-q/index.md | 9 +++-- .trellis/workspace/zl-q/journal-1.md | 58 ++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/.trellis/workspace/zl-q/index.md b/.trellis/workspace/zl-q/index.md index 3ec2969..5bbfd05 100644 --- a/.trellis/workspace/zl-q/index.md +++ b/.trellis/workspace/zl-q/index.md @@ -8,8 +8,8 @@ - **Active File**: `journal-1.md` -- **Total Sessions**: 0 -- **Last Active**: - +- **Total Sessions**: 1 +- **Last Active**: 2026-04-10 --- @@ -19,7 +19,7 @@ | File | Lines | Status | |------|-------|--------| -| `journal-1.md` | ~0 | Active | +| `journal-1.md` | ~65 | Active | --- @@ -29,6 +29,7 @@ | # | Date | Title | Commits | |---|------|-------|---------| +| 1 | 2026-04-10 | 实现站内通知系统 | `3f3d613` | --- @@ -37,4 +38,4 @@ - Sessions are appended to journal files - New journal file created when current exceeds 2000 lines -- Use `add_session.py` to record sessions +- Use `add_session.py` to record sessions \ No newline at end of file diff --git a/.trellis/workspace/zl-q/journal-1.md b/.trellis/workspace/zl-q/journal-1.md index 7530958..9b3db17 100644 --- a/.trellis/workspace/zl-q/journal-1.md +++ b/.trellis/workspace/zl-q/journal-1.md @@ -5,3 +5,61 @@ --- + + +## Session 1: 实现站内通知系统 + +**Date**: 2026-04-10 +**Task**: 实现站内通知系统 + +### Summary + +(Add summary) + +### Main Changes + +## 完成内容 + +| 模块 | 描述 | +|------|------| +| 协议文档 | `docs/protocols/notification/notification-inbox-protocol.md` 及 `http-error-codes.md` 新增 `NOTIFICATION_NOT_FOUND` | +| 数据库迁移 | `notifications` + `user_notifications` 两张表, RLS 策略, 索引 | +| 后端 ORM | `Notification(TimestampMixin, SoftDeleteMixin, Base)` + `UserNotification(TimestampMixin, Base)` | +| 后端 API | schema/repository/service/router 全套, 4 个端点 (列表/未读数/单条已读/全部已读) | +| 后端测试 | 19 个单元测试覆盖: 列表权限隔离, 未读数统计, 幂等已读, 越权拒绝, 撤销/删除过滤, payload 解析 | +| Flutter models | `NotificationPayload` sealed class (none/open_route/open_url) + `NotificationItem` + `NotificationListResult` | +| Flutter API | `NotificationApi` (list/unreadCount/markRead/markAllRead) | +| Flutter Repository | 抽象接口 + `NotificationRepositoryImpl` | +| Flutter Bloc | `NotificationBloc` (ChangeNotifier) 含 Realtime 事件处理 | +| Flutter UI | `NotificationCenterScreen` + `NotificationListItem` + 首页 badge 集成 | +| Flutter 测试 | 14 个测试: payload 解析 6 个 + bloc 状态管理 8 个 | + +## 验收标准对照 + +- [x] 能为指定用户写入一条站内通知 (ORM + migration 就绪) +- [x] 用户能看到自己的通知列表 (GET /notifications) +- [x] 用户点击通知后可标记为已读 (PATCH /notifications/{id}/read) +- [x] "全部已读"后未读数归零 (PATCH /notifications/mark-all-read) +- [x] 用户 A 不能读取或修改用户 B 的通知 (service 层 user_id 来自 JWT, 测试覆盖) +- [x] 已读接口重复调用不会报错 (幂等实现, 测试覆盖) +- [x] 首页 badge 会随未读数自动更新 (NotificationBloc + ListenableBuilder) +- [x] 撤销或统一删除主通知后, 用户侧列表不再展示 (repository 过滤 status+deleted_at) + + +### Git Commits + +| Hash | Message | +|------|---------| +| `3f3d613` | (see git log) | + +### Testing + +- [OK] (Add test results) + +### Status + +[OK] **Completed** + +### Next Steps + +- None - task complete