Files
Web_BAI_Manage_ApiServer/pocket-base/spec/openapi-wx/company.yaml

904 lines
34 KiB
YAML
Raw Normal View History

paths:
companyRecords:
post:
operationId: postPocketBaseCompanyRecord
tags:
- 企业信息
summary: 创建公司
description: |
使用 PocketBase 原生 records create 接口向 `tbl_company` 新增一行记录。
当前线上权限规则:
- `createRule = ""`,因此任何客户端都可直接创建
- 其他原生操作中,`update/delete/view` 仅管理员或管理后台用户允许
注意:
- 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装
- `company_id` 由数据库自动生成,客户端创建时不需要传
- `company_id` 仍带唯一索引,可用于后续按业务 id 查询
requestBody:
required: true
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyCreateRequest
example:
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区 / 县名称|string
company_district_code: 区 / 县编码|string
company_postalcode: 邮编|string
company_add: 地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
responses:
"200":
description: 创建成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
"400":
description: 参数错误或违反当前集合约束
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"403":
description: 集合规则被锁定或服务端权限设置异常
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
get:
operationId: getPocketBaseCompanyRecords
tags:
- 企业信息
summary: 查询整个 tbl_company 列表 / 根据 company_id 查询对应公司信息
description: |
使用 PocketBase 原生 records list 接口查询 `tbl_company`。
当前线上权限规则:
- `listRule = is_delete = 0`,因此默认只返回未软删除数据,且整个列表查询与条件查询都公开可读
- `createRule = ""`,因此创建也公开可调用
- `view/update/delete` 仅管理员或管理后台用户允许
标准调用方式有两种:
1. 根据 `company_id` 查询对应公司信息:
- `filter=company_id="WX-COMPANY-10001"`
- `perPage=1`
- `page=1`
2. 查询整个 `tbl_company` 列表:
- 不传 `filter`
- 按需传 `page`、`perPage`
注意:
- 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装
- PocketBase 原生标准接口里,“按 `company_id` 查询单条”和“查询整个列表”共用同一个 `GET /records` 路径,因此文档以同一个 GET operation 展示两种调用模式
parameters:
- name: filter
in: query
required: false
description: |
PocketBase 标准过滤表达式。
- 根据 `company_id` 查询单条时:`company_id="WX-COMPANY-10001"`
- 查询整个列表时:不传该参数
schema:
type: string
example: company_id="WX-COMPANY-10001"
- name: page
in: query
required: false
description: 页码
schema:
type: integer
minimum: 1
default: 1
- name: perPage
in: query
required: false
description: 每页条数;按 `company_id` 单查时建议固定为 `1`
schema:
type: integer
minimum: 1
default: 20
responses:
"200":
description: 查询成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyListResponse
example:
page: page|integer
perPage: perPage|integer
totalItems: totalItems|integer
totalPages: totalPages|integer
items:
- id: PocketBase 记录主键|string
collectionId: collectionId|string
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
"400":
description: 查询参数错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"403":
description: 集合规则被锁定或服务端权限设置异常
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
companyRecordById:
patch:
operationId: patchPocketBaseCompanyRecordByRecordId
tags:
- 企业信息
summary: 通过 company_id 定位后修改公司信息
description: |
这是 PocketBase 原生标准更新接口,实际写入路径参数仍然必须使用记录主键 `recordId`。
如果前端手里只有 `company_id`,标准调用流程是:
1. 先调用 `GET /pb/api/collections/tbl_company/records?filter=company_id="..."&perPage=1&page=1`
2. 从返回结果 `items[0].id` 中取出 PocketBase 原生记录主键
3. 再调用当前 `PATCH /pb/api/collections/tbl_company/records/{recordId}` 完成更新
当前线上权限规则:
- `updateRule` 仅管理员或管理后台用户允许
- 普通公开调用不能直接更新
parameters:
- name: recordId
in: path
required: true
description: 通过 `company_id` 查询结果拿到的 PocketBase 记录主键 `id`
schema:
type: string
example: l2r3nq7rqhuob0h
requestBody:
required: true
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyUpdateRequest
example:
company_id: 所属公司业务 ID|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区 / 县名称|string
company_district_code: 区 / 县编码|string
company_postalcode: 邮编|string
company_add: 地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
responses:
"200":
description: 更新成功
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
"400":
description: 参数错误或违反集合约束
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"403":
description: 当前调用方没有 update 权限
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"404":
description: 记录不存在
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
"500":
description: 服务端错误
content:
application/json:
schema:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
components:
schemas:
PocketBaseNativeError:
type: object
properties:
code:
type:
- integer
- string
description: 业务状态码
example: 错误状态码 | integer
message:
type: string
example: PocketBase原生错误信息 | string
data:
description: 业务响应数据
type: object
additionalProperties: true
example:
code: 业务状态码|integer
message: message|string
data:
业务响应数据字段|string: 业务响应数据值|string
PocketBaseRecordBase:
type: object
required:
- id
- collectionId
- collectionName
- created
- updated
properties:
id:
type: string
description: PocketBase 记录主键
example: PocketBase记录主键 | string
collectionId:
type: string
example: 集合ID | string
collectionName:
type: string
example: 集合名称 | string
created:
type: string
description: 记录创建时间
example: 记录创建时间 | string
updated:
type: string
description: 记录更新时间
example: 记录更新时间 | string
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
CompanyInfo:
anyOf:
- type: object
description: 用户所属公司信息;当用户尚未绑定公司时返回 `null`
properties:
pb_id:
type: string
description: PocketBase 记录主键 id
example: PocketBase记录主键id | string
company_id:
type: string
description: 公司业务 id由数据库自动生成
example: 公司业务id由数据库自动生成 | string
company_name:
type: string
description: 公司名称
example: 公司名称 | string
company_type:
type: string
description: 公司类型
example: 公司类型 | string
company_entity:
type: string
description: 公司法人
example: 公司法人 | string
company_usci:
type: string
description: 统一社会信用代码
example: 统一社会信用代码 | string
company_nationality:
type: string
description: 国家名称
example: 国家名称 | string
company_nationality_code:
type: string
description: 国家编码
example: 国家编码 | string
company_province:
type: string
description: 省份名称
example: 省份名称 | string
company_province_code:
type: string
description: 省份编码
example: 省份编码 | string
company_city:
type: string
description: 城市名称
example: 城市名称 | string
company_city_code:
type: string
description: 城市编码
example: 城市编码 | string
company_district:
type: string
description: 区/县名称
example: 区县名称 | string
company_district_code:
type: string
description: 区/县编码
example: 区县编码 | string
company_postalcode:
type: string
description: 邮政编码
example: 邮政编码 | string
company_add:
type: string
description: 公司地址
example: 公司地址 | string
company_status:
type: string
description: 公司状态
example: 公司状态 | string
company_level:
type: string
description: 公司等级
example: 公司等级 | string
company_owner_openid:
type: string
description: 公司所有者 openid
example: 公司所有者openid | string
company_remark:
type: string
description: 备注
example: 备注 | string
created:
type: string
description: 记录创建时间
example: 记录创建时间 | string
updated:
type: string
description: 记录更新时间
example: 记录更新时间 | string
example:
pb_id: PocketBase记录主键id | string
company_id: 公司业务id由数据库自动生成 | string
company_name: 公司名称 | string
company_type: 公司类型 | string
company_entity: 公司法人 | string
company_usci: 统一社会信用代码 | string
company_nationality: 国家名称 | string
company_nationality_code: 国家编码 | string
company_province: 省份名称 | string
company_province_code: 省份编码 | string
company_city: 城市名称 | string
company_city_code: 城市编码 | string
company_district: 区县名称 | string
company_district_code: 区县编码 | string
company_postalcode: 邮政编码 | string
company_add: 公司地址 | string
company_status: 公司状态 | string
company_level: 公司等级 | string
company_owner_openid: 公司所有者openid | string
company_remark: 备注 | string
created: 记录创建时间 | string
updated: 记录更新时间 | string
- type: "null"
example:
pb_id: PocketBase 记录主键 id|string
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
created: 记录创建时间|string
updated: 记录更新时间|string
PocketBaseCompanyFields:
type: object
properties:
company_id:
type: string
description: 公司业务 id由数据库自动生成
example: 公司业务id由数据库自动生成 | string
company_name:
type: string
description: 公司名称
example: 公司名称 | string
company_type:
type: string
description: 公司类型
example: 公司类型 | string
company_entity:
type: string
description: 公司法人
example: 公司法人 | string
company_usci:
type: string
description: 统一社会信用代码
example: 统一社会信用代码 | string
company_nationality:
type: string
description: 国家名称
example: 国家名称 | string
company_nationality_code:
type: string
description: 国家编码
example: 国家编码 | string
company_province:
type: string
description: 省份名称
example: 省份名称 | string
company_province_code:
type: string
description: 省份编码
example: 省份编码 | string
company_city:
type: string
description: 城市名称
example: 城市名称 | string
company_city_code:
type: string
description: 城市编码
example: 城市编码 | string
company_district:
type: string
description: 区/县名称
example: 区县名称 | string
company_district_code:
type: string
description: 区/县编码
example: 区县编码 | string
company_postalcode:
type: string
description: 邮政编码
example: 邮政编码 | string
company_add:
type: string
description: 公司地址
example: 公司地址 | string
company_status:
type: string
description: 公司状态
example: 公司状态 | string
company_level:
type: string
description: 公司等级
example: 公司等级 | string
company_owner_openid:
type: string
description: 公司所有者 openid
example: 公司所有者openid | string
company_remark:
type: string
description: 备注
example: 备注 | string
example:
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
PocketBaseCompanyRecord:
allOf:
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase
- $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyFields
example:
id: PocketBase 记录主键|string
collectionId: collectionId|string
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
PocketBaseCompanyCreateRequest:
type: object
properties:
company_name:
description: 公司名称
type: string
company_type:
description: 公司类型
type: string
company_entity:
description: 公司法人
type: string
company_usci:
description: 统一社会信用代码
type: string
company_nationality:
description: 国家名称
type: string
company_nationality_code:
description: 国家编码
type: string
company_province:
description: 省份名称
type: string
company_province_code:
description: 省份编码
type: string
company_city:
description: 城市名称
type: string
company_city_code:
description: 城市编码
type: string
company_district:
description: 区 / 县名称
type: string
company_district_code:
description: 区 / 县编码
type: string
company_postalcode:
description: 邮编
type: string
company_add:
description: 地址
type: string
company_status:
description: 公司状态
type: string
company_level:
description: 公司等级
type: string
company_owner_openid:
description: 公司所有者 openid
type: string
company_remark:
description: 备注
type: string
additionalProperties: false
example:
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区 / 县名称|string
company_district_code: 区 / 县编码|string
company_postalcode: 邮编|string
company_add: 地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
PocketBaseCompanyUpdateRequest:
type: object
properties:
company_id:
description: 所属公司业务 ID
type: string
company_name:
description: 公司名称
type: string
company_type:
description: 公司类型
type: string
company_entity:
description: 公司法人
type: string
company_usci:
description: 统一社会信用代码
type: string
company_nationality:
description: 国家名称
type: string
company_nationality_code:
description: 国家编码
type: string
company_province:
description: 省份名称
type: string
company_province_code:
description: 省份编码
type: string
company_city:
description: 城市名称
type: string
company_city_code:
description: 城市编码
type: string
company_district:
description: 区 / 县名称
type: string
company_district_code:
description: 区 / 县编码
type: string
company_postalcode:
description: 邮编
type: string
company_add:
description: 地址
type: string
company_status:
description: 公司状态
type: string
company_level:
description: 公司等级
type: string
company_owner_openid:
description: 公司所有者 openid
type: string
company_remark:
description: 备注
type: string
additionalProperties: false
example:
company_id: 所属公司业务 ID|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区 / 县名称|string
company_district_code: 区 / 县编码|string
company_postalcode: 邮编|string
company_add: 地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string
PocketBaseCompanyListResponse:
type: object
required:
- page
- perPage
- totalItems
- totalPages
- items
properties:
page:
type:
- integer
- string
example: 页码 | integer
perPage:
type:
- integer
- string
example: 每页条数 | integer
totalItems:
type:
- integer
- string
example: 总记录数 | integer
totalPages:
type:
- integer
- string
example: 总页数 | integer
items:
type: array
items:
$ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord
example:
page: page|integer
perPage: perPage|integer
totalItems: totalItems|integer
totalPages: totalPages|integer
items:
- id: PocketBase 记录主键|string
collectionId: collectionId|string
collectionName: collectionName|string
created: 记录创建时间|string
updated: 记录更新时间|string
company_id: 公司业务 id由数据库自动生成|string
company_name: 公司名称|string
company_type: 公司类型|string
company_entity: 公司法人|string
company_usci: 统一社会信用代码|string
company_nationality: 国家名称|string
company_nationality_code: 国家编码|string
company_province: 省份名称|string
company_province_code: 省份编码|string
company_city: 城市名称|string
company_city_code: 城市编码|string
company_district: 区/县名称|string
company_district_code: 区/县编码|string
company_postalcode: 邮政编码|string
company_add: 公司地址|string
company_status: 公司状态|string
company_level: 公司等级|string
company_owner_openid: 公司所有者 openid|string
company_remark: 备注|string