添加是否初次直播

master
kanade 5 years ago
parent e8242e440a
commit 05c8df1a1b

@ -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,

@ -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 {
// 计算超时时间

Loading…
Cancel
Save