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

package client
import (
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
activity_service "hudongzhuanjia/services/activity"
auction_service "hudongzhuanjia/services/auction"
bahe_service "hudongzhuanjia/services/bahe"
bully_screen_service "hudongzhuanjia/services/bully_reward"
calorie_service "hudongzhuanjia/services/calorie"
red_envelope_service "hudongzhuanjia/services/red_envelope"
vote_service "hudongzhuanjia/services/vote"
"hudongzhuanjia/utils/code"
"hudongzhuanjia/utils/define"
)
type ActivityCtl struct {
controllers.AuthorCtl
}
func (t *ActivityCtl) ModuleStatus() {
activityId := t.MustGetInt64("activity_id")
moduleName := t.MustGet("module_name")
exist, err := activity_service.ExistModuleByActivityId(activityId, moduleName)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"status": exist,
})
}
// 某个模块的活动状态
func (t *ActivityCtl) ModuleCurrent() {
activityId := t.MustGetInt64("activity_id")
moduleName := t.MustGet("module_name")
uid := t.MustGetUID()
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
var data map[string]interface{}
switch moduleName {
case define.MODULE_TUGWAR: // 拔河
data, err = bahe_service.GetCurrentTugWar(activityId, uid, activity.RehearsalId)
case define.MODULE_CALORIE: // 卡路里
data, err = calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId)
case define.MODULE_SHAKRB: // 摇红包
// 没有初始状态 // 记下参与人数
data, err = red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId)
case define.MODULE_AUCTION:
// 竞拍
data, err = auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID())
case define.MODULE_VOTE:
data, err = vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId)
case define.MODULE_BULLYS:
data, err = bully_screen_service.GetCurrentBullyScreen(activityId)
default:
t.ERROR("不存在该模块", code.MSG_MODULE_NOT_EXIST)
}
t.CheckErr(err)
t.JSON(data)
}