Files
EchoChat/docs/api/notify.md
bujinyuan 44fa5a3830 docs: 统一时间格式为亚洲友好的日期时间字符串
所有文档中的时间字段统一为 yyyy-MM-dd HH:mm:ss 格式(Asia/Shanghai):
- 移除 ISO 8601 格式(2026-02-27T10:00:00Z)
- 移除 Unix 时间戳(1740700000)
- 响应字段从 timestamp(int64) 改为 time(string)
- API README 新增「时间格式规范」章节
- 涉及 10 个文档文件

Made-with: Cursor
2026-02-28 09:47:42 +08:00

2.4 KiB
Raw Blame History

通知模块 API (Notify)

通用规范(认证方式、响应格式、错误码)见 README.md 新通知的实时推送通过 WebSocket 完成,见 websocket.md


接口列表

方法 路径 权限 说明
GET /api/v1/notifications 需认证 获取通知列表
PUT /api/v1/notifications/:id/read 需认证 标记通知已读
PUT /api/v1/notifications/read-all 需认证 全部标记已读

1. 获取通知列表

GET /api/v1/notifications

权限: 需认证

查询参数:

参数 类型 默认值 说明
is_read bool 筛选已读/未读,不传则返回全部
type string 筛选通知类型meeting_invite / friend_request / friend_accepted / meeting_reminder / system
page int 1 页码
page_size int 20 每页数量

成功响应:

{
    "code": 0,
    "message": "ok",
    "data": {
        "list": [
            {
                "id": 1,
                "type": "meeting_invite",
                "title": "会议邀请",
                "content": "张三邀请你参加会议「产品需求讨论」",
                "extra": {
                    "room_code": "123-456-789",
                    "room_title": "产品需求讨论",
                    "from_user_id": 1,
                    "from_username": "zhangsan"
                },
                "is_read": false,
                "created_at": "2026-02-27 10:00:00"
            },
            {
                "id": 2,
                "type": "friend_request",
                "title": "好友申请",
                "content": "李四请求添加你为好友",
                "extra": {
                    "from_user_id": 2,
                    "from_username": "lisi",
                    "message": "我是你的同事"
                },
                "is_read": false,
                "created_at": "2026-02-27 09:30:00"
            }
        ],
        "total": 15,
        "page": 1,
        "page_size": 20
    }
}

2. 标记通知已读

PUT /api/v1/notifications/:id/read

权限: 需认证

路径参数: id — 通知 ID


3. 全部标记已读

PUT /api/v1/notifications/read-all

权限: 需认证

说明: 将当前用户的所有未读通知标记为已读。