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,157 +1,155 @@
paths:
cartList:
post:
operationId: postCartList
tags:
- 购物车
summary: 按索引字段模糊查询购物车列表
cartRecords:
get:
tags: [购物车]
summary: 查询购物车记录列表
description: |
调用自定义 hooks API 查询当前登录用户的购物车列表
查询规则:
- 仅允许查询当前 `Authorization` 对应用户自己的购物车记录
- 支持通过 `keyword` 对多个索引相关字段做统一模糊搜索,当前实现覆盖:
- `cart_id`
- `cart_number`
- `cart_product_id`
- `product_name`
- 支持按 `cart_status` 精确过滤
- 支持按 `cart_number` 精确过滤
目标软删除契约:
- 目标行为应仅返回 `is_delete = 0` 的记录
- 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准
security:
- BearerAuth: []
requestBody:
required: false
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/CartListRequest
example:
keyword: 对 cart_id、cart_number、cart_product_id 等索引相关字段的统一模糊搜索关键字|string
cart_status: 购物车状态精确过滤|string
cart_number: 购物车名称或分组号精确过滤|string
使用 PocketBase 原生 records list 接口查询 `tbl_cart`
如需鉴权,请自行在请求头中携带 `Authorization: Bearer <token>`。
parameters:
- name: filter
in: query
required: false
schema:
type: string
description: PocketBase 原生过滤表达式
example: cart_id="购物车业务ID|string"
- name: page
in: query
required: false
schema:
type: integer
minimum: 1
default: 1
- name: perPage
in: query
required: false
schema:
type: integer
minimum: 1
default: 20
- name: sort
in: query
required: false
schema:
type: string
example: -cart_create
responses:
"200":
'200':
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/CartListResponse
example:
items:
- pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
cart_id: 购物车业务 ID|string
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|integer
cart_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
product_name: 产品名称(服务端联动补充)|string
product_modelnumber: 产品型号(服务端联动补充)|string
product_basic_price: 产品基础价格(服务端联动补充)|integer
"400":
description: 参数错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"401":
description: token 缺失、无效或已过期
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"415":
description: 请求体必须为 application/json
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
$ref: '#/components/schemas/PocketBaseCartListResponse'
'400':
description: 查询参数错误
'401':
description: token 无效或已过期
'403':
description: 无权访问
'500':
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
cartDetail:
post:
operationId: postCartDetail
tags:
- 购物车
summary: 按 cart_id 精确查询购物车详情
tags: [购物车]
summary: 创建购物车记录
description: |
调用自定义 hooks API 按 `cart_id` 查询单条购物车记录。
查询规则:
- 仅允许访问当前 `Authorization` 对应用户自己的购物车记录
- 查询键为业务 ID `cart_id`,不是 PocketBase 原生 `recordId`
目标软删除契约:
- 目标行为应仅允许查询 `is_delete = 0` 的记录
- 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准
security:
- BearerAuth: []
使用 PocketBase 原生 records create 接口向 `tbl_cart` 新增记录。
如集合规则要求 `cart_owner` 与当前用户一致,请客户端显式提交。
requestBody:
required: true
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/CartDetailRequest
$ref: '#/components/schemas/PocketBaseCartCreateRequest'
example:
cart_id: 购物车业务 ID|string
cart_id: 购物车业务ID|string
cart_number: 购物车名称或分组号|string
cart_owner: 购物车所有者openid|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|number
cart_remark: 备注|string
responses:
"200":
description: 查询成功
'200':
description: 创建成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/CartRecord
example:
pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
cart_id: 购物车业务 ID|string
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|integer
cart_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
product_name: 产品名称(服务端联动补充)|string
product_modelnumber: 产品型号(服务端联动补充)|string
product_basic_price: 产品基础价格(服务端联动补充)|integer
$ref: '#/components/schemas/PocketBaseCartRecord'
'400':
description: 参数错误或违反集合规则
'401':
description: token 无效或已过期
'403':
description: 无权访问
'500':
description: 服务端错误
cartRecordById:
patch:
tags: [购物车]
summary: 更新购物车记录
description: |
使用 PocketBase 原生 records update 接口更新 `tbl_cart`。
路径参数使用 PocketBase 原生 `recordId`。
parameters:
- name: recordId
in: path
required: true
schema:
type: string
example: PocketBase记录主键|string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PocketBaseCartUpdateRequest'
example:
cart_number: 购物车名称或分组号|string
cart_owner: 购物车所有者openid|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|number
cart_remark: 备注|string
responses:
'200':
description: 更新成功
content:
application/json:
schema:
$ref: '#/components/schemas/PocketBaseCartRecord'
'400':
description: 参数错误
'401':
description: token 无效或已过期
'404':
description: 记录不存在
'500':
description: 服务端错误
delete:
tags: [购物车]
summary: 删除购物车记录
description: |
使用 PocketBase 原生 records delete 接口删除 `tbl_cart`。
路径参数使用 PocketBase 原生 `recordId`。
parameters:
- name: recordId
in: path
required: true
schema:
type: string
example: PocketBase记录主键|string
responses:
'204':
description: 删除成功
'401':
description: token 无效或已过期
'404':
description: 记录不存在
'500':
description: 服务端错误
"400":
description: 参数错误
content:
@@ -231,7 +229,8 @@ paths:
- 服务端自动根据当前 token 写入 `cart_owner`
- 服务端自动生成 `cart_id`
- 若未传 `cart_number`,服务端会自动生成展示编号
- `cart_product_id`、`cart_product_quantity`、`cart_at_price` 为必填
- `cart_product_id` 为必填;当前 hooks 与库结构保持一致,必须传 `tbl_product_list` 的 `recordId`
- `cart_product_quantity`、`cart_at_price` 为必填
目标软删除契约:
- 新建记录应默认为 `is_delete = 0`
@@ -246,7 +245,7 @@ paths:
$ref: ../openapi-wx.yaml#/components/schemas/CartCreateRequest
example:
cart_number: 可选;未传时服务端自动生成|string
cart_product_id: 产品业务 ID|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: 产品数量,需为正整数|integer
cart_status: 可选;未传时默认 有效|string
cart_at_price: 加入购物车时价格|integer
@@ -266,7 +265,8 @@ paths:
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_id: 关联产品的 PocketBase recordId|string
cart_product_business_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|integer
@@ -354,7 +354,7 @@ paths:
example:
cart_id: 购物车业务 ID|string
cart_number: cart_number|string
cart_product_id: cart_product_id|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: cart_product_quantity|integer
cart_status: cart_status|string
cart_at_price: cart_at_price|integer
@@ -374,7 +374,8 @@ paths:
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_id: 关联产品的 PocketBase recordId|string
cart_product_business_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|integer
@@ -710,8 +711,9 @@ paths:
使用 PocketBase 原生 records create 接口向 `tbl_cart` 新增记录。
当前线上权限规则:
- `createRule = @request.auth.id != "" && @request.body.cart_owner = @request.auth.openid`
- 因此客户端创建时必须显式提交 `cart_owner`,并且值必须等于当前 token 对应的 `openid`
- `createRule = @request.body.cart_owner != ""`
- 因此客户端创建时必须显式提交非空 `cart_owner`
- `cart_product_id` 当前为 relation 字段,必须传 `tbl_product_list` 的 PocketBase `recordId`
这意味着:
- 不能依赖服务端自动补 owner
@@ -728,11 +730,11 @@ paths:
example:
cart_id: cart_id|string
cart_number: cart_number|string
cart_owner: 必须显式提交,且值必须等于当前 token 对应 openid|string
cart_product_id: cart_product_id|string
cart_product_quantity: cart_product_quantity|integer
cart_status: cart_status|string
cart_at_price: cart_at_price|number
cart_owner: 必须显式提交非空 owner|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: cart_product_quantity|integer,可为空
cart_status: cart_status|string,可为空
cart_at_price: cart_at_price|number,可为空
cart_remark: cart_remark|string
responses:
"200":
@@ -751,7 +753,7 @@ paths:
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_id: 关联产品的 PocketBase recordId|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|number
@@ -963,77 +965,6 @@ paths:
业务响应数据字段|string: 业务响应数据值|string
components:
schemas:
ApiResponseBase:
type: object
required:
- statusCode
- errMsg
- data
properties:
statusCode:
type:
- integer
- string
description: 业务状态码
example: 业务状态码 | integer
errMsg:
type: string
description: 业务提示信息
example: 业务提示信息 | string
data:
description: 业务响应数据
type: object
additionalProperties: true
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
ErrorResponse:
type: object
required:
- statusCode
- errMsg
- data
properties:
statusCode:
type:
- integer
- string
description: 业务状态码
example: 业务状态码 | integer
errMsg:
type: string
description: 业务提示信息
example: 失败原因提示 | string
data:
description: 业务响应数据
type: object
additionalProperties: true
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
HookRecordBase:
type: object
properties:
pb_id:
type: string
description: PocketBase 记录主键 id
example: l2r3nq7rqhuob0h
created:
type: string
description: PocketBase 系统创建时间
example: 2026-04-03 15:30:00.000Z
updated:
type: string
description: PocketBase 系统更新时间
example: 2026-04-03 15:35:00.000Z
example:
pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
PocketBaseNativeError:
type: object
properties:
@@ -1041,13 +972,14 @@ components:
type:
- integer
- string
description: 业务状态
description: PocketBase错误
example: 错误状态码 | integer
message:
type: string
description: PocketBase错误信息
example: PocketBase原生错误信息 | string
data:
description: 业务响应数据
description: PocketBase错误数据
type: object
additionalProperties: true
example:
@@ -1088,245 +1020,6 @@ components:
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
CartRecord:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/HookRecordBase
- type: object
properties:
cart_id:
type: string
description: 购物车业务 ID
example: CART-1770000000000-abc123
cart_number:
type: string
description: 购物车名称或分组号
example: wx-user-20260403153000
cart_create:
type: string
description: 购物车项创建时间,由数据库自动生成
example: 2026-04-03 15:30:00.000Z
cart_owner:
type: string
description: 购物车所有者 openid
example: wx-openid-user-001
cart_product_id:
type: string
description: 产品业务 ID
example: PROD-1770000000000-abcd12
cart_product_quantity:
type:
- integer
- number
description: 产品数量
example: 2
cart_status:
type: string
description: 购物车状态
example: 有效
cart_at_price:
type:
- integer
- number
description: 加入购物车时价格
example: 1999
cart_remark:
type: string
description: 备注
example: 小程序加入购物车示例
is_delete:
type:
- integer
- number
description: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出
example: 0
product_name:
type: string
description: 产品名称(服务端联动补充)
example: BAI 智能主机
product_modelnumber:
type: string
description: 产品型号(服务端联动补充)
example: BAI-HOST-01
product_basic_price:
type:
- integer
- number
- "null"
description: 产品基础价格(服务端联动补充)
example: 1999
example:
pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
cart_id: 购物车业务 ID|string
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|integer
cart_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
product_name: 产品名称(服务端联动补充)|string
product_modelnumber: 产品型号(服务端联动补充)|string
product_basic_price: 产品基础价格(服务端联动补充)|integer
CartListRequest:
type: object
properties:
keyword:
type: string
description: 对 `cart_id`、`cart_number`、`cart_product_id` 等索引相关字段的统一模糊搜索关键字
example: CART-1770
cart_status:
type: string
description: 购物车状态精确过滤
example: 有效
cart_number:
type: string
description: 购物车名称或分组号精确过滤
example: wx-user-20260403153000
example:
keyword: 对 cart_id、cart_number、cart_product_id 等索引相关字段的统一模糊搜索关键字|string
cart_status: 购物车状态精确过滤|string
cart_number: 购物车名称或分组号精确过滤|string
CartDetailRequest:
type: object
required:
- cart_id
properties:
cart_id:
type: string
description: 购物车业务 ID
example: CART-1770000000000-abc123
example:
cart_id: 购物车业务 ID|string
CartCreateRequest:
type: object
required:
- cart_product_id
- cart_product_quantity
- cart_at_price
properties:
cart_number:
type: string
description: 可选;未传时服务端自动生成
cart_product_id:
type: string
description: 产品业务 ID
example: PROD-1770000000000-abcd12
cart_product_quantity:
type:
- integer
- number
description: 产品数量,需为正整数
example: 2
cart_status:
type: string
description: 可选;未传时默认 `有效`
example: 有效
cart_at_price:
type:
- integer
- number
description: 加入购物车时价格
example: 1999
cart_remark:
type: string
description: 备注
example: 小程序加入购物车示例
example:
cart_number: 可选;未传时服务端自动生成|string
cart_product_id: 产品业务 ID|string
cart_product_quantity: 产品数量,需为正整数|integer
cart_status: 可选;未传时默认 有效|string
cart_at_price: 加入购物车时价格|integer
cart_remark: 备注|string
CartUpdateRequest:
type: object
required:
- cart_id
properties:
cart_id:
type: string
description: 购物车业务 ID
example: CART-1770000000000-abc123
cart_number:
type: string
cart_product_id:
type: string
cart_product_quantity:
type:
- integer
- number
cart_status:
type: string
cart_at_price:
type:
- integer
- number
cart_remark:
type: string
example:
cart_id: 购物车业务 ID|string
cart_number: cart_number|string
cart_product_id: cart_product_id|string
cart_product_quantity: cart_product_quantity|integer
cart_status: cart_status|string
cart_at_price: cart_at_price|integer
cart_remark: cart_remark|string
CartDeleteRequest:
type: object
required:
- cart_id
properties:
cart_id:
type: string
description: 购物车业务 ID
example: CART-1770000000000-abc123
example:
cart_id: 购物车业务 ID|string
CartListResponse:
type: object
properties:
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/CartRecord
example:
items:
- pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
cart_id: 购物车业务 ID|string
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|integer
cart_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
product_name: 产品名称(服务端联动补充)|string
product_modelnumber: 产品型号(服务端联动补充)|string
product_basic_price: 产品基础价格(服务端联动补充)|integer
CartDeleteResponse:
type: object
properties:
cart_id:
type: string
description: 购物车业务 ID
example: CART-1770000000000-abc123
is_delete:
type:
- integer
- number
description: 目标软删除标记值;当前实现可能仍返回物理删除结果
example: 1
example:
cart_id: 购物车业务 ID|string
is_delete: 目标软删除标记值;当前实现可能仍返回物理删除结果|integer
PocketBaseCartFields:
type: object
properties:
@@ -1348,7 +1041,11 @@ components:
example: wx-openid-user-001
cart_product_id:
type: string
description: 产品业务 ID
description: 关联产品的 PocketBase recordId
example: pbc_product_record_id|string
cart_product_business_id:
type: string
description: 关联产品的业务 IDprod_list_id用于展示
example: PROD-1770000000000-abcd12
cart_product_quantity:
type:
@@ -1375,7 +1072,8 @@ components:
cart_number: 购物车名称或分组号|string
cart_create: 购物车项创建时间,由数据库自动生成|string
cart_owner: 购物车所有者 openid|string
cart_product_id: 产品业务 ID|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_business_id: 产品业务 ID|string
cart_product_quantity: 产品数量|integer
cart_status: 购物车状态|string
cart_at_price: 加入购物车时价格|number
@@ -1402,13 +1100,8 @@ components:
PocketBaseCartCreateRequest:
type: object
required:
- cart_id
- cart_number
- cart_owner
- cart_product_id
- cart_product_quantity
- cart_status
- cart_at_price
properties:
cart_id:
type: string
@@ -1416,9 +1109,10 @@ components:
type: string
cart_owner:
type: string
description: 必须显式提交,且值必须等于当前 token 对应 openid
description: 必须显式提交非空 owner
cart_product_id:
type: string
description: tbl_product_list 的 PocketBase recordId
cart_product_quantity:
type:
- integer
@@ -1432,13 +1126,11 @@ components:
cart_remark:
type: string
example:
cart_id: cart_id|string
cart_number: cart_number|string
cart_owner: 必须显式提交,且值必须等于当前 token 对应 openid|string
cart_product_id: cart_product_id|string
cart_product_quantity: cart_product_quantity|integer
cart_status: cart_status|string
cart_at_price: cart_at_price|number
cart_owner: 必须显式提交非空 owner|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: cart_product_quantity|integer可为空
cart_status: cart_status|string,可为空
cart_at_price: cart_at_price|number可为空
cart_remark: cart_remark|string
PocketBaseCartUpdateRequest:
type: object
@@ -1447,9 +1139,10 @@ components:
type: string
cart_owner:
type: string
description: 若提交,必须仍等于当前 token 对应 openid
description: 若提交,必须仍为非空 owner
cart_product_id:
type: string
description: tbl_product_list 的 PocketBase recordId
cart_product_quantity:
type:
- integer
@@ -1464,8 +1157,8 @@ components:
type: string
example:
cart_number: cart_number|string
cart_owner: 若提交,必须仍等于当前 token 对应 openid|string
cart_product_id: cart_product_id|string
cart_owner: 若提交,必须仍为非空 owner|string
cart_product_id: tbl_product_list 的 PocketBase recordId|string
cart_product_quantity: cart_product_quantity|integer
cart_status: cart_status|string
cart_at_price: cart_at_price|number

