31 lines
597 B
Go
31 lines
597 B
Go
|
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()
|
||
|
}
|