swagger
This commit is contained in:
256
docs/docs.go
Normal file
256
docs/docs.go
Normal file
@@ -0,0 +1,256 @@
|
||||
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
const docTemplate = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"contact": {
|
||||
"name": "Divano",
|
||||
"url": "http://www.example.com",
|
||||
"email": "divano@example.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/users": {
|
||||
"post": {
|
||||
"description": "根据用户名和密码创建一个新的系统用户。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户管理"
|
||||
],
|
||||
"summary": "创建新用户",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "用户信息",
|
||||
"name": "user",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/user.CreateUserRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "用户创建成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/user.CreateUserResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "请求参数错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "用户名已存在",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "服务器内部错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/login": {
|
||||
"post": {
|
||||
"description": "用户使用用户名和密码登录,成功后返回 JWT 令牌。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户管理"
|
||||
],
|
||||
"summary": "用户登录",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "登录凭证",
|
||||
"name": "credentials",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/user.LoginRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "登录成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/user.LoginResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "请求参数错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "用户名或密码不正确",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "服务器内部错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"controller.Response": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"description": "业务状态码",
|
||||
"type": "integer"
|
||||
},
|
||||
"data": {
|
||||
"description": "业务数据"
|
||||
},
|
||||
"message": {
|
||||
"description": "提示信息",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.CreateUserRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 6,
|
||||
"example": "password123"
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "newuser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.CreateUserResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "newuser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.LoginRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string",
|
||||
"example": "password123"
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "testuser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.LoginResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"token": {
|
||||
"type": "string",
|
||||
"example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "testuser"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "localhost:8080",
|
||||
BasePath: "/api/v1",
|
||||
Schemes: []string{},
|
||||
Title: "猪场管理系统 API",
|
||||
Description: "这是一个用于管理猪场设备的后端服务。",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
||||
232
docs/swagger.json
Normal file
232
docs/swagger.json
Normal file
@@ -0,0 +1,232 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "这是一个用于管理猪场设备的后端服务。",
|
||||
"title": "猪场管理系统 API",
|
||||
"contact": {
|
||||
"name": "Divano",
|
||||
"url": "http://www.example.com",
|
||||
"email": "divano@example.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost:8080",
|
||||
"basePath": "/api/v1",
|
||||
"paths": {
|
||||
"/users": {
|
||||
"post": {
|
||||
"description": "根据用户名和密码创建一个新的系统用户。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户管理"
|
||||
],
|
||||
"summary": "创建新用户",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "用户信息",
|
||||
"name": "user",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/user.CreateUserRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "用户创建成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/user.CreateUserResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "请求参数错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "用户名已存在",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "服务器内部错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/login": {
|
||||
"post": {
|
||||
"description": "用户使用用户名和密码登录,成功后返回 JWT 令牌。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户管理"
|
||||
],
|
||||
"summary": "用户登录",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "登录凭证",
|
||||
"name": "credentials",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/user.LoginRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "登录成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/user.LoginResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "请求参数错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "用户名或密码不正确",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "服务器内部错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"controller.Response": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"description": "业务状态码",
|
||||
"type": "integer"
|
||||
},
|
||||
"data": {
|
||||
"description": "业务数据"
|
||||
},
|
||||
"message": {
|
||||
"description": "提示信息",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.CreateUserRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 6,
|
||||
"example": "password123"
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "newuser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.CreateUserResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "newuser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.LoginRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string",
|
||||
"example": "password123"
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "testuser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user.LoginResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"token": {
|
||||
"type": "string",
|
||||
"example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"example": "testuser"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
151
docs/swagger.yaml
Normal file
151
docs/swagger.yaml
Normal file
@@ -0,0 +1,151 @@
|
||||
basePath: /api/v1
|
||||
definitions:
|
||||
controller.Response:
|
||||
properties:
|
||||
code:
|
||||
description: 业务状态码
|
||||
type: integer
|
||||
data:
|
||||
description: 业务数据
|
||||
message:
|
||||
description: 提示信息
|
||||
type: string
|
||||
type: object
|
||||
user.CreateUserRequest:
|
||||
properties:
|
||||
password:
|
||||
example: password123
|
||||
minLength: 6
|
||||
type: string
|
||||
username:
|
||||
example: newuser
|
||||
type: string
|
||||
required:
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
user.CreateUserResponse:
|
||||
properties:
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
username:
|
||||
example: newuser
|
||||
type: string
|
||||
type: object
|
||||
user.LoginRequest:
|
||||
properties:
|
||||
password:
|
||||
example: password123
|
||||
type: string
|
||||
username:
|
||||
example: testuser
|
||||
type: string
|
||||
required:
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
user.LoginResponse:
|
||||
properties:
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
token:
|
||||
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
|
||||
type: string
|
||||
username:
|
||||
example: testuser
|
||||
type: string
|
||||
type: object
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: divano@example.com
|
||||
name: Divano
|
||||
url: http://www.example.com
|
||||
description: 这是一个用于管理猪场设备的后端服务。
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: 猪场管理系统 API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/users:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 根据用户名和密码创建一个新的系统用户。
|
||||
parameters:
|
||||
- description: 用户信息
|
||||
in: body
|
||||
name: user
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.CreateUserRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 用户创建成功
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/controller.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.CreateUserResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: 请求参数错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"409":
|
||||
description: 用户名已存在
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"500":
|
||||
description: 服务器内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
summary: 创建新用户
|
||||
tags:
|
||||
- 用户管理
|
||||
/users/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 用户使用用户名和密码登录,成功后返回 JWT 令牌。
|
||||
parameters:
|
||||
- description: 登录凭证
|
||||
in: body
|
||||
name: credentials
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.LoginRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 登录成功
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/controller.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.LoginResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: 请求参数错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"401":
|
||||
description: 用户名或密码不正确
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"500":
|
||||
description: 服务器内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
summary: 用户登录
|
||||
tags:
|
||||
- 用户管理
|
||||
swagger: "2.0"
|
||||
Reference in New Issue
Block a user