View File

@@ -0,0 +1,48 @@
openapi: 3.1.0
info:
title: BAI PocketBase Native API
version: 1.0.0-wx-folder
description: |
本目录仅收敛 PocketBase 原生 API 文档,不包含自定义 hooks API。
文档约定:
- 不单独配置鉴权组件;如接口需要登录,请直接在说明中关注 `Authorization: Bearer <token>`
- 示例字段值统一使用 `<字段说明>|<类型>` 风格
- 原生接口返回 PocketBase 标准 records 结构,不使用 hooks 统一响应信封
servers:
- url: https://bai-api.blv-oa.com
description: 生产环境
- url: http://127.0.0.1:8090
description: PocketBase 本地环境
tags:
- name: 企业信息
description: PocketBase 原生公司记录接口
- name: 附件信息
description: PocketBase 原生附件记录接口
- name: 产品信息
description: PocketBase 原生产品记录接口
- name: 文档信息
description: PocketBase 原生文档记录接口
- name: 购物车
description: PocketBase 原生购物车记录接口
- name: 订单
description: PocketBase 原生订单记录接口
paths:
/pb/api/collections/tbl_company/records:
$ref: './company.yaml#/paths/companyRecords'
/pb/api/collections/tbl_company/records/{recordId}:
$ref: './company.yaml#/paths/companyRecordById'
/pb/api/collections/tbl_attachments/records:
$ref: './attachments.yaml#/paths/attachmentRecords'
/pb/api/collections/tbl_product_list/records:
$ref: './products.yaml#/paths/productRecords'
/pb/api/collections/tbl_document/records:
$ref: './documents.yaml#/paths/documentRecords'
/pb/api/collections/tbl_cart/records:
$ref: './cart.yaml#/paths/cartRecords'
/pb/api/collections/tbl_cart/records/{recordId}:
$ref: './cart.yaml#/paths/cartRecordById'
/pb/api/collections/tbl_order/records:
$ref: './order.yaml#/paths/orderRecords'
/pb/api/collections/tbl_order/records/{recordId}:
$ref: './order.yaml#/paths/orderRecordById'

