feat: 添加 PocketBase 管理端与自定义 hooks 的 API 文档

- 新增 openapi.yaml 文件,定义管理端与自定义 hooks 的接口文档,包括系统、微信认证、平台认证、字典管理、附件管理、文档管理、购物车和订单等接口。
- 新增 order.yaml 文件,定义订单相关的接口,包括查询订单列表、查询订单详情、新增订单记录、修改订单记录和删除订单记录的请求和响应结构。
- 新增 openapi-wx/openapi.yaml 文件,定义 PocketBase 原生 API 文档,包含企业信息、附件信息、产品信息、文档信息、购物车和订单的接口。
- 新增 pocketbase.scheme.js 文件,包含 PocketBase 集合的创建和更新逻辑,定义了多个集合的字段、索引和权限规则。
This commit is contained in:
2026-04-08 20:14:22 +08:00
parent e47060f54f
commit 0bdaf54eed
36 changed files with 4391 additions and 2418 deletions

View File

@@ -1,54 +1,29 @@
openapi: 3.1.0
info:
title: BAI PocketBase WeChat API
title: BAI PocketBase Native API
version: 1.0.0-wx
description: |
面向微信端的小程序接口文档
本文档包含微信登录、微信资料完善,以及微信小程序侧会直接调用的业务接口。
微信小程序调用适配说明:
- 除 `/pb/api/wechat/login` 外,调用购物车 / 订单的 PocketBase 原生 records API 时都需要在请求头中携带 `Authorization: Bearer <token>`
- `token` 取自 `/pb/api/wechat/login` 成功返回的认证 token
- 小程序端应统一使用 HTTPS不依赖 Cookie / Session
- 购物车与订单同时提供两套调用说明:`/pb/api/cart/*`、`/pb/api/order/*` 为自定义 hooks API`/pb/api/collections/.../records` 为 PocketBase 原生 records API
- 按当前 collection 规则,创建 `tbl_cart` / `tbl_order` 原生 records 时,客户端必须显式提交 owner 字段,且值必须等于当前 token 对应的 `openid`
- 当前仓库中 `DELETE` 对应的 hooks 实现仍是物理删除;若要满足“仅将 `is_delete` 标记为 `1`”的软删除契约,需同步调整后端服务实现
- 当前仓库中购物车 / 订单 hooks 列表与详情接口尚未显式按 `is_delete = 0` 过滤;若要完全满足软删除检索约束,需同步调整后端服务实现
license:
name: Proprietary
identifier: LicenseRef-Proprietary
顶层兼容入口
当前原生 API 文档已整理到 `spec/openapi-wx/` 目录下;本文件保留为兼容总入口。
servers:
- url: https://bai-api.blv-oa.com
description: 生产环境
- url: http://127.0.0.1:8090
description: PocketBase 本地环境
tags:
- name: 系统
description: 微信端共用系统接口
- name: 微信认证
description: 微信登录、资料完善与 token 刷新接口
- name: 企业信息
description: 通过 PocketBase 原生 records API 访问 `tbl_company`
description: PocketBase 原生公司记录接口
- name: 附件信息
description: 通过 PocketBase 原生 records API 访问 `tbl_attachments`
description: PocketBase 原生附件记录接口
- name: 产品信息
description: 通过 PocketBase 原生 records API 访问 `tbl_product_list`
description: PocketBase 原生产品记录接口
- name: 文档信息
description: 通过 PocketBase 原生 records API 访问 `tbl_document`
description: PocketBase 原生文档记录接口
- name: 购物车
description: 微信小程序侧购物车 CRUD 接口
description: PocketBase 原生购物车记录接口
- name: 订单
description: 微信小程序侧订单 CRUD 接口
security: []
description: PocketBase 原生订单记录接口
paths:
/pb/api/system/users-count:
$ref: './openapi-wx/system.yaml#/paths/usersCount'
/pb/api/system/refresh-token:
$ref: './openapi-wx/system.yaml#/paths/refreshToken'
/pb/api/wechat/login:
$ref: './openapi-wx/wechat-auth.yaml#/paths/wechatLogin'
/pb/api/wechat/profile:
$ref: './openapi-wx/wechat-auth.yaml#/paths/wechatProfile'
/pb/api/collections/tbl_company/records:
$ref: './openapi-wx/company.yaml#/paths/companyRecords'
/pb/api/collections/tbl_company/records/{recordId}:
@@ -59,150 +34,11 @@ paths:
$ref: './openapi-wx/products.yaml#/paths/productRecords'
/pb/api/collections/tbl_document/records:
$ref: './openapi-wx/documents.yaml#/paths/documentRecords'
/pb/api/cart/list:
$ref: './openapi-wx/cart.yaml#/paths/cartList'
/pb/api/cart/detail:
$ref: './openapi-wx/cart.yaml#/paths/cartDetail'
/pb/api/cart/create:
$ref: './openapi-wx/cart.yaml#/paths/cartCreate'
/pb/api/cart/update:
$ref: './openapi-wx/cart.yaml#/paths/cartUpdate'
/pb/api/cart/delete:
$ref: './openapi-wx/cart.yaml#/paths/cartDelete'
/pb/api/collections/tbl_cart/records:
$ref: './openapi-wx/cart.yaml#/paths/cartRecords'
/pb/api/collections/tbl_cart/records/{recordId}:
$ref: './openapi-wx/cart.yaml#/paths/cartRecordById'
/pb/api/order/list:
$ref: './openapi-wx/order.yaml#/paths/orderList'
/pb/api/order/detail:
$ref: './openapi-wx/order.yaml#/paths/orderDetail'
/pb/api/order/create:
$ref: './openapi-wx/order.yaml#/paths/orderCreate'
/pb/api/order/update:
$ref: './openapi-wx/order.yaml#/paths/orderUpdate'
/pb/api/order/delete:
$ref: './openapi-wx/order.yaml#/paths/orderDelete'
/pb/api/collections/tbl_order/records:
$ref: './openapi-wx/order.yaml#/paths/orderRecords'
/pb/api/collections/tbl_order/records/{recordId}:
$ref: './openapi-wx/order.yaml#/paths/orderRecordById'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
ApiResponseBase:
$ref: './openapi-wx/system.yaml#/components/schemas/ApiResponseBase'
ErrorResponse:
$ref: './openapi-wx/system.yaml#/components/schemas/ErrorResponse'
SystemRefreshTokenRequest:
$ref: './openapi-wx/system.yaml#/components/schemas/SystemRefreshTokenRequest'
RefreshTokenResponse:
$ref: './openapi-wx/system.yaml#/components/schemas/RefreshTokenResponse'
UsersCountData:
$ref: './openapi-wx/system.yaml#/components/schemas/UsersCountData'
UsersCountResponse:
$ref: './openapi-wx/system.yaml#/components/schemas/UsersCountResponse'
UserInfo:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/UserInfo'
WechatLoginRequest:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatLoginRequest'
WechatProfileRequest:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatProfileRequest'
AuthSuccessData:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/AuthSuccessData'
AuthSuccessResponse:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/AuthSuccessResponse'
WechatProfileResponseData:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatProfileResponseData'
WechatProfileResponse:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatProfileResponse'
CompanyInfo:
$ref: './openapi-wx/wechat-auth.yaml#/components/schemas/CompanyInfo'
PocketBaseNativeError:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseNativeError'
PocketBaseRecordBase:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseRecordBase'
PocketBaseCompanyFields:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyFields'
PocketBaseCompanyRecord:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyRecord'
PocketBaseCompanyCreateRequest:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyCreateRequest'
PocketBaseCompanyUpdateRequest:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyUpdateRequest'
PocketBaseCompanyListResponse:
$ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyListResponse'
PocketBaseAttachmentRecord:
$ref: './openapi-wx/attachments.yaml#/components/schemas/PocketBaseAttachmentRecord'
PocketBaseAttachmentListResponse:
$ref: './openapi-wx/attachments.yaml#/components/schemas/PocketBaseAttachmentListResponse'
PocketBaseProductListFields:
$ref: './openapi-wx/products.yaml#/components/schemas/PocketBaseProductListFields'
PocketBaseProductListRecord:
$ref: './openapi-wx/products.yaml#/components/schemas/PocketBaseProductListRecord'
PocketBaseProductListListResponse:
$ref: './openapi-wx/products.yaml#/components/schemas/PocketBaseProductListListResponse'
PocketBaseDocumentFields:
$ref: './openapi-wx/documents.yaml#/components/schemas/PocketBaseDocumentFields'
PocketBaseDocumentRecord:
$ref: './openapi-wx/documents.yaml#/components/schemas/PocketBaseDocumentRecord'
PocketBaseDocumentListResponse:
$ref: './openapi-wx/documents.yaml#/components/schemas/PocketBaseDocumentListResponse'
HookRecordBase:
$ref: './openapi-wx/cart.yaml#/components/schemas/HookRecordBase'
CartRecord:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartRecord'
CartListRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartListRequest'
CartDetailRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartDetailRequest'
CartCreateRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartCreateRequest'
CartUpdateRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartUpdateRequest'
CartDeleteRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartDeleteRequest'
CartListResponse:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartListResponse'
CartDeleteResponse:
$ref: './openapi-wx/cart.yaml#/components/schemas/CartDeleteResponse'
PocketBaseCartFields:
$ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartFields'
PocketBaseCartRecord:
$ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartRecord'
PocketBaseCartCreateRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartCreateRequest'
PocketBaseCartUpdateRequest:
$ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartUpdateRequest'
PocketBaseCartListResponse:
$ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartListResponse'
OrderRecord:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderRecord'
OrderListRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderListRequest'
OrderDetailRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderDetailRequest'
OrderCreateRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderCreateRequest'
OrderUpdateRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderUpdateRequest'
OrderDeleteRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderDeleteRequest'
OrderListResponse:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderListResponse'
OrderDeleteResponse:
$ref: './openapi-wx/order.yaml#/components/schemas/OrderDeleteResponse'
PocketBaseOrderFields:
$ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderFields'
PocketBaseOrderRecord:
$ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderRecord'
PocketBaseOrderCreateRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderCreateRequest'
PocketBaseOrderUpdateRequest:
$ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderUpdateRequest'
PocketBaseOrderListResponse:
$ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderListResponse'