From 988b358365986ee3f67d37c6347f754b872a0763 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Wed, 10 Jun 2020 14:18:22 +0800 Subject: [PATCH] fix:bug --- controllers/client/live.go | 8 -------- controllers/client/sign.go | 35 ++++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 19 deletions(-) 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, "主活动不存在")