View File

@@ -1,229 +1,163 @@
paths:
orderList:
post:
operationId: postOrderList
tags:
- 订单
summary: 按索引字段模糊查询订单列表
orderRecords:
get:
tags: [订单]
summary: 查询订单记录列表
description: |
调用自定义 hooks API 查询当前登录用户的订单列表
查询规则:
- 仅允许查询当前 `Authorization` 对应用户自己的订单记录
- 支持通过 `keyword` 对多个索引相关字段做统一模糊搜索,当前实现覆盖:
- `order_id`
- `order_number`
- `order_source_id`
- 支持按 `order_status` 精确过滤
- 支持按 `order_source` 精确过滤
目标软删除契约:
- 目标行为应仅返回 `is_delete = 0` 的记录
- 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准
security:
- BearerAuth: []
requestBody:
required: false
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/OrderListRequest
example:
keyword: 对 order_id、order_number、order_source_id 等索引相关字段的统一模糊搜索关键字|string
order_status: 订单状态精确过滤|string
order_source: 订单来源精确过滤|string
使用 PocketBase 原生 records list 接口查询 `tbl_order`
如需鉴权,请自行在请求头中携带 `Authorization: Bearer <token>`。
parameters:
- name: filter
in: query
required: false
schema:
type: string
description: PocketBase 原生过滤表达式
example: order_id="订单业务ID|string"
- name: page
in: query
required: false
schema:
type: integer
minimum: 1
default: 1
- name: perPage
in: query
required: false
schema:
type: integer
minimum: 1
default: 20
- name: sort
in: query
required: false
schema:
type: string
example: -order_create
responses:
"200":
'200':
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/OrderListResponse
example:
items:
- pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
order_id: 订单业务 ID|string
order_number: 订单编号|string
order_create: 订单创建时间,由数据库自动生成|string
order_owner: 订单所有者 openid|string
order_source: 订单来源|string
order_status: 订单状态|string
order_source_id: 来源关联业务 ID|string
order_snap:
order_snap字段|string: order_snap值|string
order_amount: 订单金额|integer
order_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
"400":
description: 参数错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"401":
description: token 缺失、无效或已过期
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"415":
description: 请求体必须为 application/json
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
$ref: '#/components/schemas/PocketBaseOrderListResponse'
'400':
description: 查询参数错误
'401':
description: token 无效或已过期
'403':
description: 无权访问
'500':
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
orderDetail:
post:
operationId: postOrderDetail
tags:
- 订单
summary: 按 order_id 精确查询订单详情
tags: [订单]
summary: 创建订单记录
description: |
调用自定义 hooks API 按 `order_id` 查询单条订单记录。
查询规则:
- 仅允许访问当前 `Authorization` 对应用户自己的订单记录
- 查询键为业务 ID `order_id`,不是 PocketBase 原生 `recordId`
目标软删除契约:
- 目标行为应仅允许查询 `is_delete = 0` 的记录
- 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准
security:
- BearerAuth: []
使用 PocketBase 原生 records create 接口向 `tbl_order` 新增记录。
如集合规则要求 `order_owner` 与当前用户一致,请客户端显式提交。
requestBody:
required: true
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/OrderDetailRequest
$ref: '#/components/schemas/PocketBaseOrderCreateRequest'
example:
order_id: 订单业务 ID|string
order_id: 订单业务ID|string
order_number: 订单编号|string
order_owner: 订单所有者openid|string
order_source: 订单来源|string
order_status: 订单状态|string
order_source_id: 来源关联业务ID|string
order_snap:
字段名|string: 字段值|string
order_amount: 订单金额|number
order_remark: 备注|string
responses:
"200":
description: 查询成功
'200':
description: 创建成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/OrderRecord
example:
pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
order_id: 订单业务 ID|string
order_number: 订单编号|string
order_create: 订单创建时间,由数据库自动生成|string
order_owner: 订单所有者 openid|string
order_source: 订单来源|string
order_status: 订单状态|string
order_source_id: 来源关联业务 ID|string
order_snap:
order_snap字段|string: order_snap值|string
order_amount: 订单金额|integer
order_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
$ref: '#/components/schemas/PocketBaseOrderRecord'
'400':
description: 参数错误或违反集合规则
'401':
description: token 无效或已过期
'403':
description: 无权访问
'500':
description: 服务端错误
orderRecordById:
patch:
tags: [订单]
summary: 更新订单记录
description: |
使用 PocketBase 原生 records update 接口更新 `tbl_order`。
路径参数使用 PocketBase 原生 `recordId`。
parameters:
- name: recordId
in: path
required: true
schema:
type: string
example: PocketBase记录主键|string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PocketBaseOrderUpdateRequest'
example:
order_number: 订单编号|string
order_owner: 订单所有者openid|string
order_source: 订单来源|string
order_status: 订单状态|string
order_source_id: 来源关联业务ID|string
order_snap:
字段名|string: 字段值|string
order_amount: 订单金额|number
order_remark: 备注|string
responses:
'200':
description: 更新成功
content:
application/json:
schema:
$ref: '#/components/schemas/PocketBaseOrderRecord'
'400':
description: 参数错误
'401':
description: token 无效或已过期
'404':
description: 记录不存在
'500':
description: 服务端错误
delete:
tags: [订单]
summary: 删除订单记录
description: |
使用 PocketBase 原生 records delete 接口删除 `tbl_order`。
路径参数使用 PocketBase 原生 `recordId`。
parameters:
- name: recordId
in: path
required: true
schema:
type: string
example: PocketBase记录主键|string
responses:
'204':
description: 删除成功
'401':
description: token 无效或已过期
'404':
description: 记录不存在
'500':
description: 服务端错误
"400":
description: 参数错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"401":
description: token 缺失、无效或已过期
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"403":
description: 无权访问该订单记录
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"404":
description: 未找到对应订单记录
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"415":
description: 请求体必须为 application/json
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
orderCreate:
post:
operationId: postOrderCreate
tags:
- 订单
summary: 新增订单记录
description: |
调用自定义 hooks API 新增一条订单记录。
components:
schemas:
创建规则:
- 服务端自动根据当前 token 写入 `order_owner`
- 服务端自动生成 `order_id`
@@ -231,12 +165,13 @@ paths:
- `order_source`、`order_source_id`、`order_snap`、`order_amount` 为必填
目标软删除契约:
- 新建记录应默认为 `is_delete = 0`
description: PocketBase错误码
- 当前仓库导出响应中尚未显式返回 `is_delete` 字段
security:
- BearerAuth: []
description: PocketBase错误信息
example: PocketBase原生错误信息 | string
requestBody:
required: true
description: PocketBase错误数据
content:
application/json:
schema:
@@ -1088,253 +1023,6 @@ components:
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
OrderRecord:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/HookRecordBase
- type: object
properties:
order_id:
type: string
description: 订单业务 ID
example: ORDER-1770000000000-abc123
order_number:
type: string
description: 订单编号
example: wx-user-20260403153500
order_create:
type: string
description: 订单创建时间,由数据库自动生成
example: 2026-04-03 15:35:00.000Z
order_owner:
type: string
description: 订单所有者 openid
example: wx-openid-user-001
order_source:
type: string
description: 订单来源
example: 购物车
order_status:
type: string
description: 订单状态
example: 订单已生成
order_source_id:
type: string
description: 来源关联业务 ID
example: CART-1770000000000-abc123
order_snap:
description: 订单快照 JSON
oneOf:
- type: object
additionalProperties: true
- type: array
items:
type: object
additionalProperties: true
order_amount:
type:
- integer
- number
description: 订单金额
example: 3998
order_remark:
type: string
description: 备注
example: 小程序订单示例
is_delete:
type:
- integer
- number
description: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出
example: 0
example:
pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
order_id: 订单业务 ID|string
order_number: 订单编号|string
order_create: 订单创建时间,由数据库自动生成|string
order_owner: 订单所有者 openid|string
order_source: 订单来源|string
order_status: 订单状态|string
order_source_id: 来源关联业务 ID|string
order_snap:
order_snap字段|string: order_snap值|string
order_amount: 订单金额|integer
order_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
OrderListRequest:
type: object
properties:
keyword:
type: string
description: 对 `order_id`、`order_number`、`order_source_id` 等索引相关字段的统一模糊搜索关键字
example: ORDER-1770
order_status:
type: string
description: 订单状态精确过滤
example: 订单已生成
order_source:
type: string
description: 订单来源精确过滤
example: 购物车
example:
keyword: 对 order_id、order_number、order_source_id 等索引相关字段的统一模糊搜索关键字|string
order_status: 订单状态精确过滤|string
order_source: 订单来源精确过滤|string
OrderDetailRequest:
type: object
required:
- order_id
properties:
order_id:
type: string
description: 订单业务 ID
example: ORDER-1770000000000-abc123
example:
order_id: 订单业务 ID|string
OrderCreateRequest:
type: object
required:
- order_source
- order_source_id
- order_snap
- order_amount
properties:
order_number:
type: string
description: 可选;未传时服务端自动生成
order_source:
type: string
description: 订单来源
example: 购物车
order_status:
type: string
description: 可选;未传时默认 `订单已生成`
example: 订单已生成
order_source_id:
type: string
description: 来源关联业务 ID
example: CART-1770000000000-abc123
order_snap:
description: 订单快照 JSON
oneOf:
- type: object
additionalProperties: true
- type: array
items:
type: object
additionalProperties: true
order_amount:
type:
- integer
- number
description: 订单金额
example: 3998
order_remark:
type: string
description: 备注
example: 小程序订单示例
example:
order_number: 可选;未传时服务端自动生成|string
order_source: 订单来源|string
order_status: 可选;未传时默认 订单已生成|string
order_source_id: 来源关联业务 ID|string
order_snap:
order_snap字段|string: order_snap值|string
order_amount: 订单金额|integer
order_remark: 备注|string
OrderUpdateRequest:
type: object
required:
- order_id
properties:
order_id:
type: string
description: 订单业务 ID
example: ORDER-1770000000000-abc123
order_number:
type: string
order_source:
type: string
order_status:
type: string
order_source_id:
type: string
order_snap:
oneOf:
- type: object
additionalProperties: true
- type: array
items:
type: object
additionalProperties: true
order_amount:
type:
- integer
- number
order_remark:
type: string
example:
order_id: 订单业务 ID|string
order_number: order_number|string
order_source: order_source|string
order_status: order_status|string
order_source_id: order_source_id|string
order_snap:
order_snap字段|string: order_snap值|string
order_amount: order_amount|integer
order_remark: order_remark|string
OrderDeleteRequest:
type: object
required:
- order_id
properties:
order_id:
type: string
description: 订单业务 ID
example: ORDER-1770000000000-abc123
example:
order_id: 订单业务 ID|string
OrderListResponse:
type: object
properties:
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/OrderRecord
example:
items:
- pb_id: PocketBase 记录主键 id|string
created: PocketBase 系统创建时间|string
updated: PocketBase 系统更新时间|string
order_id: 订单业务 ID|string
order_number: 订单编号|string
order_create: 订单创建时间,由数据库自动生成|string
order_owner: 订单所有者 openid|string
order_source: 订单来源|string
order_status: 订单状态|string
order_source_id: 来源关联业务 ID|string
order_snap:
order_snap字段|string: order_snap值|string
order_amount: 订单金额|integer
order_remark: 备注|string
is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer
OrderDeleteResponse:
type: object
properties:
order_id:
type: string
description: 订单业务 ID
example: ORDER-1770000000000-abc123
is_delete:
type:
- integer
- number
description: 目标软删除标记值;当前实现可能仍返回物理删除结果
example: 1
example:
order_id: 订单业务 ID|string
is_delete: 目标软删除标记值;当前实现可能仍返回物理删除结果|integer
PocketBaseOrderFields:
type: object
properties:

