feat: 添加购物车相关迁移和索引功能

- 在 package.json 中添加迁移脚本 `migrate:cart-active-unique-index`。
- 修改 `pocketbase.cart-order.js` 文件,更新 `cart_id` 和 `cart_product_id` 字段的必填属性,并添加唯一索引 `idx_tbl_cart_owner_product_active_unique`。
- 在 `pocketbase.ensure-cart-order-autogen-id.js` 中,调整 `cart_id` 字段的必填属性为可选,并确保 `order_id` 字段为必填。
- 在 `pocketbase.product-list.js` 中,新增 `prod_list_barcode` 字段。
- 新增 `make-openapi-standalone.cjs` 脚本,用于处理 OpenAPI 文档。
- 新增 `pocketbase.cart-active-unique-index.js` 脚本,处理购物车的唯一索引和去重逻辑。
This commit is contained in:
2026-04-09 14:49:12 +08:00
parent 0bdaf54eed
commit ec6b59b4fa
29 changed files with 1240 additions and 6449 deletions

View File

@@ -1,5 +1,17 @@
openapi: 3.1.0
info:
title: BAI PocketBase Native API - Attachments
version: 1.0.0
description: |
PocketBase 原生 `tbl_attachments` records API 文档。
本文件可单独导入使用,不依赖其他 YAML。
servers:
- url: https://bai-api.blv-oa.com
description: 生产环境
- url: http://localhost:8090
description: PocketBase 本地环境
paths:
attachmentRecords:
/pb/api/collections/tbl_attachments/records:
get:
operationId: getPocketBaseAttachmentRecords
tags:
@@ -38,7 +50,7 @@ paths:
- 不传该参数时,返回分页列表
schema:
type: string
example: attachments_id="ATT-1774599142438-8n1UcU"
example: 过滤表达式|string
- name: page
in: query
required: false
@@ -60,8 +72,6 @@ paths:
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseAttachmentListResponse
example:
page: page|integer
perPage: perPage|integer
@@ -85,8 +95,6 @@ paths:
description: 查询参数错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -97,7 +105,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -108,7 +116,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -240,8 +248,6 @@ components:
example: 总页数 | integer
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseAttachmentRecord
example:
page: page|integer
perPage: perPage|integer

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,17 @@
openapi: 3.1.0
info:
title: BAI PocketBase Native API - Company
version: 1.0.0
description: |
PocketBase 原生 `tbl_company` records API 文档。
本文件可单独导入使用,不依赖其他 YAML。
servers:
- url: https://bai-api.blv-oa.com
description: 生产环境
- url: http://localhost:8090
description: PocketBase 本地环境
paths:
companyRecords:
/pb/api/collections/tbl_company/records:
post:
operationId: postPocketBaseCompanyRecord
tags:
@@ -21,7 +33,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyCreateRequest
$ref: #/components/schemas/PocketBaseCompanyCreateRequest
example:
company_name: 公司名称|string
company_type: 公司类型|string
@@ -47,7 +59,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord
$ref: #/components/schemas/PocketBaseCompanyRecord
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
@@ -78,7 +90,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -89,7 +101,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -100,7 +112,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -142,7 +154,7 @@ paths:
- 查询整个列表时:不传该参数
schema:
type: string
example: company_id="WX-COMPANY-10001"
example: 过滤表达式|string
- name: page
in: query
required: false
@@ -165,7 +177,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyListResponse
$ref: #/components/schemas/PocketBaseCompanyListResponse
example:
page: page|integer
perPage: perPage|integer
@@ -201,7 +213,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -212,7 +224,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -223,13 +235,13 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
companyRecordById:
/pb/api/collections/tbl_company/records/{recordId}:
patch:
operationId: patchPocketBaseCompanyRecordByRecordId
tags:
@@ -253,13 +265,13 @@ paths:
description: 通过 `company_id` 查询结果拿到的 PocketBase 记录主键 `id`
schema:
type: string
example: l2r3nq7rqhuob0h
example: PocketBase记录主键|string
requestBody:
required: true
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyUpdateRequest
$ref: #/components/schemas/PocketBaseCompanyUpdateRequest
example:
company_id: 所属公司业务 ID|string
company_name: 公司名称|string
@@ -286,7 +298,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord
$ref: #/components/schemas/PocketBaseCompanyRecord
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
@@ -317,7 +329,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -328,7 +340,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -339,7 +351,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -350,7 +362,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -653,8 +665,8 @@ components:
company_remark: 备注|string
PocketBaseCompanyRecord:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyFields
- $ref: #/components/schemas/PocketBaseRecordBase
- $ref: #/components/schemas/PocketBaseCompanyFields
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
@@ -870,7 +882,7 @@ components:
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord
$ref: #/components/schemas/PocketBaseCompanyRecord
example:
page: page|integer
perPage: perPage|integer

