@@ -8,7 +8,6 @@ require ( | |||||
github.com/astaxie/beego v1.12.2 | github.com/astaxie/beego v1.12.2 | ||||
github.com/go-check/check v0.0.0-20200227125254-8fa46927fb4f // indirect | github.com/go-check/check v0.0.0-20200227125254-8fa46927fb4f // indirect | ||||
github.com/go-sql-driver/mysql v1.5.0 | github.com/go-sql-driver/mysql v1.5.0 | ||||
github.com/lib/pq v1.0.0 | |||||
golib.gaore.com/GaoreGo/cast v1.3.2 | golib.gaore.com/GaoreGo/cast v1.3.2 | ||||
golib.gaore.com/GaoreGo/goes v1.2.2 // indirect | golib.gaore.com/GaoreGo/goes v1.2.2 // indirect | ||||
golib.gaore.com/GaoreGo/grconfig v1.1.0 | golib.gaore.com/GaoreGo/grconfig v1.1.0 | ||||
@@ -2,7 +2,7 @@ package mvc | |||||
import ( | import ( | ||||
"github.com/astaxie/beego" | "github.com/astaxie/beego" | ||||
"golib.gaore.com/GaoreGo/beegoinit/response" | |||||
"golib.gaore.com/GaoreGo/beegoinit/response/json" | |||||
"strings" | "strings" | ||||
) | ) | ||||
@@ -25,7 +25,7 @@ func (this *BaseController) Prepare() { | |||||
} | } | ||||
func (this *BaseController) RespJson(status bool, code int, msg string, data interface{}) { | func (this *BaseController) RespJson(status bool, code int, msg string, data interface{}) { | ||||
this.Data["json"] = &response.Json{ | |||||
this.Data["json"] = &json.Json{ | |||||
Code: code, | Code: code, | ||||
Data: data, | Data: data, | ||||
Msg: msg, | Msg: msg, | ||||
@@ -1,17 +0,0 @@ | |||||
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, | |||||
} | |||||
} |
@@ -0,0 +1,44 @@ | |||||
package json | |||||
type Json struct { | |||||
Code int `json:"code"` | |||||
Data interface{} `json:"data"` | |||||
Msg string `json:"msg"` | |||||
Status bool `json:"status"` | |||||
} | |||||
func GetDefaultJsonSuccessResponse() *Json { | |||||
return &Json{ | |||||
Code: 0, | |||||
Data: nil, | |||||
Msg: "ok", | |||||
Status: true, | |||||
} | |||||
} | |||||
func GetDefaultJsonFailedResponse() *Json { | |||||
return &Json{ | |||||
Code: 1, | |||||
Data: nil, | |||||
Msg: "unknow", | |||||
Status: false, | |||||
} | |||||
} | |||||
func New(status bool, code int, msg string, data ...interface{}) *Json { | |||||
if len(data) > 0 { | |||||
return &Json{ | |||||
Code: code, | |||||
Data: data[0], | |||||
Msg: msg, | |||||
Status: status, | |||||
} | |||||
} else { | |||||
return &Json{ | |||||
Code: code, | |||||
Data: nil, | |||||
Msg: msg, | |||||
Status: status, | |||||
} | |||||
} | |||||
} |