Files
niumalll/backend/docs/openapi.json

262 lines
7.7 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"openapi": "3.0.0",
"info": {
"title": "NiuMall 管理系统 API",
"description": "NiuMall 管理系统后端API文档",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:4330/api",
"description": "本地开发环境"
}
],
"paths": {
"/auth/login": {
"post": {
"summary": "用户登录",
"description": "管理员用户登录认证接口,支持通过用户名或邮箱登录",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["username", "password"],
"properties": {
"username": {
"type": "string",
"description": "用户名或邮箱"
},
"password": {
"type": "string",
"description": "用户密码"
}
},
"example": {
"username": "admin",
"password": "123456"
}
}
}
}
},
"responses": {
"200": {
"description": "登录成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "登录成功"
},
"access_token": {
"type": "string",
"description": "JWT访问令牌"
},
"token_type": {
"type": "string",
"example": "Bearer"
},
"expires_in": {
"type": "integer",
"description": "令牌过期时间(分钟)",
"example": 1440
},
"user": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"username": {
"type": "string",
"example": "admin"
},
"email": {
"type": "string",
"example": "admin@niumall.com"
},
"phone": {
"type": "string",
"example": "13800138000"
},
"role": {
"type": "string",
"example": "admin"
},
"status": {
"type": "string",
"example": "active"
}
}
}
}
}
}
}
},
"400": {
"description": "参数错误",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": false
},
"message": {
"type": "string",
"example": "用户名和密码不能为空"
}
}
}
}
}
},
"401": {
"description": "认证失败",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": false
},
"message": {
"type": "string",
"example": "用户名或密码错误"
}
}
}
}
}
},
"500": {
"description": "服务器错误",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": false
},
"message": {
"type": "string",
"example": "登录失败,请稍后再试"
}
}
}
}
}
}
}
}
},
"/auth/current": {
"get": {
"summary": "获取当前用户信息",
"description": "获取当前登录用户的详细信息需要JWT认证",
"security": [
{
"bearerAuth": []
}
],
"responses": {
"200": {
"description": "获取成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "获取用户信息成功"
},
"data": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"username": {
"type": "string",
"example": "admin"
},
"email": {
"type": "string",
"example": "admin@niumall.com"
},
"phone": {
"type": "string",
"example": "13800138000"
},
"user_type": {
"type": "string",
"example": "admin"
},
"status": {
"type": "string",
"example": "active"
}
}
}
}
}
}
}
},
"401": {
"description": "未认证",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": false
},
"message": {
"type": "string",
"example": "未授权,请登录"
}
}
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
}
}