change xorm.io

This commit is contained in:
liangzy 2020-07-10 10:33:13 +08:00
parent 11e3c96d66
commit bbb15cd25b
4 changed files with 46 additions and 20 deletions

1
go.mod
View File

@ -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

View File

@ -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,

View File

@ -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
View 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,
}
}
}