docs: 修复通知系统设计文档问题
修复内容: - 修正章节编号 8.2 -> 8.3 - 查询逻辑增加 star_id 条件 - HTTP 接口说明增加 star_id 传递方式 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
ec46004551
commit
7d119d34ba
@ -164,6 +164,8 @@ CREATE TABLE notification_stats (
|
||||
| POST | /api/v1/notifications/read-all | 全部标已读 |
|
||||
| DELETE | /api/v1/notifications/:id | 删除通知 |
|
||||
|
||||
> **说明**:所有 HTTP 接口都需要通过 Header 或 Cookie 传递 `star_id` 进行数据隔离。
|
||||
|
||||
### 4.3 查询参数
|
||||
|
||||
```
|
||||
@ -174,6 +176,7 @@ GET /api/v1/notifications?type=like&tab=today&page=1&pageSize=20
|
||||
- tab: 查询tab (today / history)
|
||||
- page: 页码
|
||||
- pageSize: 每页数量
|
||||
- star_id: 数据隔离 ID(从 Header 或上下文获取)
|
||||
```
|
||||
|
||||
---
|
||||
@ -198,14 +201,16 @@ GET /api/v1/notifications?type=like&tab=today&page=1&pageSize=20
|
||||
|
||||
```
|
||||
今日 Tab:
|
||||
WHERE type = 'like' AND user_id = ? AND created_at >= 今日零点
|
||||
WHERE type = 'like' AND user_id = ? AND star_id = ? AND created_at >= 今日零点
|
||||
ORDER BY created_at DESC
|
||||
|
||||
历史 Tab:
|
||||
WHERE type = 'like' AND user_id = ? AND created_at < 今日零点
|
||||
WHERE type = 'like' AND user_id = ? AND star_id = ? AND created_at < 今日零点
|
||||
ORDER BY created_at DESC
|
||||
```
|
||||
|
||||
> **说明**:所有查询都需要 `star_id` 确保数据隔离。
|
||||
|
||||
### 5.3 未读数统计
|
||||
|
||||
- 每次创建通知时,在同一事务中更新 `notification_stats` 表对应类型的未读数
|
||||
@ -291,7 +296,7 @@ ON notifications (user_id, star_id, type, data->>'target_id', data->>'actor_id',
|
||||
|
||||
> **说明**:如果业务上允许同一天多条点赞通知(每条都展示),则不需要此唯一约束。
|
||||
|
||||
### 8.2 补偿机制
|
||||
### 8.3 补偿机制
|
||||
|
||||
如果事务提交后 RPC 调用方未收到响应,调用方会重试。此时:
|
||||
- 使用唯一约束 `UNIQUE (user_id, star_id, type, target_type, target_id, actor_id, date)` 防止重复创建点赞通知
|
||||
|
||||
Loading…
Reference in New Issue
Block a user