feat(*): go 后端项目脚手架

This commit is contained in:
2025-11-15 18:20:30 +08:00
commit 5bb025c1aa
39 changed files with 2459 additions and 0 deletions

181
docs/swagger.yaml Normal file
View 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"