12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package controllers
-
- import (
- "Data_Upload_Api/enums"
- )
-
- type BaseAPIController struct {
- BaseController
- }
-
- // func (this *BaseAPIController) Prepare() {
- // this.BaseController.Prepare()
- // beego.Trace("============================================================")
- // beego.Trace("session ID: %v", this.Ctx.Input.Cookie("beegosessionID"))
- // beego.Trace("session : %v", this.GetSession("info"))
- // this.SetSession("info", time.Now().Format("2006/01/02 15:04:05"))
- // beego.Trace("============================================================")
- // }
-
- // 输出数据格式化
- /*
- success json:
- {
- "state": 1,
- "code": 0,
- "data": json,
- }
-
- fail json:
- {
- "state": 0,
- "code": int,
- "msg": string,
- }
- */
- func (this *BaseAPIController) ServeSuccessJSON(data map[string]interface{}) {
- this.Data["json"] = enums.MakeSuccessResponseJSON(data)
- this.ServeJSON()
- }
-
- func (this *BaseAPIController) ServeFailJSONWithSGJErrorCode(code int) {
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(code)
- this.ServeJSON()
- }
-
- func (this *BaseAPIController) ServeFailJSONWithSGJError(err *enums.SGJError) {
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJError(err)
- this.ServeJSON()
- }
-
- func (this *BaseAPIController) ServeFailJsonSend(code int, msg string) {
- this.Data["json"] = enums.MakeFailResponseJSON(msg, code)
- this.ServeJSON()
- }
-
- type BaseAuthAPIController struct {
- BaseAPIController
- }
-
- func (this *BaseAuthAPIController) Prepare() {
- this.BaseAPIController.Prepare()
-
- }
-
- type BaseServeAPIController struct {
- BaseAPIController
- }
-
- func (this *BaseServeAPIController) Prepare() {
- this.BaseAPIController.Prepare()
-
- }
|