change xorm.io
This commit is contained in:
parent
11e3c96d66
commit
bbb15cd25b
1
go.mod
1
go.mod
@ -8,7 +8,6 @@ require (
|
||||
github.com/astaxie/beego v1.12.2
|
||||
github.com/go-check/check v0.0.0-20200227125254-8fa46927fb4f // indirect
|
||||
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/goes v1.2.2 // indirect
|
||||
golib.gaore.com/GaoreGo/grconfig v1.1.0
|
||||
|
@ -2,7 +2,7 @@ package mvc
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"golib.gaore.com/GaoreGo/beegoinit/response"
|
||||
"golib.gaore.com/GaoreGo/beegoinit/response/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ func (this *BaseController) Prepare() {
|
||||
}
|
||||
|
||||
func (this *BaseController) RespJson(status bool, code int, msg string, data interface{}) {
|
||||
this.Data["json"] = &response.Json{
|
||||
this.Data["json"] = &json.Json{
|
||||
Code: code,
|
||||
Data: data,
|
||||
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,
|
||||
}
|
||||
}
|
44
response/json/json.go
Normal file
44
response/json/json.go
Normal file
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user