feat: 更新 API 响应结构,统一使用 statusCode 和 errMsg 替代 code 和 msg;新增用户类型和公司 ID 字段;优化数据库索引;添加公司所有者同步测试脚本

This commit is contained in:
2026-03-29 19:57:04 +08:00
parent e9fe1165e3
commit 50c09d855b
50 changed files with 851 additions and 601 deletions

View File

@@ -33,13 +33,13 @@ components:
schemas:
ApiResponse:
type: object
required: [code, msg, data]
required: [statusCode, errMsg, data]
properties:
code:
statusCode:
type: integer
description: "业务状态码"
example: 200
msg:
errMsg:
type: string
description: "业务提示信息"
example: 操作成功
@@ -313,13 +313,13 @@ components:
type: object
description: |
项目统一认证响应。
所有对外接口统一返回 `code`、`msg`、`data`,认证成功时额外返回顶层 `token`。
所有对外接口统一返回 `statusCode`、`errMsg`、`data`,认证成功时额外返回顶层 `token`。
properties:
code:
statusCode:
type: integer
description: "业务状态码"
example: 200
msg:
errMsg:
type: string
description: "业务提示信息"
example: 登录成功
@@ -340,8 +340,8 @@ components:
type: string
description: PocketBase 原生 auth token仅认证类接口在成功时额外返回
example:
code: 200
msg: 登录成功
statusCode: 200
errMsg: 登录成功
data:
status: 登录或注册状态 | string
is_info_complete: 资料是否完整 | boolean
@@ -420,6 +420,14 @@ components:
type: string
description: 可选。未传 `users_phone_code` 时,可直接写入手机号
example: '13800138000'
users_type:
type: string
description: 可选。用户类型;仅在传入非空值时更新
example: 服务商
company_id:
type: string
description: 可选。公司业务 id仅在传入非空值时更新
example: WX-COMPANY-10001
users_tag:
type: string
description: 可选。用户标签;非空时才更新
@@ -1164,13 +1172,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/HelloWorldData'
description: "业务响应数据"
$ref: '#/components/schemas/HelloWorldData'
/pb/api/system/health:
post:
tags: [系统]
@@ -1181,13 +1184,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/HealthData'
description: "业务响应数据"
$ref: '#/components/schemas/HealthData'
/pb/api/system/users-count:
post:
tags: [系统]
@@ -1199,13 +1197,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/UsersCountData'
description: "业务响应数据"
$ref: '#/components/schemas/UsersCountData'
/pb/api/system/refresh-token:
post:
tags: [系统]
@@ -1235,8 +1228,8 @@ paths:
type: string
description: 新签发的 PocketBase 原生 auth token
example:
code: 200
msg: 刷新成功
statusCode: 200
errMsg: 刷新成功
data: {}
token: eyJhbGciOi...
'400':
@@ -1337,8 +1330,8 @@ paths:
schema:
$ref: '#/components/schemas/PocketBaseAuthResponse'
example:
code: 200
msg: 登录成功
statusCode: 200
errMsg: 登录成功
data:
status: login_success
is_info_complete: false
@@ -1395,13 +1388,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/WechatProfileResponseData'
description: "业务响应数据"
$ref: '#/components/schemas/WechatProfileResponseData'
'401':
description: token 无效或当前 auth record 缺少统一身份字段 openid
'400':
@@ -1426,18 +1414,13 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/DictionaryRecord'
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/DictionaryRecord'
'415':
description: 请求体必须为 application/json
/pb/api/dictionary/detail:
@@ -1460,13 +1443,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/DictionaryRecord'
description: "业务响应数据"
$ref: '#/components/schemas/DictionaryRecord'
'400':
description: 参数错误
'404':
@@ -1493,13 +1471,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/DictionaryRecord'
description: "业务响应数据"
$ref: '#/components/schemas/DictionaryRecord'
'400':
description: 参数错误或 dict_name 已存在
'401':
@@ -1529,13 +1502,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/DictionaryRecord'
description: "业务响应数据"
$ref: '#/components/schemas/DictionaryRecord'
'400':
description: 参数错误或 dict_name 冲突
'401':
@@ -1567,17 +1535,12 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
dict_name:
description: "字典名称,当前按全局唯一维护"
type: string
description: "业务响应数据"
type: object
properties:
dict_name:
description: "字典名称,当前按全局唯一维护"
type: string
'400':
description: 参数错误或删除失败
'401':
@@ -1609,18 +1572,13 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/AttachmentRecord'
'401':
description: token 无效或已过期
'403':
@@ -1646,13 +1604,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/AttachmentRecord'
description: "业务响应数据"
$ref: '#/components/schemas/AttachmentRecord'
'400':
description: 参数错误
'401':
@@ -1683,13 +1636,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/AttachmentRecord'
description: "业务响应数据"
$ref: '#/components/schemas/AttachmentRecord'
'400':
description: 参数错误、缺少文件或附件保存失败
'401':
@@ -1715,17 +1663,12 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
attachments_id:
description: "附件业务 ID"
type: string
description: "业务响应数据"
type: object
properties:
attachments_id:
description: "附件业务 ID"
type: string
'400':
description: 参数错误、附件已被文档引用或删除失败
'401':
@@ -1759,18 +1702,13 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/DocumentRecord'
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/DocumentRecord'
'401':
description: token 无效或已过期
'403':
@@ -1796,13 +1734,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/DocumentRecord'
description: "业务响应数据"
$ref: '#/components/schemas/DocumentRecord'
'400':
description: 参数错误
'401':
@@ -1835,13 +1768,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/DocumentRecord'
description: "业务响应数据"
$ref: '#/components/schemas/DocumentRecord'
'400':
description: 参数错误、附件不存在或文档创建失败
'401':
@@ -1874,13 +1802,8 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
$ref: '#/components/schemas/DocumentRecord'
description: "业务响应数据"
$ref: '#/components/schemas/DocumentRecord'
'400':
description: 参数错误、附件不存在或修改失败
'401':
@@ -1912,17 +1835,12 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
document_id:
description: "文档业务 ID"
type: string
description: "业务响应数据"
type: object
properties:
document_id:
description: "文档业务 ID"
type: string
'400':
description: 参数错误或删除失败
'401':
@@ -1954,21 +1872,18 @@ paths:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/ApiResponse'
- type: object
properties:
data:
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/DocumentHistoryRecord'
description: "业务响应数据"
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/DocumentHistoryRecord'
'401':
description: token 无效或已过期
'403':
description: 非 ManagePlatform 用户无权访问
'415':
description: 请求体必须为 application/json