Browse Source

change xorm.io

tags/v1.0.8
liangzy 3 years ago
parent
commit
bbb15cd25b
4 changed files with 46 additions and 20 deletions
  1. +0
    -1
      go.mod
  2. +2
    -2
      mvc/controller.go
  3. +0
    -17
      response/json.go
  4. +44
    -0
      response/json/json.go

+ 0
- 1
go.mod View File

@@ -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
- 2
mvc/controller.go View File

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


+ 0
- 17
response/json.go 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
- 0
response/json/json.go 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,
}
}
}

Loading…
Cancel
Save