{ "swagger": "2.0", "info": { "description": "这是一个基于 Gin 的用户管理平台后端 API 文档", "title": "我的用户管理平台 API", "termsOfService": "http://kmux.cn", "contact": { "name": "zhilv", "url": "www.kmux.cn", "email": "zhilv666@qq.com" }, "license": { "name": "MIT", "url": "https://opensource.org/licenses/MIT" }, "version": "1.0" }, "host": "localhost:8080", "basePath": "/api/v1", "paths": { "/api/v1/auth/login": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "用户登录", "parameters": [ { "description": "登录参数", "name": "login", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.Req" } } ], "responses": { "200": { "description": "登录成功", "schema": { "$ref": "#/definitions/common.Response-handler_LoginResp" } }, "400": { "description": "登录失败", "schema": { "$ref": "#/definitions/common.Response-any" } } } } }, "/api/v1/auth/register": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "用户注册", "parameters": [ { "description": "注册参数", "name": "register", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.Req" } } ], "responses": { "200": { "description": "注册成功", "schema": { "$ref": "#/definitions/common.Response-handler_Req" } }, "400": { "description": "注册失败", "schema": { "$ref": "#/definitions/common.Response-any" } } } } }, "/api/v1/user/{id}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "获取指定 ID 用户", "parameters": [ { "type": "integer", "description": "用户 ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "获取成功", "schema": { "$ref": "#/definitions/common.Response-model_User" } }, "400": { "description": "获取失败", "schema": { "$ref": "#/definitions/common.Response-any" } } } } } }, "definitions": { "common.Response-any": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": {}, "msg": { "type": "string", "example": "success" } } }, "common.Response-handler_LoginResp": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "$ref": "#/definitions/handler.LoginResp" }, "msg": { "type": "string", "example": "success" } } }, "common.Response-handler_Req": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "$ref": "#/definitions/handler.Req" }, "msg": { "type": "string", "example": "success" } } }, "common.Response-model_User": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "$ref": "#/definitions/model.User" }, "msg": { "type": "string", "example": "success" } } }, "handler.LoginResp": { "type": "object", "properties": { "token": { "type": "string", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...zYyfQ.bQeIyXvkOExxD4DAy5Eyjgwj9FbjE-AO6FCLF-YFGVA" } } }, "handler.Req": { "type": "object", "required": [ "password", "username" ], "properties": { "otp_code": { "type": "string", "example": "123456" }, "password": { "type": "string", "example": "123456" }, "username": { "type": "string", "example": "admin" } } }, "model.User": { "type": "object", "properties": { "created_at": { "type": "string" }, "disabled": { "description": "禁用标志", "type": "boolean" }, "email": { "type": "string" }, "id": { "type": "integer" }, "is_admin": { "description": "true = 管理员", "type": "boolean" }, "points": { "description": "积分", "type": "integer" }, "sso_id": { "description": "OAuth2 唯一标识", "type": "string" }, "updated_at": { "type": "string" }, "username": { "description": "邮箱注册", "type": "string" }, "verified": { "description": "是否通过邮箱验证/管理员审核", "type": "boolean" }, "verify_at": { "description": "验证时间", "type": "string" } } } } }