12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package function_api_controllers
-
- import (
- "XT_Admin_Api/controllers"
- "XT_Admin_Api/enums"
- "XT_Admin_Api/models/admin_models"
- )
-
- type FuntionBaseController struct {
- controllers.BaseAPIController
- }
-
- func (this *FuntionBaseController) ErrorLog(format string, a ...interface{}) {
- //beego.Error(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
- }
-
- func (this *FuntionBaseController) WarnLog(format string, a ...interface{}) {
- //beego.Warn(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
- }
-
- func (this *FuntionBaseController) InfoLog(format string, a ...interface{}) {
- //beego.Info(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
- }
-
- func (this *FuntionBaseController) DebugLog(format string, a ...interface{}) {
- //beego.Debug(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
- }
-
- func (this *FuntionBaseController) TraceLog(format string, a ...interface{}) {
- //beego.Trace(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
- }
-
- func (this *FuntionBaseController) GetAdminInfo() *AdminInfo {
- userInfo := this.GetSession("admin_info")
- if userInfo == nil {
- return nil
- } else {
- return userInfo.(*AdminInfo)
- }
- }
-
- type AdminInfo struct {
- Admin *admin_models.AdminAccount
- }
-
- type FunctionBaseAPIAuthController struct {
- FuntionBaseController
- }
-
- func (this *FunctionBaseAPIAuthController) Prepare() {
- this.FuntionBaseController.Prepare()
- adminInfo := this.GetAdminInfo()
- if adminInfo == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
- this.StopRun()
- }
- }
|