Browse Source

change xorm.io

tags/v1.0.8
liangzy 3 years ago
parent
commit
11e3c96d66
2 changed files with 24 additions and 1 deletions
  1. +7
    -1
      mvc/controller.go
  2. +17
    -0
      response/json.go

+ 7
- 1
mvc/controller.go View File

@@ -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()
}



+ 17
- 0
response/json.go View File

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

Loading…
Cancel
Save