From 5610bc1f758e6b7b7738e4ac4ee492206b26b3e3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 13 Jul 2024 14:49:10 +0800 Subject: [PATCH] 1 --- sysutils.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sysutils.go b/sysutils.go index 2a547e8..0d599fd 100644 --- a/sysutils.go +++ b/sysutils.go @@ -7,6 +7,8 @@ import ( "sync" "errors" "gorm.io/gorm" + "net/http" + "github.com/gin-gonic/gin" ) const ( @@ -96,6 +98,20 @@ func BatchReleaseLock(locks []*sync.Mutex) { } } +func RspErr(c *gin.Context, errCode int32, errMsg string) { + c.JSON(http.StatusOK, gin.H{ + "errcode": errCode, + "errmsg": errMsg, + }) +} + +func RspErr2(c *gin.Context, code int32, message string) { + c.JSON(http.StatusOK, gin.H{ + "code": code, + "message": message, + }) +} + func init() { switch os.Getenv("SERVER_ENV") { case "TEST":