mobile_api_base_controller.go 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package mobile_api_controllers
  2. import (
  3. "XT_New/controllers"
  4. "XT_New/enums"
  5. "XT_New/models"
  6. "fmt"
  7. )
  8. type MobileBaseAPIController struct {
  9. controllers.BaseAPIController
  10. }
  11. func (this *MobileBaseAPIController) Prepare() {
  12. this.BaseAPIController.Prepare()
  13. // beego.Trace("============================================================")
  14. // beego.Trace("session ID: %v", this.Ctx.Input.Cookie("beegosessionID"))
  15. // beego.Trace("session : %v", this.GetSession("info"))
  16. // this.SetSession("info", time.Now().Format("2006/01/02 15:04:05"))
  17. // beego.Trace("============================================================")
  18. }
  19. func (this *MobileBaseAPIController) GetMobileAdminUserInfo() *MobileAdminUserInfo {
  20. userInfo := this.GetSession("mobile_admin_user_info")
  21. if userInfo == nil {
  22. return nil
  23. } else {
  24. return userInfo.(*MobileAdminUserInfo)
  25. }
  26. }
  27. type MobileAdminUserInfo struct {
  28. AdminUser *models.AdminUser
  29. Org *models.Org
  30. App *models.OrgApp
  31. AppRole *models.App_Role
  32. Subscibe *models.ServeSubscibe
  33. TemplateInfo *models.GobalTemplate
  34. }
  35. type MobileBaseAPIAuthController struct {
  36. MobileBaseAPIController
  37. }
  38. func (this *MobileBaseAPIAuthController) Prepare() {
  39. this.MobileBaseAPIController.Prepare()
  40. adminUserInfo := this.GetMobileAdminUserInfo()
  41. fmt.Println(adminUserInfo)
  42. if adminUserInfo == nil {
  43. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
  44. this.StopRun()
  45. }
  46. //if this.Ctx.Request.Method != "GET" {
  47. // err := service.GetOrgSubscibeState(adminUserInfo.Subscibe)
  48. // if err != nil || adminUserInfo.Subscibe.State == 3 {
  49. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
  50. // this.StopRun()
  51. // }
  52. //}
  53. }