Files
xk-docs/docs/projects/xk-admin/modules/notice.md
2026-07-08 15:04:42 +08:00

65 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 通知公告模块
## 功能概述
管理系统内部通知公告的发布、已读/未读状态管理。支持全员公告和指定用户通知。
## 通知类型
| 类型 | 说明 |
|------|------|
| `type=0` | 全员公告(仅平台管理员可发) |
| `type>0` | 指定用户通知 |
## 核心流程
```mermaid
graph TB
A[管理员发送通知] --> B{type=0?}
B -->|是| C[全员公告<br/>所有管理员可见]
B -->|否| D[指定用户通知<br/>仅选中用户可见]
C --> E[用户查看已读]
D --> E
E --> F{全部已读?}
F -->|是| G[通知状态标记为已读]
F -->|否| H[保持未读状态]
```
## 数据模型
| 模型 | 表名 | 说明 |
|------|------|------|
| `AdminNoticeModel` | `xk_admin_notice` | 通知主体(标题、内容、类型、发布人) |
| `AdminNoticeRelationsModel` | `xk_admin_notice_relations` | 通知-用户关联(已读状态) |
### 通知字段
| 字段 | 说明 |
|------|------|
| `title` | 通知标题 |
| `detail` | 摘要 |
| `content` | 详细内容 |
| `type` | 通知类型0=全员) |
| `edit_type` | 编辑类型 |
| `user_id` | 发布人 ID |
| `status` | 全局已读状态0=未全读, 1=全部已读) |
## 对应 API
| 方法 | 路径 | 说明 |
|------|------|------|
| GET | `api/admin/notice/list` | 通知列表(当前用户) |
| GET | `api/admin/notice/detail` | 通知详情(自动标记已读) |
| POST | `api/admin/notice/read` | 标记单条已读 |
| POST | `api/admin/notice/read-all` | 全部已读 |
| POST | `api/admin/notice/send` | 发送通知 |
| GET | `api/admin/notice/user-option` | 接收人下拉列表 |
## 关联类
| 类 | 路径 | 说明 |
|----|------|------|
| `NoticeController` | `app/Service/admin/notice/NoticeController.php` | 控制器 |
| `NoticeService` | `app/Service/admin/notice/NoticeService.php` | 服务层 |
| `SendToUserNoticeJob` | `app/Jobs/admin/notices/SendToUserNoticeJob.php` | 异步发送 Job |