feat: 更新 PocketBase API 路由,增强认证安全性

- 修改登录路由为 `/pb/api/wechat/login`,新增局部 try/catch 以保留业务状态码并返回统一结构 `{ code, msg, data }`。
- 更新所有相关 API 路由前缀为 `/pb`,包括系统、平台、字典、附件和文档接口。
- 新增文档接口支持多个附件 ID,更新 OpenAPI 文档以反映这些变化。
- 在数据库模式中添加对字典名称的唯一索引,确保全局唯一性。
- 更新文档字段,设置 `document_title` 和 `document_type` 为必填项,并在验证过程中检查字段的必填属性。
This commit is contained in:
2026-03-27 13:55:06 +08:00
parent 9feb0bb3a0
commit c43aae783f
9 changed files with 749 additions and 206 deletions

View File

@@ -467,20 +467,48 @@ components:
type: string
document_image:
type: string
description: 关联 `attachments_id`
description: 关联多个 `attachments_id`,底层使用 `|` 分隔保存
document_image_ids:
type: array
description: `document_image` 解析后的附件 id 列表
items:
type: string
document_image_urls:
type: array
description: 根据 `document_image -> tbl_attachments` 自动解析出的图片文件流链接列表
items:
type: string
document_image_url:
type: string
description: 根据 `document_image -> tbl_attachments` 自动解析出的图片文件流链接
description: 兼容字段,返回第一张图片文件流链接
document_image_attachments:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
document_image_attachment:
allOf:
- $ref: '#/components/schemas/AttachmentRecord'
nullable: true
document_video:
type: string
description: 关联 `attachments_id`
description: 关联多个 `attachments_id`,底层使用 `|` 分隔保存
document_video_ids:
type: array
description: `document_video` 解析后的附件 id 列表
items:
type: string
document_video_urls:
type: array
description: 根据 `document_video -> tbl_attachments` 自动解析出的视频文件流链接列表
items:
type: string
document_video_url:
type: string
description: 根据 `document_video -> tbl_attachments` 自动解析出的视频文件流链接
description: 兼容字段,返回第一个视频文件流链接
document_video_attachments:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
document_video_attachment:
allOf:
- $ref: '#/components/schemas/AttachmentRecord'
@@ -546,6 +574,7 @@ components:
example: DOC-1743037200000-abc123
DocumentMutationRequest:
type: object
required: [document_title, document_type]
properties:
document_id:
type: string
@@ -570,11 +599,21 @@ components:
document_content:
type: string
document_image:
type: string
description: 图片附件的 `attachments_id`
oneOf:
- type: string
description: 多个图片附件 id 使用 `|` 分隔
- type: array
items:
type: string
description: 图片附件 id 列表;支持数组或 `|` 分隔字符串
document_video:
type: string
description: 视频附件的 `attachments_id`
oneOf:
- type: string
description: 多个视频附件 id 使用 `|` 分隔
- type: array
items:
type: string
description: 视频附件 id 列表;支持数组或 `|` 分隔字符串
document_relation_model:
type: string
document_keywords:
@@ -1222,8 +1261,8 @@ paths:
description: |
仅允许 `ManagePlatform` 用户访问。
支持按标题、摘要、关键词等字段模糊搜索,并可按 `document_status`、`document_type` 过滤。
返回结果会自动根据 `document_image`、`document_video` 关联 `tbl_attachments`
额外补充 `document_image_url`、`document_video_url` 以及对应附件对象。
返回结果会自动根据 `document_image`、`document_video` 中的多个 `attachments_id` 关联 `tbl_attachments`
额外补充 `document_image_urls`、`document_video_urls` 以及对应附件对象数组
requestBody:
required: false
content:
@@ -1259,7 +1298,7 @@ paths:
summary: 查询文档详情
description: |
仅允许 `ManagePlatform` 用户访问。
按 `document_id` 查询单条文档,并返回与附件表联动解析后的文件流链接。
按 `document_id` 查询单条文档,并返回与附件表联动解析后的文件流链接。
requestBody:
required: true
content:
@@ -1295,7 +1334,8 @@ paths:
description: |
仅允许 `ManagePlatform` 用户访问。
`document_id` 可选;未传时服务端自动生成。
`document_image`、`document_video` 需传入已存在于 `tbl_attachments` 的 `attachments_id`
`document_title`、`document_type` 为必填;其余字段均允许为空
`document_image`、`document_video` 支持传入多个已存在于 `tbl_attachments` 的 `attachments_id`。
成功后会同步写入一条 `tbl_document_operation_history`,操作类型为 `create`。
requestBody:
required: true
@@ -1331,7 +1371,9 @@ paths:
summary: 修改文档
description: |
仅允许 `ManagePlatform` 用户访问。
按 `document_id` 定位现有文档并更新;若传入 `document_image`、`document_video`,则必须是已存在的 `attachments_id`
按 `document_id` 定位现有文档并更新。
`document_title`、`document_type` 为必填;其余字段均允许为空。
若传入 `document_image`、`document_video`,则支持多个 `attachments_id`,并会逐一校验是否存在。
成功后会同步写入一条 `tbl_document_operation_history`,操作类型为 `update`。
requestBody:
required: true