View File

@@ -1,253 +0,0 @@
paths:
usersCount:
post:
security: []
operationId: postSystemUsersCount
tags:
- 系统
summary: 查询用户总数
description: 统计 `tbl_auth_users` 集合中的记录总数。
responses:
"200":
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/UsersCountResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
total_users: total_users|integer
"400":
description: 请求参数错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
refreshToken:
post:
security:
- BearerAuth: []
- {}
operationId: postSystemRefreshToken
tags:
- 系统
summary: 刷新认证 token
description: |
当当前 `Authorization` 仍有效时,直接基于当前 auth 用户续签。
当 token 失效时,可传入 `users_wx_code` 走微信 code 重新签发。
requestBody:
required: false
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/SystemRefreshTokenRequest
example:
users_wx_code: 当前 token 失效时,可通过该 code 重新签发 token。|string
responses:
"200":
description: 刷新成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/RefreshTokenResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
token: 新签发的 PocketBase 原生 auth token|string
"400":
description: 参数错误或微信 code 换取失败
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"401":
description: token 无效,且未提供有效的 `users_wx_code`
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"404":
description: 当前用户不存在
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"415":
description: 请求体不是 JSON
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"429":
description: 请求过于频繁
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
components:
schemas:
ApiResponseBase:
type: object
required:
- statusCode
- errMsg
- data
properties:
statusCode:
type:
- integer
- string
description: 业务状态码
example: 业务状态码 | integer
errMsg:
type: string
description: 业务提示信息
example: 业务提示信息 | string
data:
description: 业务响应数据
type: object
additionalProperties: true
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
ErrorResponse:
type: object
required:
- statusCode
- errMsg
- data
properties:
statusCode:
type:
- integer
- string
description: 业务状态码
example: 业务状态码 | integer
errMsg:
type: string
description: 业务提示信息
example: 失败原因提示 | string
data:
description: 业务响应数据
type: object
additionalProperties: true
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
SystemRefreshTokenRequest:
type: object
properties:
users_wx_code:
type:
- string
- "null"
description: |
可选。
当前 token 失效时,可通过该 code 重新签发 token。
example: 0a1b2c3d4e5f6g
example:
users_wx_code: 当前 token 失效时,可通过该 code 重新签发 token。|string
RefreshTokenResponse:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/ApiResponseBase
- type: object
required:
- token
properties:
data:
type: object
additionalProperties: true
description: 业务响应数据
example: {}
token:
type: string
description: 新签发的 PocketBase 原生 auth token
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
业务响应数据字段|string: 业务响应数据值|string
token: 新签发的 PocketBase 原生 auth token|string
UsersCountData:
type: object
properties:
total_users:
type:
- integer
- string
example: 用户总数 | integer
example:
total_users: total_users|integer
UsersCountResponse:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/ApiResponseBase
- type: object
properties:
data:
description: 业务响应数据
$ref: ../openapi-wx.yaml#/components/schemas/UsersCountData
example:
statusCode: 业务状态码|integer
errMsg: 业务提示信息|string
data:
total_users: total_users|integer

File diff suppressed because it is too large Load Diff