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