feat: 添加 PocketBase MiniApp 公司 API 文档和文件字段迁移脚本

- 新增 openapi-miniapp-company.yaml 文件,定义 tbl_company 的基础 CRUD 接口文档,包括查询、创建、更新和删除公司记录的详细描述和示例。
- 新增 pocketbase.file-fields-to-attachments.js 脚本,用于迁移 PocketBase 中的文件字段到文本字段,并处理 tbl_attachments 集合的公开规则。
This commit is contained in:
2026-03-28 15:13:04 +08:00
parent eaf282ea24
commit 51a90260e4
50 changed files with 4250 additions and 113 deletions

View File

@@ -120,6 +120,28 @@ components:
type: string
users_picture:
type: string
description: 用户头像附件的 `attachments_id`
users_picture_url:
type: string
description: 根据 `users_picture -> tbl_attachments` 自动解析出的头像文件流链接
users_id_pic_a:
type: string
description: 证件正面附件的 `attachments_id`
users_id_pic_a_url:
type: string
description: 根据 `users_id_pic_a -> tbl_attachments` 自动解析出的文件流链接
users_id_pic_b:
type: string
description: 证件反面附件的 `attachments_id`
users_id_pic_b_url:
type: string
description: 根据 `users_id_pic_b -> tbl_attachments` 自动解析出的文件流链接
users_title_picture:
type: string
description: 资质附件的 `attachments_id`
users_title_picture_url:
type: string
description: 根据 `users_title_picture -> tbl_attachments` 自动解析出的文件流链接
openid:
type: string
description: 全平台统一身份标识;微信用户为微信 openid平台用户为服务端生成的 GUID
@@ -180,6 +202,13 @@ components:
users_auth_type: 0
users_type: 注册用户
users_picture: ''
users_picture_url: ''
users_id_pic_a: ''
users_id_pic_a_url: ''
users_id_pic_b: ''
users_id_pic_b_url: ''
users_title_picture: ''
users_title_picture_url: ''
openid: app_momo
company_id: ''
users_parent_id: ''
@@ -211,7 +240,17 @@ components:
example: 2b7d9f2e3c4a5b6d7e8f
users_picture:
type: string
example: https://example.com/avatar.png
description: 用户头像附件的 `attachments_id`
example: ATT-1743123456789-abc123
users_id_pic_a:
type: string
description: 可选。证件正面附件的 `attachments_id`
users_id_pic_b:
type: string
description: 可选。证件反面附件的 `attachments_id`
users_title_picture:
type: string
description: 可选。资质附件的 `attachments_id`
WechatProfileResponseData:
type: object
properties:
@@ -239,9 +278,19 @@ components:
example: 12345678
users_picture:
type: string
example: https://example.com/avatar.png
description: 用户头像附件的 `attachments_id`
example: ATT-1743123456789-abc123
users_id_number:
type: string
users_id_pic_a:
type: string
description: 可选。证件正面附件的 `attachments_id`
users_id_pic_b:
type: string
description: 可选。证件反面附件的 `attachments_id`
users_title_picture:
type: string
description: 可选。资质附件的 `attachments_id`
users_level:
type: string
users_type:
@@ -480,52 +529,76 @@ components:
type: string
document_image:
type: string
description: 关联多个 `attachments_id`,底层使用 `|` 分隔保存
description: "关联多个 `attachments_id`,底层使用 `|` 分隔保存"
document_image_ids:
type: array
description: `document_image` 解析后的附件 id 列表
description: "`document_image` 解析后的附件 id 列表"
items:
type: string
document_image_urls:
type: array
description: 根据 `document_image -> tbl_attachments` 自动解析出的图片文件流链接列表
description: "根据 `document_image -> tbl_attachments` 自动解析出的图片文件流链接列表"
items:
type: string
document_image_url:
type: string
description: 兼容字段,返回第一张图片的文件流链接
description: "兼容字段,返回第一张图片的文件流链接"
document_image_attachments:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
document_image_attachment:
allOf:
anyOf:
- $ref: '#/components/schemas/AttachmentRecord'
nullable: true
- type: 'null'
document_video:
type: string
description: 关联多个 `attachments_id`,底层使用 `|` 分隔保存
description: "关联多个 `attachments_id`,底层使用 `|` 分隔保存"
document_video_ids:
type: array
description: `document_video` 解析后的附件 id 列表
description: "`document_video` 解析后的附件 id 列表"
items:
type: string
document_video_urls:
type: array
description: 根据 `document_video -> tbl_attachments` 自动解析出的视频文件流链接列表
description: "根据 `document_video -> tbl_attachments` 自动解析出的视频文件流链接列表"
items:
type: string
document_video_url:
type: string
description: 兼容字段,返回第一个视频的文件流链接
description: "兼容字段,返回第一个视频的文件流链接"
document_video_attachments:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
document_video_attachment:
allOf:
anyOf:
- $ref: '#/components/schemas/AttachmentRecord'
nullable: true
- type: 'null'
document_file:
type: string
description: "关联多个 `attachments_id`,底层使用 `|` 分隔保存"
document_file_ids:
type: array
description: "`document_file` 解析后的附件 id 列表"
items:
type: string
document_file_urls:
type: array
description: "根据 `document_file -> tbl_attachments` 自动解析出的文件流链接列表"
items:
type: string
document_file_url:
type: string
description: "兼容字段,返回第一个文件的文件流链接"
document_file_attachments:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
document_file_attachment:
anyOf:
- $ref: '#/components/schemas/AttachmentRecord'
- type: 'null'
document_owner:
type: string
description: 上传者 openid
@@ -630,6 +703,14 @@ components:
items:
type: string
description: 视频附件 id 列表;支持数组或 `|` 分隔字符串
document_file:
oneOf:
- type: string
description: 多个文件附件 id 使用 `|` 分隔
- type: array
items:
type: string
description: 文件附件 id 列表;支持数组或 `|` 分隔字符串
document_relation_model:
type: string
document_keywords:
@@ -1237,7 +1318,7 @@ paths:
summary: 删除附件
description: |
仅允许 `ManagePlatform` 用户访问。
按 `attachments_id` 真删除附件;若附件已被 `tbl_document.document_image``document_video` 引用,则拒绝删除。
按 `attachments_id` 真删除附件;若附件已被 `tbl_document.document_image``document_video` 或 `document_file` 引用,则拒绝删除。
requestBody:
required: true
content:
@@ -1278,8 +1359,8 @@ paths:
description: |
仅允许 `ManagePlatform` 用户访问。
支持按标题、摘要、关键词等字段模糊搜索,并可按 `document_status`、`document_type` 过滤。
返回结果会自动根据 `document_image`、`document_video` 中的多个 `attachments_id` 关联 `tbl_attachments`
额外补充 `document_image_urls`、`document_video_urls` 以及对应附件对象数组。
返回结果会自动根据 `document_image`、`document_video`、`document_file` 中的多个 `attachments_id` 关联 `tbl_attachments`
额外补充 `document_image_urls`、`document_video_urls`、`document_file_urls` 以及对应附件对象数组。
requestBody:
required: false
content:
@@ -1352,7 +1433,7 @@ paths:
仅允许 `ManagePlatform` 用户访问。
`document_id` 可选;未传时服务端自动生成。
`document_title`、`document_type` 为必填;其余字段均允许为空。
`document_image`、`document_video` 支持传入多个已存在于 `tbl_attachments` 的 `attachments_id`。
`document_image`、`document_video`、`document_file` 支持传入多个已存在于 `tbl_attachments` 的 `attachments_id`。
成功后会同步写入一条 `tbl_document_operation_history`,操作类型为 `create`。
requestBody:
required: true
@@ -1390,7 +1471,7 @@ paths:
仅允许 `ManagePlatform` 用户访问。
按 `document_id` 定位现有文档并更新。
`document_title`、`document_type` 为必填;其余字段均允许为空。
若传入 `document_image`、`document_video`,则支持多个 `attachments_id`,并会逐一校验是否存在。
若传入 `document_image`、`document_video`、`document_file`,则支持多个 `attachments_id`,并会逐一校验是否存在。
成功后会同步写入一条 `tbl_document_operation_history`,操作类型为 `update`。
requestBody:
required: true