From 05c8df1a1b576165edf3c66d9cd98c3b723eb9fb Mon Sep 17 00:00:00 2001 From: kanade <3136520963@qq.com> Date: Thu, 22 Oct 2020 18:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=88=9D?= =?UTF-8?q?=E6=AC=A1=E7=9B=B4=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/live/live.go | 14 +++++++++++--- app/lib/tencent/live.go | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controller/live/live.go b/app/controller/live/live.go index f9b5150..938da51 100644 --- a/app/controller/live/live.go +++ b/app/controller/live/live.go @@ -101,13 +101,21 @@ type liveInfo struct { GoodsLists []GoodsItem `json:"goodsLists"` Title string `json:"title"` Topic uint `json:"topic"` + IsFirst int `json:"isFirst"` } func (l *Live) Info(c *gin.Context) { userId := common.GetUserId(c) + liveRoom := (&live2.LiveRoom{}).GetLiveByUserId(userId) + isFirst := 1 + if liveRoom.Id > 0 { + isFirst = 0 + } liveItem := (&live2.LiveItem{}).GetLiveItemIng(userId) if liveItem.Id <= 0 { - back.Suc(c, "", liveInfo{}) + back.Suc(c, "", liveInfo{ + IsFirst: isFirst, + }) return } users, err := recook.User.GetUsers([]uint{liveItem.UserId}) @@ -116,7 +124,6 @@ func (l *Live) Info(c *gin.Context) { return } liveData := (&live2.LiveData{}).GetByLiveItemId(liveItem.Id) - liveRoom := (&live2.LiveRoom{}).GetLiveByUserId(liveItem.UserId) itemGoods := (&live2.LiveGoods{}).GetGoodsByLiveItemId(liveItem.Id) goodsIds := []uint{} @@ -153,6 +160,7 @@ func (l *Live) Info(c *gin.Context) { GoodsLists: goodsList, Topic: liveItem.Topic, Title: topicInfo.Title, + IsFirst: isFirst, } back.Suc(c, "操作成功", reply) } @@ -341,7 +349,7 @@ func (l *Live) LiveInfo(c *gin.Context) { reply := replyLiveInfo{ Nickname: (*users)[0].Nickname, HeadImgUrl: (*users)[0].HeadImgUrl, - PlayUrl: tencent.Live.GetPlayUrl(liveRoom.StreamName), + PlayUrl: tencent.Live.GetPlayUrl(liveRoom.StreamName, liveItem.Id), GroupId: liveRoom.GroupId, UserId: liveItem.UserId, Id: liveItem.Id, diff --git a/app/lib/tencent/live.go b/app/lib/tencent/live.go index 8fdea14..7419fa9 100644 --- a/app/lib/tencent/live.go +++ b/app/lib/tencent/live.go @@ -53,6 +53,7 @@ func init() { // @Title 获取推流url func (l *live) GetPushUrl(streamName string, liveItemId uint) string { + streamName = fmt.Sprintf("%s_%v", streamName, liveItemId) query := "" if l.pushExpire > 0 { // 计算超时时间 @@ -72,7 +73,8 @@ func (l *live) GetPushUrl(streamName string, liveItemId uint) string { } // @Title 获取播放url -func (l *live) GetPlayUrl(streamName string) string { +func (l *live) GetPlayUrl(streamName string, liveItemId uint) string { + streamName = fmt.Sprintf("%s_%v", streamName, liveItemId) query := "" if l.playExpire > 0 { // 计算超时时间