签入版本
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
# 6.8 公告与链接管理
|
||||
|
||||
:::tip 概述
|
||||
本节涵盖通知公告和友情链接两个模块,均继承 BaseTenantLogic 实现租户隔离。
|
||||
|
||||
> **说明:** 本文件因历史原因命名为 `content.md`,实际文档内容为通知公告(Notice)和友情链接(Link)两个独立模块,并不存在 "Content" 模块。
|
||||
:::
|
||||
|
||||
## 通知公告
|
||||
|
||||
### 模块特点
|
||||
|
||||
| 特性 | 说明 |
|
||||
|------|------|
|
||||
| 基类 | BaseTenantLogic(租户隔离) |
|
||||
| 文件字段 | cover(封面图),保存到 notice 目录 |
|
||||
| 富文本字段 | content(公告内容) |
|
||||
| 枚举映射 | type → notice_type(1=通知 2=公告),status → notice_status |
|
||||
| 排序 | 按 id 倒序(最新在前) |
|
||||
|
||||
### 核心代码
|
||||
|
||||
```php
|
||||
// app/logic/NoticeLogic.php
|
||||
|
||||
class NoticeLogic extends BaseTenantLogic
|
||||
{
|
||||
/**
|
||||
* 关联的模型类
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $modelClass = Notice::class;
|
||||
|
||||
/**
|
||||
* 需要自动处理的文件上传字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $fileFields = ['cover'];
|
||||
|
||||
/**
|
||||
* 文件保存的子目录
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $fileSaveDir = 'notice';
|
||||
|
||||
/**
|
||||
* LIKE 模糊匹配字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $pageLikeFields = ['title'];
|
||||
|
||||
/**
|
||||
* 精确匹配字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $pageEqFields = ['type', 'status'];
|
||||
|
||||
/**
|
||||
* 默认排序规则
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $pageOrderBy = [
|
||||
['field' => 'tenant_id', 'type' => 'asc'],
|
||||
['field' => 'id', 'type' => 'desc'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 枚举显示名映射
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $serializeMaps = [
|
||||
'type' => 'notice_type',
|
||||
'status' => 'notice_status',
|
||||
];
|
||||
|
||||
/**
|
||||
* 富文本字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $contentFields = ['content'];
|
||||
}
|
||||
```
|
||||
|
||||
### API 接口
|
||||
|
||||
| 方法 | 路径 | 权限码 | 说明 |
|
||||
|------|------|--------|------|
|
||||
| GET | `/api/notice/page` | sys:notice:page | 分页列表 |
|
||||
| GET | `/api/notice/list` | - | 全量列表 |
|
||||
| GET | `/api/notice/detail/:id` | sys:notice:detail | 详情 |
|
||||
| POST | `/api/notice/add` | sys:notice:add | 新增 |
|
||||
| PUT | `/api/notice/update` | sys:notice:update | 修改 |
|
||||
| DELETE | `/api/notice/delete/:id` | sys:notice:delete | 删除 |
|
||||
| DELETE | `/api/notice/batchDelete` | sys:notice:batchDelete | 批量删除 |
|
||||
|
||||
---
|
||||
|
||||
## 友情链接
|
||||
|
||||
### 模块特点
|
||||
|
||||
| 特性 | 说明 |
|
||||
|------|------|
|
||||
| 基类 | BaseTenantLogic(租户隔离) |
|
||||
| 文件字段 | image(友链Logo),保存到 link 目录 |
|
||||
| 枚举映射 | type → link_type,form → link_form,status → link_status |
|
||||
|
||||
### 核心代码
|
||||
|
||||
```php
|
||||
// app/logic/LinkLogic.php
|
||||
|
||||
class LinkLogic extends BaseTenantLogic
|
||||
{
|
||||
/**
|
||||
* 关联的模型类
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $modelClass = Link::class;
|
||||
|
||||
/**
|
||||
* 需要自动处理的文件上传字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $fileFields = ['image'];
|
||||
|
||||
/**
|
||||
* 文件保存的子目录
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $fileSaveDir = 'link';
|
||||
|
||||
/**
|
||||
* LIKE 模糊匹配字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $pageLikeFields = ['name'];
|
||||
|
||||
/**
|
||||
* 精确匹配字段
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $pageEqFields = ['type', 'status'];
|
||||
|
||||
/**
|
||||
* 默认排序规则
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $pageOrderBy = [
|
||||
['field' => 'tenant_id', 'type' => 'asc'],
|
||||
['field' => 'sort', 'type' => 'asc'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 枚举显示名映射
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $serializeMaps = [
|
||||
'type' => 'link_type',
|
||||
'form' => 'link_form',
|
||||
'status' => 'link_status',
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
### API 接口
|
||||
|
||||
| 方法 | 路径 | 权限码 | 说明 |
|
||||
|------|------|--------|------|
|
||||
| GET | `/api/link/page` | sys:link:page | 分页列表 |
|
||||
| GET | `/api/link/detail/:id` | sys:link:detail | 详情 |
|
||||
| POST | `/api/link/add` | sys:link:add | 新增 |
|
||||
| PUT | `/api/link/update` | sys:link:update | 修改 |
|
||||
| DELETE | `/api/link/delete/:id` | sys:link:delete | 删除 |
|
||||
| DELETE | `/api/link/batchDelete` | sys:link:batchDelete | 批量删除 |
|
||||
Reference in New Issue
Block a user