From 11e3c96d6607b120b47ffe5a94eecc9fd352fa46 Mon Sep 17 00:00:00 2001 From: liangzy Date: Thu, 9 Jul 2020 15:01:25 +0800 Subject: [PATCH] change xorm.io --- mvc/controller.go | 8 +++++++- response/json.go | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 response/json.go diff --git a/mvc/controller.go b/mvc/controller.go index 7cc7a58..58634d5 100644 --- a/mvc/controller.go +++ b/mvc/controller.go @@ -2,6 +2,7 @@ package mvc import ( "github.com/astaxie/beego" + "golib.gaore.com/GaoreGo/beegoinit/response" "strings" ) @@ -24,7 +25,12 @@ func (this *BaseController) Prepare() { } func (this *BaseController) RespJson(status bool, code int, msg string, data interface{}) { - this.Data["json"] = &map[string]interface{}{"status": status, "code": code, "msg": msg, "data": data} + this.Data["json"] = &response.Json{ + Code: code, + Data: data, + Msg: msg, + Status: status, + } this.ServeJSON() } diff --git a/response/json.go b/response/json.go new file mode 100644 index 0000000..8df495e --- /dev/null +++ b/response/json.go @@ -0,0 +1,17 @@ +package response + +type Json struct { + Code int `json:"code"` + Data interface{} `json:"data"` + Msg string `json:"msg"` + Status bool `json:"status"` +} + +func GetDefaultJsonResponse() *Json { + return &Json{ + Code: 0, + Data: nil, + Msg: "ok", + Status: true, + } +}