View File

@@ -1,5 +1,17 @@
openapi: 3.1.0
info:
title: BAI PocketBase Native API - Documents
version: 1.0.0
description: |
PocketBase 原生 `tbl_document` records API 文档。
本文件可单独导入使用,不依赖其他 YAML。
servers:
- url: https://bai-api.blv-oa.com
description: 生产环境
- url: http://localhost:8090
description: PocketBase 本地环境
paths:
documentRecords:
/pb/api/collections/tbl_document/records:
get:
operationId: getPocketBaseDocumentRecords
tags:
@@ -57,7 +69,7 @@ paths:
- 例如:`document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1"`
schema:
type: string
example: document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1"
example: 过滤表达式|string
- name: page
in: query
required: false
@@ -84,14 +96,14 @@ paths:
- `-document_create`:按最新上传倒序返回
schema:
type: string
example: -document_create
example: 排序表达式|string
responses:
"200":
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseDocumentListResponse
$ref: #/components/schemas/PocketBaseDocumentListResponse
example:
page: page|integer
perPage: perPage|integer
@@ -135,7 +147,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -146,7 +158,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -157,7 +169,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -289,15 +301,15 @@ components:
document_share_count:
type: number
description: 分享次数
example: 0
example: 分享次数|number
document_download_count:
type: number
description: 下载次数
example: 0
example: 下载次数|number
document_favorite_count:
type: number
description: 收藏次数
example: 0
example: 收藏次数|number
document_embedding_status:
type: string
description: 文档嵌入状态
@@ -360,8 +372,8 @@ components:
document_remark: 备注|string
PocketBaseDocumentRecord:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseDocumentFields
- $ref: #/components/schemas/PocketBaseRecordBase
- $ref: #/components/schemas/PocketBaseDocumentFields
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
@@ -427,7 +439,7 @@ components:
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseDocumentRecord
$ref: #/components/schemas/PocketBaseDocumentRecord
example:
page: page|integer
perPage: perPage|integer

View File

