multitenantStack/controllers/base.go

31 lines
597 B
Go
Raw Normal View History

2018-11-07 10:10:51 +00:00
package controllers
import (
"github.com/astaxie/beego"
)
type JsonBasicResponse struct {
Status int
Message string
}
const JSON_ERROR int = 500
const JSON_SUCCESS int = 200
// BaseController operations for BaseController
type BaseController struct {
beego.Controller
}
func (this *BaseController) ServeJsonError(message string) {
json := JsonBasicResponse{JSON_ERROR, message}
this.Data["json"] = &json
this.ServeJSON()
}
func (this *BaseController) ServeJsonSuccess(message string) {
json := JsonBasicResponse{JSON_SUCCESS, message}
this.Data["json"] = &json
this.ServeJSON()
}