feat(*): go 后端项目脚手架
This commit is contained in:
291
docs/docs.go
Normal file
291
docs/docs.go
Normal file
@@ -0,0 +1,291 @@
|
||||
// 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}}",
|
||||
"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": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// 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: "这是一个基于 Gin 的用户管理平台后端 API 文档",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
||||
267
docs/swagger.json
Normal file
267
docs/swagger.json
Normal file
@@ -0,0 +1,267 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
181
docs/swagger.yaml
Normal file
181
docs/swagger.yaml
Normal file
@@ -0,0 +1,181 @@
|
||||
basePath: /api/v1
|
||||
definitions:
|
||||
common.Response-any:
|
||||
properties:
|
||||
code:
|
||||
example: 0
|
||||
type: integer
|
||||
data: {}
|
||||
msg:
|
||||
example: success
|
||||
type: string
|
||||
type: object
|
||||
common.Response-handler_LoginResp:
|
||||
properties:
|
||||
code:
|
||||
example: 0
|
||||
type: integer
|
||||
data:
|
||||
$ref: '#/definitions/handler.LoginResp'
|
||||
msg:
|
||||
example: success
|
||||
type: string
|
||||
type: object
|
||||
common.Response-handler_Req:
|
||||
properties:
|
||||
code:
|
||||
example: 0
|
||||
type: integer
|
||||
data:
|
||||
$ref: '#/definitions/handler.Req'
|
||||
msg:
|
||||
example: success
|
||||
type: string
|
||||
type: object
|
||||
common.Response-model_User:
|
||||
properties:
|
||||
code:
|
||||
example: 0
|
||||
type: integer
|
||||
data:
|
||||
$ref: '#/definitions/model.User'
|
||||
msg:
|
||||
example: success
|
||||
type: string
|
||||
type: object
|
||||
handler.LoginResp:
|
||||
properties:
|
||||
token:
|
||||
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...zYyfQ.bQeIyXvkOExxD4DAy5Eyjgwj9FbjE-AO6FCLF-YFGVA
|
||||
type: string
|
||||
type: object
|
||||
handler.Req:
|
||||
properties:
|
||||
otp_code:
|
||||
example: "123456"
|
||||
type: string
|
||||
password:
|
||||
example: "123456"
|
||||
type: string
|
||||
username:
|
||||
example: admin
|
||||
type: string
|
||||
required:
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
model.User:
|
||||
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
|
||||
type: object
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: zhilv666@qq.com
|
||||
name: zhilv
|
||||
url: www.kmux.cn
|
||||
description: 这是一个基于 Gin 的用户管理平台后端 API 文档
|
||||
license:
|
||||
name: MIT
|
||||
url: https://opensource.org/licenses/MIT
|
||||
termsOfService: http://kmux.cn
|
||||
title: 我的用户管理平台 API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/api/v1/auth/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: 登录参数
|
||||
in: body
|
||||
name: login
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/handler.Req'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 登录成功
|
||||
schema:
|
||||
$ref: '#/definitions/common.Response-handler_LoginResp'
|
||||
"400":
|
||||
description: 登录失败
|
||||
schema:
|
||||
$ref: '#/definitions/common.Response-any'
|
||||
summary: 用户登录
|
||||
/api/v1/auth/register:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: 注册参数
|
||||
in: body
|
||||
name: register
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/handler.Req'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 注册成功
|
||||
schema:
|
||||
$ref: '#/definitions/common.Response-handler_Req'
|
||||
"400":
|
||||
description: 注册失败
|
||||
schema:
|
||||
$ref: '#/definitions/common.Response-any'
|
||||
summary: 用户注册
|
||||
/api/v1/user/{id}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: 用户 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 获取成功
|
||||
schema:
|
||||
$ref: '#/definitions/common.Response-model_User'
|
||||
"400":
|
||||
description: 获取失败
|
||||
schema:
|
||||
$ref: '#/definitions/common.Response-any'
|
||||
summary: 获取指定 ID 用户
|
||||
swagger: "2.0"
|
||||
Reference in New Issue
Block a user