9 changed files with 1109 additions and 7 deletions
@ -0,0 +1,371 @@
@@ -0,0 +1,371 @@
|
||||
// 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://swagger.io/terms/", |
||||
"contact": { |
||||
"name": "API支持", |
||||
"url": "http://www.gofaster.com/support", |
||||
"email": "support@gofaster.com" |
||||
}, |
||||
"license": { |
||||
"name": "Apache 2.0", |
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" |
||||
}, |
||||
"version": "{{.Version}}" |
||||
}, |
||||
"host": "{{.Host}}", |
||||
"basePath": "{{.BasePath}}", |
||||
"paths": { |
||||
"/users": { |
||||
"get": { |
||||
"description": "获取分页用户列表", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "获取用户列表", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"default": 1, |
||||
"description": "页码", |
||||
"name": "page", |
||||
"in": "query" |
||||
}, |
||||
{ |
||||
"type": "integer", |
||||
"default": 10, |
||||
"description": "每页数量", |
||||
"name": "pageSize", |
||||
"in": "query" |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "用户列表", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": true |
||||
} |
||||
}, |
||||
"400": { |
||||
"description": "请求参数错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/users/{id}": { |
||||
"get": { |
||||
"description": "根据ID获取用户详情", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "获取用户详情", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"description": "用户ID", |
||||
"name": "id", |
||||
"in": "path", |
||||
"required": true |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "用户信息", |
||||
"schema": { |
||||
"$ref": "#/definitions/model.User" |
||||
} |
||||
}, |
||||
"400": { |
||||
"description": "无效的用户ID", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"404": { |
||||
"description": "用户不存在", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"put": { |
||||
"description": "根据ID更新用户信息", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "更新用户信息", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"description": "用户ID", |
||||
"name": "id", |
||||
"in": "path", |
||||
"required": true |
||||
}, |
||||
{ |
||||
"description": "用户信息", |
||||
"name": "user", |
||||
"in": "body", |
||||
"required": true, |
||||
"schema": { |
||||
"$ref": "#/definitions/model.User" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "更新后的用户信息", |
||||
"schema": { |
||||
"$ref": "#/definitions/model.User" |
||||
} |
||||
}, |
||||
"400": { |
||||
"description": "无效的用户ID或请求参数", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"404": { |
||||
"description": "用户不存在", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"delete": { |
||||
"description": "根据ID删除用户", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "删除用户", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"description": "用户ID", |
||||
"name": "id", |
||||
"in": "path", |
||||
"required": true |
||||
} |
||||
], |
||||
"responses": { |
||||
"204": { |
||||
"description": "删除成功" |
||||
}, |
||||
"400": { |
||||
"description": "无效的用户ID", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"404": { |
||||
"description": "用户不存在", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"definitions": { |
||||
"model.Permission": { |
||||
"type": "object", |
||||
"properties": { |
||||
"action": { |
||||
"description": "create, read, update, delete等", |
||||
"type": "string" |
||||
}, |
||||
"created_at": { |
||||
"type": "string" |
||||
}, |
||||
"description": { |
||||
"type": "string" |
||||
}, |
||||
"id": { |
||||
"type": "integer" |
||||
}, |
||||
"name": { |
||||
"type": "string" |
||||
}, |
||||
"resource": { |
||||
"type": "string" |
||||
}, |
||||
"updated_at": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"model.Role": { |
||||
"type": "object", |
||||
"properties": { |
||||
"created_at": { |
||||
"type": "string" |
||||
}, |
||||
"description": { |
||||
"type": "string" |
||||
}, |
||||
"id": { |
||||
"type": "integer" |
||||
}, |
||||
"name": { |
||||
"type": "string" |
||||
}, |
||||
"permissions": { |
||||
"type": "array", |
||||
"items": { |
||||
"$ref": "#/definitions/model.Permission" |
||||
} |
||||
}, |
||||
"updated_at": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"model.User": { |
||||
"type": "object", |
||||
"properties": { |
||||
"created_at": { |
||||
"type": "string" |
||||
}, |
||||
"email": { |
||||
"type": "string" |
||||
}, |
||||
"id": { |
||||
"type": "integer" |
||||
}, |
||||
"phone": { |
||||
"type": "string" |
||||
}, |
||||
"roles": { |
||||
"type": "array", |
||||
"items": { |
||||
"$ref": "#/definitions/model.Role" |
||||
} |
||||
}, |
||||
"status": { |
||||
"description": "1-正常 2-禁用", |
||||
"type": "integer" |
||||
}, |
||||
"updated_at": { |
||||
"type": "string" |
||||
}, |
||||
"username": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}` |
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{ |
||||
Version: "1.0", |
||||
Host: "localhost:8080", |
||||
BasePath: "/api", |
||||
Schemes: []string{"http"}, |
||||
Title: "GoFaster API", |
||||
Description: "GoFaster项目API文档", |
||||
InfoInstanceName: "swagger", |
||||
SwaggerTemplate: docTemplate, |
||||
LeftDelim: "{{", |
||||
RightDelim: "}}", |
||||
} |
||||
|
||||
func init() { |
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) |
||||
} |
@ -0,0 +1,350 @@
@@ -0,0 +1,350 @@
|
||||
{ |
||||
"schemes": [ |
||||
"http" |
||||
], |
||||
"swagger": "2.0", |
||||
"info": { |
||||
"description": "GoFaster项目API文档", |
||||
"title": "GoFaster API", |
||||
"termsOfService": "http://swagger.io/terms/", |
||||
"contact": { |
||||
"name": "API支持", |
||||
"url": "http://www.gofaster.com/support", |
||||
"email": "support@gofaster.com" |
||||
}, |
||||
"license": { |
||||
"name": "Apache 2.0", |
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" |
||||
}, |
||||
"version": "1.0" |
||||
}, |
||||
"host": "localhost:8080", |
||||
"basePath": "/api", |
||||
"paths": { |
||||
"/users": { |
||||
"get": { |
||||
"description": "获取分页用户列表", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "获取用户列表", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"default": 1, |
||||
"description": "页码", |
||||
"name": "page", |
||||
"in": "query" |
||||
}, |
||||
{ |
||||
"type": "integer", |
||||
"default": 10, |
||||
"description": "每页数量", |
||||
"name": "pageSize", |
||||
"in": "query" |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "用户列表", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": true |
||||
} |
||||
}, |
||||
"400": { |
||||
"description": "请求参数错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/users/{id}": { |
||||
"get": { |
||||
"description": "根据ID获取用户详情", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "获取用户详情", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"description": "用户ID", |
||||
"name": "id", |
||||
"in": "path", |
||||
"required": true |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "用户信息", |
||||
"schema": { |
||||
"$ref": "#/definitions/model.User" |
||||
} |
||||
}, |
||||
"400": { |
||||
"description": "无效的用户ID", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"404": { |
||||
"description": "用户不存在", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"put": { |
||||
"description": "根据ID更新用户信息", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "更新用户信息", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"description": "用户ID", |
||||
"name": "id", |
||||
"in": "path", |
||||
"required": true |
||||
}, |
||||
{ |
||||
"description": "用户信息", |
||||
"name": "user", |
||||
"in": "body", |
||||
"required": true, |
||||
"schema": { |
||||
"$ref": "#/definitions/model.User" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "更新后的用户信息", |
||||
"schema": { |
||||
"$ref": "#/definitions/model.User" |
||||
} |
||||
}, |
||||
"400": { |
||||
"description": "无效的用户ID或请求参数", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"404": { |
||||
"description": "用户不存在", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"delete": { |
||||
"description": "根据ID删除用户", |
||||
"consumes": [ |
||||
"application/json" |
||||
], |
||||
"produces": [ |
||||
"application/json" |
||||
], |
||||
"tags": [ |
||||
"用户管理" |
||||
], |
||||
"summary": "删除用户", |
||||
"parameters": [ |
||||
{ |
||||
"type": "integer", |
||||
"description": "用户ID", |
||||
"name": "id", |
||||
"in": "path", |
||||
"required": true |
||||
} |
||||
], |
||||
"responses": { |
||||
"204": { |
||||
"description": "删除成功" |
||||
}, |
||||
"400": { |
||||
"description": "无效的用户ID", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"404": { |
||||
"description": "用户不存在", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"500": { |
||||
"description": "服务器内部错误", |
||||
"schema": { |
||||
"type": "object", |
||||
"additionalProperties": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"definitions": { |
||||
"model.Permission": { |
||||
"type": "object", |
||||
"properties": { |
||||
"action": { |
||||
"description": "create, read, update, delete等", |
||||
"type": "string" |
||||
}, |
||||
"created_at": { |
||||
"type": "string" |
||||
}, |
||||
"description": { |
||||
"type": "string" |
||||
}, |
||||
"id": { |
||||
"type": "integer" |
||||
}, |
||||
"name": { |
||||
"type": "string" |
||||
}, |
||||
"resource": { |
||||
"type": "string" |
||||
}, |
||||
"updated_at": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"model.Role": { |
||||
"type": "object", |
||||
"properties": { |
||||
"created_at": { |
||||
"type": "string" |
||||
}, |
||||
"description": { |
||||
"type": "string" |
||||
}, |
||||
"id": { |
||||
"type": "integer" |
||||
}, |
||||
"name": { |
||||
"type": "string" |
||||
}, |
||||
"permissions": { |
||||
"type": "array", |
||||
"items": { |
||||
"$ref": "#/definitions/model.Permission" |
||||
} |
||||
}, |
||||
"updated_at": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
}, |
||||
"model.User": { |
||||
"type": "object", |
||||
"properties": { |
||||
"created_at": { |
||||
"type": "string" |
||||
}, |
||||
"email": { |
||||
"type": "string" |
||||
}, |
||||
"id": { |
||||
"type": "integer" |
||||
}, |
||||
"phone": { |
||||
"type": "string" |
||||
}, |
||||
"roles": { |
||||
"type": "array", |
||||
"items": { |
||||
"$ref": "#/definitions/model.Role" |
||||
} |
||||
}, |
||||
"status": { |
||||
"description": "1-正常 2-禁用", |
||||
"type": "integer" |
||||
}, |
||||
"updated_at": { |
||||
"type": "string" |
||||
}, |
||||
"username": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,234 @@
@@ -0,0 +1,234 @@
|
||||
basePath: /api |
||||
definitions: |
||||
model.Permission: |
||||
properties: |
||||
action: |
||||
description: create, read, update, delete等 |
||||
type: string |
||||
created_at: |
||||
type: string |
||||
description: |
||||
type: string |
||||
id: |
||||
type: integer |
||||
name: |
||||
type: string |
||||
resource: |
||||
type: string |
||||
updated_at: |
||||
type: string |
||||
type: object |
||||
model.Role: |
||||
properties: |
||||
created_at: |
||||
type: string |
||||
description: |
||||
type: string |
||||
id: |
||||
type: integer |
||||
name: |
||||
type: string |
||||
permissions: |
||||
items: |
||||
$ref: '#/definitions/model.Permission' |
||||
type: array |
||||
updated_at: |
||||
type: string |
||||
type: object |
||||
model.User: |
||||
properties: |
||||
created_at: |
||||
type: string |
||||
email: |
||||
type: string |
||||
id: |
||||
type: integer |
||||
phone: |
||||
type: string |
||||
roles: |
||||
items: |
||||
$ref: '#/definitions/model.Role' |
||||
type: array |
||||
status: |
||||
description: 1-正常 2-禁用 |
||||
type: integer |
||||
updated_at: |
||||
type: string |
||||
username: |
||||
type: string |
||||
type: object |
||||
host: localhost:8080 |
||||
info: |
||||
contact: |
||||
email: support@gofaster.com |
||||
name: API支持 |
||||
url: http://www.gofaster.com/support |
||||
description: GoFaster项目API文档 |
||||
license: |
||||
name: Apache 2.0 |
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html |
||||
termsOfService: http://swagger.io/terms/ |
||||
title: GoFaster API |
||||
version: "1.0" |
||||
paths: |
||||
/users: |
||||
get: |
||||
consumes: |
||||
- application/json |
||||
description: 获取分页用户列表 |
||||
parameters: |
||||
- default: 1 |
||||
description: 页码 |
||||
in: query |
||||
name: page |
||||
type: integer |
||||
- default: 10 |
||||
description: 每页数量 |
||||
in: query |
||||
name: pageSize |
||||
type: integer |
||||
produces: |
||||
- application/json |
||||
responses: |
||||
"200": |
||||
description: 用户列表 |
||||
schema: |
||||
additionalProperties: true |
||||
type: object |
||||
"400": |
||||
description: 请求参数错误 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"500": |
||||
description: 服务器内部错误 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
summary: 获取用户列表 |
||||
tags: |
||||
- 用户管理 |
||||
/users/{id}: |
||||
delete: |
||||
consumes: |
||||
- application/json |
||||
description: 根据ID删除用户 |
||||
parameters: |
||||
- description: 用户ID |
||||
in: path |
||||
name: id |
||||
required: true |
||||
type: integer |
||||
produces: |
||||
- application/json |
||||
responses: |
||||
"204": |
||||
description: 删除成功 |
||||
"400": |
||||
description: 无效的用户ID |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"404": |
||||
description: 用户不存在 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"500": |
||||
description: 服务器内部错误 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
summary: 删除用户 |
||||
tags: |
||||
- 用户管理 |
||||
get: |
||||
consumes: |
||||
- application/json |
||||
description: 根据ID获取用户详情 |
||||
parameters: |
||||
- description: 用户ID |
||||
in: path |
||||
name: id |
||||
required: true |
||||
type: integer |
||||
produces: |
||||
- application/json |
||||
responses: |
||||
"200": |
||||
description: 用户信息 |
||||
schema: |
||||
$ref: '#/definitions/model.User' |
||||
"400": |
||||
description: 无效的用户ID |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"404": |
||||
description: 用户不存在 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"500": |
||||
description: 服务器内部错误 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
summary: 获取用户详情 |
||||
tags: |
||||
- 用户管理 |
||||
put: |
||||
consumes: |
||||
- application/json |
||||
description: 根据ID更新用户信息 |
||||
parameters: |
||||
- description: 用户ID |
||||
in: path |
||||
name: id |
||||
required: true |
||||
type: integer |
||||
- description: 用户信息 |
||||
in: body |
||||
name: user |
||||
required: true |
||||
schema: |
||||
$ref: '#/definitions/model.User' |
||||
produces: |
||||
- application/json |
||||
responses: |
||||
"200": |
||||
description: 更新后的用户信息 |
||||
schema: |
||||
$ref: '#/definitions/model.User' |
||||
"400": |
||||
description: 无效的用户ID或请求参数 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"404": |
||||
description: 用户不存在 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
"500": |
||||
description: 服务器内部错误 |
||||
schema: |
||||
additionalProperties: |
||||
type: string |
||||
type: object |
||||
summary: 更新用户信息 |
||||
tags: |
||||
- 用户管理 |
||||
schemes: |
||||
- http |
||||
swagger: "2.0" |
Loading…
Reference in new issue