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 - 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