package client import ( "hudongzhuanjia/controllers" "hudongzhuanjia/models" "hudongzhuanjia/utils/code" ) type LiveCtl struct { controllers.AuthorCtl //controllers.BaseCtl } // 详情 func (t *LiveCtl) Detail() { activityId := t.MustGetInt64("activity_id") //var userId int64 = 0 userId := t.MustGetUID() err := new(models.LiveViewer).Record(userId, activityId) t.CheckErr(err) live := new(models.LiveConfig) exist, err := live.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在") live.AdminLiveUrl = "" t.JSON(live) } func (t *LiveCtl) Like() { activityId := t.MustGetInt64("activity_id") //userId := t.MustGetUID() _, err := new(models.LiveConfig).Like(activityId) t.CheckErr(err) live := new(models.LiveConfig) exist, err := live.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在") t.JSON(map[string]interface{}{ "like": live.LikeNum, "watch": live.WatchNum, }) } func (t *LiveCtl) LoopQuery() { activityId := t.MustGetInt64("activity_id") live := new(models.LiveConfig) exist, err := live.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在") t.JSON(map[string]interface{}{ "like": live.LikeNum, "watch": live.WatchNum, }) }