feat: 添加微信认证相关接口,包括微信登录和用户资料更新功能
- 新增 wechatLogin 接口,支持使用微信临时凭证 code 登录或注册用户,返回用户信息和 auth token。 - 新增 wechatProfile 接口,支持更新微信用户资料,支持非空字段增量更新。 - 定义相关请求和响应的 schema,包括 WechatLoginRequest、WechatProfileRequest、AuthSuccessResponse 和 WechatProfileResponse。 - 处理不同的响应状态码,包括成功、参数错误、认证失败等。
This commit is contained in:
253
pocket-base/spec/openapi-wx/system.yaml
Normal file
253
pocket-base/spec/openapi-wx/system.yaml
Normal file
@@ -0,0 +1,253 @@
|
||||
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
|
||||
Reference in New Issue
Block a user