280 lines
7.2 KiB
YAML
280 lines
7.2 KiB
YAML
|
|
openapi: 3.0.0
|
|||
|
|
info:
|
|||
|
|
title: 用户管理API
|
|||
|
|
description: 用户管理相关接口文档
|
|||
|
|
version: 1.0.0
|
|||
|
|
|
|||
|
|
paths:
|
|||
|
|
/api/login:
|
|||
|
|
post:
|
|||
|
|
summary: 用户登录
|
|||
|
|
description: 用户登录并获取JWT令牌
|
|||
|
|
requestBody:
|
|||
|
|
required: true
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
type: object
|
|||
|
|
properties:
|
|||
|
|
username:
|
|||
|
|
type: string
|
|||
|
|
description: 用户名
|
|||
|
|
password:
|
|||
|
|
type: string
|
|||
|
|
description: 密码
|
|||
|
|
required:
|
|||
|
|
- username
|
|||
|
|
- password
|
|||
|
|
responses:
|
|||
|
|
'200':
|
|||
|
|
description: 登录成功,返回访问令牌
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
type: object
|
|||
|
|
properties:
|
|||
|
|
access_token:
|
|||
|
|
type: string
|
|||
|
|
description: JWT访问令牌
|
|||
|
|
token_type:
|
|||
|
|
type: string
|
|||
|
|
description: 令牌类型
|
|||
|
|
'400':
|
|||
|
|
description: 请求参数错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'401':
|
|||
|
|
description: 用户名或密码错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'500':
|
|||
|
|
description: 服务器内部错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
|
|||
|
|
/api/users:
|
|||
|
|
get:
|
|||
|
|
summary: 获取用户列表
|
|||
|
|
description: 获取系统中的用户列表,支持分页
|
|||
|
|
parameters:
|
|||
|
|
- name: skip
|
|||
|
|
in: query
|
|||
|
|
description: 跳过的记录数
|
|||
|
|
required: false
|
|||
|
|
schema:
|
|||
|
|
type: integer
|
|||
|
|
default: 0
|
|||
|
|
- name: limit
|
|||
|
|
in: query
|
|||
|
|
description: 返回的记录数
|
|||
|
|
required: false
|
|||
|
|
schema:
|
|||
|
|
type: integer
|
|||
|
|
default: 100
|
|||
|
|
responses:
|
|||
|
|
'200':
|
|||
|
|
description: 成功返回用户列表
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
type: array
|
|||
|
|
items:
|
|||
|
|
$ref: '#/components/schemas/User'
|
|||
|
|
'500':
|
|||
|
|
description: 服务器内部错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
|
|||
|
|
/api/users/{id}:
|
|||
|
|
get:
|
|||
|
|
summary: 获取用户详情
|
|||
|
|
description: 根据用户ID获取用户详细信息
|
|||
|
|
parameters:
|
|||
|
|
- name: id
|
|||
|
|
in: path
|
|||
|
|
description: 用户ID
|
|||
|
|
required: true
|
|||
|
|
schema:
|
|||
|
|
type: integer
|
|||
|
|
responses:
|
|||
|
|
'200':
|
|||
|
|
description: 成功返回用户信息
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/User'
|
|||
|
|
'404':
|
|||
|
|
description: 用户未找到
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'500':
|
|||
|
|
description: 服务器内部错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
put:
|
|||
|
|
summary: 更新用户信息
|
|||
|
|
description: 根据用户ID更新用户信息(需要认证)
|
|||
|
|
security:
|
|||
|
|
- bearerAuth: []
|
|||
|
|
parameters:
|
|||
|
|
- name: id
|
|||
|
|
in: path
|
|||
|
|
description: 用户ID
|
|||
|
|
required: true
|
|||
|
|
schema:
|
|||
|
|
type: integer
|
|||
|
|
requestBody:
|
|||
|
|
required: true
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/UserUpdate'
|
|||
|
|
responses:
|
|||
|
|
'200':
|
|||
|
|
description: 成功更新用户信息
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/User'
|
|||
|
|
'400':
|
|||
|
|
description: 请求参数验证失败
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'401':
|
|||
|
|
description: 未授权
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'404':
|
|||
|
|
description: 用户未找到
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'500':
|
|||
|
|
description: 服务器内部错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
delete:
|
|||
|
|
summary: 删除用户
|
|||
|
|
description: 根据用户ID删除用户(需要认证)
|
|||
|
|
security:
|
|||
|
|
- bearerAuth: []
|
|||
|
|
parameters:
|
|||
|
|
- name: id
|
|||
|
|
in: path
|
|||
|
|
description: 用户ID
|
|||
|
|
required: true
|
|||
|
|
schema:
|
|||
|
|
type: integer
|
|||
|
|
responses:
|
|||
|
|
'200':
|
|||
|
|
description: 成功删除用户
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/User'
|
|||
|
|
'401':
|
|||
|
|
description: 未授权
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'404':
|
|||
|
|
description: 用户未找到
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
'500':
|
|||
|
|
description: 服务器内部错误
|
|||
|
|
content:
|
|||
|
|
application/json:
|
|||
|
|
schema:
|
|||
|
|
$ref: '#/components/schemas/Error'
|
|||
|
|
|
|||
|
|
components:
|
|||
|
|
schemas:
|
|||
|
|
User:
|
|||
|
|
type: object
|
|||
|
|
properties:
|
|||
|
|
id:
|
|||
|
|
type: integer
|
|||
|
|
description: 用户ID
|
|||
|
|
uuid:
|
|||
|
|
type: string
|
|||
|
|
description: 用户UUID
|
|||
|
|
username:
|
|||
|
|
type: string
|
|||
|
|
description: 用户名
|
|||
|
|
user_type:
|
|||
|
|
type: string
|
|||
|
|
enum: [client, supplier, driver, staff, admin]
|
|||
|
|
description: 用户类型
|
|||
|
|
status:
|
|||
|
|
type: string
|
|||
|
|
enum: [active, inactive, locked]
|
|||
|
|
description: 用户状态
|
|||
|
|
created_at:
|
|||
|
|
type: string
|
|||
|
|
format: date-time
|
|||
|
|
description: 创建时间
|
|||
|
|
updated_at:
|
|||
|
|
type: string
|
|||
|
|
format: date-time
|
|||
|
|
description: 更新时间
|
|||
|
|
required:
|
|||
|
|
- id
|
|||
|
|
- uuid
|
|||
|
|
- username
|
|||
|
|
- user_type
|
|||
|
|
- status
|
|||
|
|
- created_at
|
|||
|
|
- updated_at
|
|||
|
|
|
|||
|
|
UserUpdate:
|
|||
|
|
type: object
|
|||
|
|
properties:
|
|||
|
|
username:
|
|||
|
|
type: string
|
|||
|
|
description: 用户名
|
|||
|
|
user_type:
|
|||
|
|
type: string
|
|||
|
|
enum: [client, supplier, driver, staff, admin]
|
|||
|
|
description: 用户类型
|
|||
|
|
status:
|
|||
|
|
type: string
|
|||
|
|
enum: [active, inactive, locked]
|
|||
|
|
description: 用户状态
|
|||
|
|
|
|||
|
|
Error:
|
|||
|
|
type: object
|
|||
|
|
properties:
|
|||
|
|
error:
|
|||
|
|
type: string
|
|||
|
|
description: 错误信息
|
|||
|
|
required:
|
|||
|
|
- error
|
|||
|
|
|
|||
|
|
securitySchemes:
|
|||
|
|
bearerAuth:
|
|||
|
|
type: http
|
|||
|
|
scheme: bearer
|
|||
|
|
bearerFormat: JWT
|