From 04c7a106e80800a62db8515a7452f2fc1b73693b Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期五, 10 四月 2020 17:01:04 +0800 Subject: [PATCH] add swag code respformat a lot code about server --- util/util.go | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/util/util.go b/util/util.go index bf2337a..480afb1 100644 --- a/util/util.go +++ b/util/util.go @@ -5,9 +5,11 @@ "encoding/json" "errors" "fmt" + "github.com/gin-gonic/gin" "io/ioutil" "net/http" "os/exec" + "swfs/code" "time" ) @@ -98,3 +100,17 @@ total = int(middle) return total, nil } + +// ResponseFormat 杩斿洖鏁版嵁鏍煎紡鍖� +func ResponseFormat(c *gin.Context, respStatus *code.Code, data interface{}) { + if respStatus == nil { + respStatus = code.RequestParamError + } + c.JSON(respStatus.Status, gin.H{ + "code": respStatus.Status, + "success": respStatus.Success, + "msg": respStatus.Message, + "data": data, + }) + return +} -- Gitblit v1.8.0