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.
59 lines
1.3 KiB
59 lines
1.3 KiB
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,
|
|
})
|
|
}
|