@@ -5,6 +5,8 @@ info:
description: |
本目录仅收敛 PocketBase 原生 API 文档,不包含自定义 hooks API。
本文件为目录索引,支持单文件独立导入,不依赖其他 YAML。
文档约定:
- 不单独配置鉴权组件;如接口需要登录,请直接在说明中关注 `Authorization: Bearer <token>`
- 示例字段值统一使用 `<字段说明>|<类型>` 风格
@@ -27,22 +29,12 @@ tags:
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'
paths: {}
x-index:
files:
- company.yaml
- attachments.yaml
- products.yaml
- documents.yaml
- cart.yaml
- order.yaml

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,17 @@
openapi: 3.1.0
info:
title: BAI PocketBase Native API - Products
version: 1.0.0
description: |
PocketBase 原生 `tbl_product_list` records API 文档。
本文件可单独导入使用,不依赖其他 YAML。
servers:
- url: https://bai-api.blv-oa.com
description: 生产环境
- url: http://localhost:8090
description: PocketBase 本地环境
paths:
productRecords:
/pb/api/collections/tbl_product_list/records:
get:
operationId: getPocketBaseProductListRecords
tags:
@@ -30,7 +42,7 @@ paths:
推荐写法:`prod_list_category="<产品分类>"`
schema:
type: string
example: prod_list_category="<产品分类>"
example: 过滤表达式|string
- name: page
in: query
required: false
@@ -57,14 +69,14 @@ paths:
- `prod_list_sort`:按分类排序值从小到大
schema:
type: string
example: prod_list_sort
example: 排序表达式|string
responses:
"200":
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseProductListListResponse
$ref: #/components/schemas/PocketBaseProductListListResponse
example:
page: page|integer
perPage: perPage|integer
@@ -79,6 +91,7 @@ paths:
prod_list_id: 产品列表业务 ID唯一标识|string
prod_list_name: 产品名称|string
prod_list_modelnumber: 产品型号|string
prod_list_barcode: 产品料号|string
prod_list_icon: 产品图标附件 ID保存 tbl_attachments.attachments_id|string
prod_list_description: 产品说明|string
prod_list_feature: 产品特色|string
@@ -103,7 +116,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -114,7 +127,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -125,7 +138,7 @@ paths:
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
$ref: #/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
@@ -202,6 +215,10 @@ components:
type: string
description: 产品型号
example: <产品型号>|<string>
prod_list_barcode:
type: string
description: 产品料号
example: <产品料号>|<string>
prod_list_icon:
type: string
description: 产品图标附件 ID保存 `tbl_attachments.attachments_id`
@@ -242,7 +259,7 @@ components:
- number
- integer
description: 排序值(同分类内按升序)
example: 10
example: 排序值|number
prod_list_comm_type:
type: string
description: 通讯类型
@@ -268,7 +285,7 @@ components:
- number
- integer
description: 基础价格
example: 1999
example: 基础价格|number
prod_list_vip_price:
type: array
description: 会员价数组,每项包含会员等级枚举值与价格
@@ -282,10 +299,10 @@ components:
type:
- number
- integer
example: 1899
example: 会员价格|number
example:
- viplevel: VIP1
price: 1899
- viplevel: 会员等级|string
price: 会员价格|number
prod_list_remark:
type: string
description: 备注
@@ -294,6 +311,7 @@ components:
prod_list_id: 产品列表业务 ID唯一标识|string
prod_list_name: 产品名称|string
prod_list_modelnumber: 产品型号|string
prod_list_barcode: 产品料号|string
prod_list_icon: 产品图标附件 ID保存 tbl_attachments.attachments_id|string
prod_list_description: 产品说明|string
prod_list_feature: 产品特色|string
@@ -315,8 +333,8 @@ components:
prod_list_remark: 备注|string
PocketBaseProductListRecord:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseProductListFields
- $ref: #/components/schemas/PocketBaseRecordBase
- $ref: #/components/schemas/PocketBaseProductListFields
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
@@ -326,6 +344,7 @@ components:
prod_list_id: 产品列表业务 ID唯一标识|string
prod_list_name: 产品名称|string
prod_list_modelnumber: 产品型号|string
prod_list_barcode: 产品料号|string
prod_list_icon: 产品图标附件 ID保存 tbl_attachments.attachments_id|string
prod_list_description: 产品说明|string
prod_list_feature: 产品特色|string
@@ -377,7 +396,7 @@ components:
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseProductListRecord
$ref: #/components/schemas/PocketBaseProductListRecord
example:
page: page|integer
perPage: perPage|integer
@@ -392,6 +411,7 @@ components:
prod_list_id: 产品列表业务 ID唯一标识|string
prod_list_name: 产品名称|string
prod_list_modelnumber: 产品型号|string
prod_list_barcode: 产品料号|string
prod_list_icon: 产品图标附件 ID保存 tbl_attachments.attachments_id|string
prod_list_description: 产品说明|string
prod_list_feature: 产品特色|string