通知中心
分页获取当前用户的通知列表,支持按类型和已读状态筛选。
| 项目 | 内容 |
|---|---|
| Method | GET |
| URL | /api/notifications |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | int | 否 | 页码,默认 1 |
| per_page | int | 否 | 每页条数,默认 15 |
| type | string | 否 | 按通知类型筛选 |
| is_read | int | 否 | 按已读状态筛选,0 未读,1 已读 |
curl -X GET "/api/notifications?page=1&per_page=15&is_read=0" \ -H "Authorization: Bearer your_token_here"| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data | object | 分页通知列表 |
{ "code": 0, "message": "success", "data": { "list": [ { "id": 101, "type": "system", "title": "系统通知", "content": "您有一条新消息。", "is_read": 0, "created_at": "2026-07-05T10:00:00Z" } ], "total": 5, "per_page": 15, "current_page": 1, "last_page": 1 }}{ "code": 401, "message": "未授权", "data": null}获取当前用户的未读通知总数,常用于角标展示。
| 项目 | 内容 |
|---|---|
| Method | GET |
| URL | /api/notifications/unread-count |
| 鉴权 | 是,Bearer Token |
本接口无请求参数。
curl -X GET "/api/notifications/unread-count" \ -H "Authorization: Bearer your_token_here"| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data.count | int | 未读通知数量 |
{ "code": 0, "message": "success", "data": { "count": 5 }}{ "code": 401, "message": "未授权", "data": null}将指定通知标记为已读状态。
| 项目 | 内容 |
|---|---|
| Method | PUT |
| URL | /api/notifications/{id}/read |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | int | 是 | 路径参数,通知 ID |
curl -X PUT "/api/notifications/101/read" \ -H "Authorization: Bearer your_token_here"| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 固定为 标记成功 |
| data | null | 无数据返回 |
{ "code": 0, "message": "标记成功", "data": null}{ "code": 404, "message": "通知不存在", "data": null}将当前用户所有未读通知批量标记为已读。
| 项目 | 内容 |
|---|---|
| Method | PUT |
| URL | /api/notifications/all/read |
| 鉴权 | 是,Bearer Token |
本接口无请求参数。
curl -X PUT "/api/notifications/all/read" \ -H "Authorization: Bearer your_token_here"| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data.affected | int | 本次标记为已读的通知数量 |
{ "code": 0, "message": "success", "data": { "affected": 5 }}{ "code": 401, "message": "未授权", "data": null}