Documentation ¶
Index ¶
- Variables
- type ApiResp
- type BaseController
- func (this *BaseController) AutoServeError(err error)
- func (this *BaseController) BasicRespGen() (apiResp *ApiResp)
- func (this *BaseController) MustGetBool(key string, def bool) bool
- func (this *BaseController) MustGetInt(key string, def int) int
- func (this *BaseController) MustGetInt64(key string, def int64) int64
- func (this *BaseController) MustGetString(key string, def string) string
- func (this *BaseController) NotFound(body string)
- func (this *BaseController) ResposeError(apiBasicParams *ApiResp, msg string)
- func (this *BaseController) ServeApiJson(msg *ApiResp)
- func (this *BaseController) ServeDataJson(data interface{})
- func (this *BaseController) ServeErrJson(msg string)
- func (this *BaseController) ServeOKJson()
- func (this *BaseController) SessionCheck() (session *uic.Session, err error)
- func (this *BaseController) SessionExpired()
- func (this *BaseController) SetPaginator(per int, nums int64) *web.Paginator
Constants ¶
This section is empty.
Variables ¶
View Source
var FilterLoginUser = func(ctx *context.Context) { cookieSig := ctx.GetCookie("sig") if cookieSig == "" { ctx.Redirect(302, "/auth/login?callback="+ctx.Request.URL.String()) return } sessionObj := uic.ReadSessionBySig(cookieSig) if sessionObj == nil || int64(sessionObj.Expired) < time.Now().Unix() { ctx.Redirect(302, "/auth/login?callback="+ctx.Request.URL.String()) return } u := uic.ReadUserById(sessionObj.Uid) if u == nil { ctx.Redirect(302, "/auth/login?callback="+ctx.Request.URL.String()) return } ctx.Input.SetData("CurrentUser", u) }
View Source
var FilterTargetTeam = func(ctx *context.Context) { tid := ctx.Input.Query("id") if tid == "" { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("id is necessary")) return } id, err := strconv.ParseInt(tid, 10, 64) if err != nil { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("id is invalid")) return } t := uic.ReadTeamById(id) if t == nil { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("no such team")) return } ctx.Input.SetData("TargetTeam", t) }
View Source
var FilterTargetUser = func(ctx *context.Context) { userId := ctx.Input.Query("id") if userId == "" { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("id is necessary")) return } id, err := strconv.ParseInt(userId, 10, 64) if err != nil { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("id is invalid")) return } u := uic.ReadUserById(id) if u == nil { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("no such user")) return } ctx.Input.SetData("TargetUser", u) }
Functions ¶
This section is empty.
Types ¶
type BaseController ¶
type BaseController struct {
beego.Controller
}
func (*BaseController) AutoServeError ¶
func (this *BaseController) AutoServeError(err error)
func (*BaseController) BasicRespGen ¶
func (this *BaseController) BasicRespGen() (apiResp *ApiResp)
func (*BaseController) MustGetBool ¶
func (this *BaseController) MustGetBool(key string, def bool) bool
func (*BaseController) MustGetInt ¶
func (this *BaseController) MustGetInt(key string, def int) int
func (*BaseController) MustGetInt64 ¶
func (this *BaseController) MustGetInt64(key string, def int64) int64
func (*BaseController) MustGetString ¶
func (this *BaseController) MustGetString(key string, def string) string
func (*BaseController) NotFound ¶
func (this *BaseController) NotFound(body string)
func (*BaseController) ResposeError ¶
func (this *BaseController) ResposeError(apiBasicParams *ApiResp, msg string)
func (*BaseController) ServeApiJson ¶
func (this *BaseController) ServeApiJson(msg *ApiResp)
func (*BaseController) ServeDataJson ¶
func (this *BaseController) ServeDataJson(data interface{})
func (*BaseController) ServeErrJson ¶
func (this *BaseController) ServeErrJson(msg string)
func (*BaseController) ServeOKJson ¶
func (this *BaseController) ServeOKJson()
func (*BaseController) SessionCheck ¶
func (this *BaseController) SessionCheck() (session *uic.Session, err error)
func (*BaseController) SessionExpired ¶
func (this *BaseController) SessionExpired()
func (*BaseController) SetPaginator ¶
func (this *BaseController) SetPaginator(per int, nums int64) *web.Paginator
Click to show internal directories.
Click to hide internal directories.