diff --git a/controllers/client/live.go b/controllers/client/live.go index 05b2984..2ad6249 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -81,19 +81,11 @@ type LiveCtl struct { func (t *LiveCtl) Detail() { activityId := t.MustGetInt64("activity_id") areaId := t.MustGetInt64("area_id") - userId := t.MustGetUID() live := new(models.LiveConfig) exist, err := live.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_LIVE_CONFIG_NOT_EXIST, "直播活动不存在") - if live.WatchNum+1 >= live.Limit { - t.ERROR("直播人数已满", code.MSG_LIVE_LIMIT_ENOUGH) - return - } - - err = new(models.LiveViewer).Record(userId, activityId, live.Id) - t.CheckErr(err) fs := make(map[string]int, 0) fs["is_shake"] = 0 diff --git a/controllers/client/sign.go b/controllers/client/sign.go index a393aaa..0d7b87b 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -19,23 +19,36 @@ type SignCtl struct { func (t *SignCtl) CheckSign() { activityId := t.MustGetInt64("activity_id") uid := t.MustGetUID() + _type := t.MustGetInt("type") - live := new(models.LiveConfig) - exist, err := live.GetByActivityId(activityId) - t.CheckErr(err) - t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在") - if live.AdaptationFunc != nil && len(live.AdaptationFunc) != 0 { - exist, err = new(models.ModuleServiceHistory).ExistSignModule(live.AdaptationFunc) + if _type == 1 { + live := new(models.LiveConfig) + exist, err := live.GetByActivityId(activityId) t.CheckErr(err) - if !exist { - t.JSON(!exist) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在") + if live.LiveMode == 2 { + if live.WatchNum+1 >= live.Limit { + t.ERROR("直播人数已满", code.MSG_LIVE_LIMIT_ENOUGH) + return + } } - } else { - t.JSON(true) + + err = new(models.LiveViewer).Record(uid, activityId, live.Id) + t.CheckErr(err) + if live.AdaptationFunc != nil && len(live.AdaptationFunc) != 0 { + exist, err = new(models.ModuleServiceHistory).ExistSignModule(live.AdaptationFunc) + t.CheckErr(err) + if !exist { + t.JSON(true) + } + } else { + t.JSON(true) + } + } activity := models.Activity{} - exist, err = models.Get(&activity, activityId) + exist, err := models.Get(&activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "主活动不存在")