互动
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.

63 lines
2.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
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_reward"
  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.MustGetInt64("activity_id")
  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.MustGetInt64("activity_id")
  30. moduleName := t.MustGet("module_name")
  31. uid := t.MustGetUID()
  32. activity := new(models.Activity)
  33. exist, err := models.Get(activity, activityId)
  34. t.CheckErr(err)
  35. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  36. var data map[string]interface{}
  37. switch moduleName {
  38. case define.MODULE_TUGWAR: // 拔河
  39. data, err = bahe_service.GetCurrentTugWar(activityId, uid, activity.RehearsalId)
  40. case define.MODULE_CALORIE: // 卡路里
  41. data, err = calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId)
  42. case define.MODULE_SHAKRB: // 摇红包
  43. // 没有初始状态 // 记下参与人数
  44. data, err = red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId)
  45. case define.MODULE_AUCTION:
  46. // 竞拍
  47. data, err = auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID())
  48. case define.MODULE_VOTE:
  49. data, err = vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId)
  50. case define.MODULE_BULLYS:
  51. data, err = bully_screen_service.GetCurrentBullyScreen(activityId)
  52. default:
  53. t.ERROR("不存在该模块", code.MSG_MODULE_NOT_EXIST)
  54. }
  55. t.CheckErr(err)
  56. t.JSON(data)
  57. }