From e4c444ad62cea8c53b27a65fa2299ed00b4c270c Mon Sep 17 00:00:00 2001 From: "LinskRuis.32" Date: Sat, 27 Jun 2020 11:55:33 +0800 Subject: [PATCH] const+ --- core/utils/code.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/utils/code.go b/core/utils/code.go index 18da74f..7c263a1 100644 --- a/core/utils/code.go +++ b/core/utils/code.go @@ -3,6 +3,8 @@ package utils import ( "GoClouds/core/comm" "fmt" + ruisUtil "github.com/mgr9525/go-ruisutil" + "gopkg.in/macaron.v1" "math/rand" "strings" "time" @@ -26,3 +28,17 @@ func HideUserName(name string) string { } return name } + +func ResMsg(c *macaron.Context, code int, msg string, desc ...string) { + rets := ruisUtil.NewMap() + rets.Set("msg", msg) + if len(desc) > 0 { + for i, v := range desc { + rets.Set(fmt.Sprintf("desc%d", i+1), v) + } + } + c.JSON(code, rets) +} +func ResMsgs(c *macaron.Context, code int, msg string) { + c.PlainText(code, []byte(msg)) +}