互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

5 years ago
  1. package client
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/models"
  5. activity_service "hudongzhuanjia/services/activity"
  6. auction_service "hudongzhuanjia/services/auction"
  7. bahe_service "hudongzhuanjia/services/bahe"
  8. bully_screen_service "hudongzhuanjia/services/bully_screen"
  9. calorie_service "hudongzhuanjia/services/calorie"
  10. red_envelope_service "hudongzhuanjia/services/red_envelope"
  11. vote_service "hudongzhuanjia/services/vote"
  12. "hudongzhuanjia/utils/code"
  13. "hudongzhuanjia/utils/define"
  14. )
  15. type ActivityCtl struct {
  16. controllers.AuthorCtl
  17. }
  18. func (t *ActivityCtl) ModuleStatus() {
  19. activityId := t.MustGetActivityId()
  20. moduleName := t.MustGet("module_name")
  21. exist, err := activity_service.ExistModuleByActivityId(activityId, moduleName)
  22. t.CheckErr(err)
  23. t.JSON(map[string]interface{}{
  24. "status": exist,
  25. })
  26. }
  27. // 某个模块的活动状态
  28. func (t *ActivityCtl) ModuleCurrent() {
  29. activityId := t.MustGetActivityId()
  30. moduleName := t.MustGet("module_name")
  31. uid := t.MustGetUID()
  32. activity := new(models.Activity)
  33. exist, err := models.GetById(activity, activityId)
  34. t.CheckErr(err)
  35. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  36. switch moduleName {
  37. case define.MODULE_TUGWAR: // 拔河
  38. data, err := bahe_service.GetCurrentTugWar(activityId, uid, activity.RehearsalId)
  39. t.CheckErr(err)
  40. t.JSON(data)
  41. case define.MODULE_CALORIE: // 卡路里
  42. data, err := calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId)
  43. t.CheckErr(err)
  44. t.JSON(data)
  45. case define.MODULE_SHAKRB: // 摇红包
  46. // 没有初始状态 // 记下参与人数
  47. data, err := red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId)
  48. t.CheckErr(err)
  49. t.JSON(data)
  50. case define.MODULE_AUCTION:
  51. // 竞拍
  52. data, err := auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID())
  53. t.CheckErr(err)
  54. t.JSON(data)
  55. case define.MODULE_VOTE:
  56. data, err := vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId)
  57. t.CheckErr(err)
  58. t.JSON(data)
  59. case define.MODULE_BULLYS:
  60. data, err := bully_screen_service.GetCurrentBullyScreen(activityId)
  61. t.CheckErr(err)
  62. t.JSON(data)
  63. default:
  64. t.ERROR("不存在该模块", code.MSG_MODULE_NOT_EXIST)
  65. }
  66. }