diff --git a/app/common/api/captcha.go b/app/common/api/captcha.go index 750927d..2e9b8ad 100644 --- a/app/common/api/captcha.go +++ b/app/common/api/captcha.go @@ -15,8 +15,8 @@ var Captcha = new(captcha) // @Summary 获取验证码图片信息 // @Description 获取验证码图片信息 // @Tags 公共 -// @Success 0 {object} response.Response "{"code": 200, "data": [...]}" -// @Router /system/public/verify [post] +// @Success 0 {object} library.Response "{"code": 200, "data": [...]}" +// @Router /captcha/get [get] // @Security func (c *captcha) Img(r *ghttp.Request) { idKeyC, base64stringC := service.Captcha.GetVerifyImgString() diff --git a/app/system/api/upload.go b/app/system/api/upload.go index 2a72356..7c38004 100644 --- a/app/system/api/upload.go +++ b/app/system/api/upload.go @@ -35,11 +35,12 @@ func (c *upload) UpImg(r *ghttp.Request) { c.SusJsonExit(r, res) } +// CkEditorUp // @Summary CkEditor编辑器上传附件 // @Description CkEditor编辑器上传附件 // @Tags 公共 // @Param upFile body string true "upFile" -// @Success 0 {object} c.Response "{"code": 200, "data": [...]}" +// @Success 0 {object} library.Response "{"code": 200, "data": [...]}" // @Router /system/upload/ckEditorUp [post] // @Security func (c *upload) CkEditorUp(r *ghttp.Request) { @@ -64,11 +65,12 @@ func (c *upload) CkEditorUp(r *ghttp.Request) { } } +// UpImgs // @Summary 批量上传图片 // @Description 批量上传图片 // @Tags 公共 // @Param file body string true "file" -// @Success 0 {object} c.Response "{"code": 200, "data": [...]}" +// @Success 0 {object} library.Response "{"code": 200, "data": [...]}" // @Router /system/upload/upImgs [post] // @Security func (c *upload) UpImgs(r *ghttp.Request) { @@ -83,11 +85,12 @@ func (c *upload) UpImgs(r *ghttp.Request) { c.SusJson(true, r, "上传成功", res) } +// UpFile // @Summary 单文件上传 // @Description 单文件上传 // @Tags 公共 // @Param file body string true "file" -// @Success 0 {object} c.Response "{"code": 200, "data": [...]}" +// @Success 0 {object} library.Response "{"code": 200, "data": [...]}" // @Router /system/upload/upFile [post] // @Security func (c *upload) UpFile(r *ghttp.Request) { @@ -102,11 +105,12 @@ func (c *upload) UpFile(r *ghttp.Request) { c.SusJson(true, r, "上传成功", res) } +// UpFiles // @Summary 批量上传文件 // @Description 批量上传文件 // @Tags 公共 // @Param file body string true "file" -// @Success 0 {object} c.Response "{"code": 200, "data": [...]}" +// @Success 0 {object} library.Response "{"code": 200, "data": [...]}" // @Router /system/upload/upFiles [post] // @Security func (c *upload) UpFiles(r *ghttp.Request) { diff --git a/go.mod b/go.mod index 76ae1c7..3373d84 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/goflyfox/gtoken v1.4.2 github.com/gogf/gcache-adapter v0.1.2 github.com/gogf/gf v1.16.4 + github.com/gogf/swagger v1.3.0 github.com/google/go-querystring v1.1.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/kr/text v0.2.0 // indirect diff --git a/go.sum b/go.sum index 5615590..ddc5564 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ github.com/gogf/gf v1.16.4 h1:1Y8/P1UMp9BmrtUn0wAg3g6ElRAO0R9QHCdUNt9Z5L4= github.com/gogf/gf v1.16.4/go.mod h1:EjnxZXddTwfFoLPofDE3NokFWx+immofINtSyFCj280= github.com/gogf/mysql v1.6.1-0.20210603073548-16164ae25579 h1:pP/uEy52biKDytlgK/ug8kiYPAiYu6KajKVUHfGrtyw= github.com/gogf/mysql v1.6.1-0.20210603073548-16164ae25579/go.mod h1:52e6mXyNnHAsFrXrSnj5JPRSKsZKpHylVtA3j4AtMz8= +github.com/gogf/swagger v1.3.0 h1:McpIEwj2DXLF3/ZNN9h9LKza/fsjtHP54nMTYVSCQ74= +github.com/gogf/swagger v1.3.0/go.mod h1:VDpNntu8+8NTTJ3sLOZNPO1LUbfW/ZA84IFJhhrlpoM= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= diff --git a/main.go b/main.go index f8045cb..a17ca32 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,15 @@ import ( _ "gfast/boot" _ "gfast/router" "github.com/gogf/gf/frame/g" + "github.com/gogf/swagger" ) +// @title GFast +// @version 2.0 +// @description GFast后台管理框架 +// @schemes http https func main() { - g.Server().Run() + s := g.Server() + s.Plugin(&swagger.Swagger{}) + s.Run() } diff --git a/packed/swagger.go b/packed/swagger.go new file mode 100644 index 0000000..a39272a --- /dev/null +++ b/packed/swagger.go @@ -0,0 +1,9 @@ +package packed + +import "github.com/gogf/gf/os/gres" + +func init() { + if err := gres.Add("H4sIAAAAAAAC/wrwZmYRYeBg4GDYoqAYzIAERBg4GYrLE9PTU4v0obReVnF+XmgIKwOjyB+9xDcRvv63HQT2ftZek9sfKFN4ZqtW6PqpVU0yYtWPcqRv377reZvjqcBKh5Wn3PkVFJdwXfEODXXQz9QW+Gtc6PTP9Wkvs9m25oUaDqnzNxnn2+rnp81/Ejvjkomv8qUVjbyTpmyNFA04KKWk3voiSmjrOpGm2vwVqY0Kqb0+4t6MMwyWv5q0aVvBvqssmRzHJu7s6681clatks6+9yuxvn79/o1Xbke/qn3X0q142GpO4mHJw6UTpF6IZ7QeWu944sFXO9GpHJ9agtec1FC+u0CmV+qq7gEPt9TJTVqKBzM42s52BD1U35f+RaDeX9XwbperdmvFW26leev+frm2ne2+3Ty5Lb935+Y/X7J/052/m69ny09oueuhO/PUrIru+3uPyqsI89/ckKs16/oDBYei6xMVhI+GTgjK8vK+kJDYJ7GOs3jJGt/pXqy5fTNEVu6foyvWPTWMqXNz+MqZy5NPa95xZgzdf435botW8Yz46FelZvorMsTms9Zr6t190WlubinVO2f9Ied1p5e5bPjKtn73lSu90/t929ZVnHusfCa28nv6j8AP7L+ORy9Xn7/n7fq78fK7ju9uflt+d/G5I8t+nNKxEL3CxjLxnOpvHvMfPKsP7/AsXcF7c4LP3sJ7prMfBzDFmc5gmDzFVIR3R6Nxk+86CS+RMxv//dVRMdUx7ze8mD3D3cD3+2WLPVfP3rtW9H2Fsc0q4c1dPKX5V2RWSa59aBSTxxMuYGvOFuYf8LnOwjn/6feEytoKm3b30qRnE9aWvONXjHnHr7nD+i2/f+7r+g3tD5+/WnvDuerlHTmnHXfkggq25/G/uv6iTveIYtVpMWUR497A9rs/xRMesGZyiOuxN+ostfR6/mVb7Avv7y+867fPXfRPUvCZQoTCpYQP027F1Jr5Tvcq3DmJpyOpyjn525bKG9F35d/oxLoZX9AWZo6OuslZck89/l5m5LnHqo+Nrv6SZmD4/z/Am52jcL7Z1H1MDAwFYgwMsIzAgJER2BEZAZz2Rf/oJYJ0I6sJ8GZkEmFGZCRkk0EZCQa2NYJIvNkKYRR2p0CAAMN/R05mBiwOY2UDyTMxMDF0MjAwuDODeIAAAAD//+jkmAXmAwAA"); err != nil { + panic("add binary content to resource manager failed: " + err.Error()) + } +} diff --git a/swagger/swagger.json b/swagger/swagger.json new file mode 100644 index 0000000..e2e941a --- /dev/null +++ b/swagger/swagger.json @@ -0,0 +1,189 @@ +{ + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "GFast后台管理框架", + "title": "GFast", + "contact": {}, + "version": "2.0" + }, + "paths": { + "/captcha/get": { + "get": { + "security": [ + { + "": [] + } + ], + "description": "获取验证码图片信息", + "tags": [ + "公共" + ], + "summary": "获取验证码图片信息", + "responses": { + "0": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/library.Response" + } + } + } + } + }, + "/system/upload/ckEditorUp": { + "post": { + "security": [ + { + "": [] + } + ], + "description": "CkEditor编辑器上传附件", + "tags": [ + "公共" + ], + "summary": "CkEditor编辑器上传附件", + "parameters": [ + { + "description": "upFile", + "name": "upFile", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "0": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/library.Response" + } + } + } + } + }, + "/system/upload/upFile": { + "post": { + "security": [ + { + "": [] + } + ], + "description": "单文件上传", + "tags": [ + "公共" + ], + "summary": "单文件上传", + "parameters": [ + { + "description": "file", + "name": "file", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "0": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/library.Response" + } + } + } + } + }, + "/system/upload/upFiles": { + "post": { + "security": [ + { + "": [] + } + ], + "description": "批量上传文件", + "tags": [ + "公共" + ], + "summary": "批量上传文件", + "parameters": [ + { + "description": "file", + "name": "file", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "0": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/library.Response" + } + } + } + } + }, + "/system/upload/upImgs": { + "post": { + "security": [ + { + "": [] + } + ], + "description": "批量上传图片", + "tags": [ + "公共" + ], + "summary": "批量上传图片", + "parameters": [ + { + "description": "file", + "name": "file", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "0": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/library.Response" + } + } + } + } + } + }, + "definitions": { + "library.Response": { + "type": "object", + "properties": { + "code": { + "description": "代码", + "type": "integer", + "example": 200 + }, + "data": { + "description": "数据集", + "type": "object" + }, + "msg": { + "description": "消息", + "type": "string" + } + } + } + } +} \ No newline at end of file