Skip to content

Commit

Permalink
Merge pull request #28 from derekwin/master
Browse files Browse the repository at this point in the history
add tao's mission
  • Loading branch information
derekwin authored Feb 21, 2023
2 parents 713089f + b6929f4 commit 5b95b9c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kitex_server/videoservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func GetVideoLatestMap(idSet []int64, currentUser int64, respVideoMap chan map[i

// TODO: @weitao
// 批量查询视频的评论数,传入视频id的切片,返回对应的评论数(需携带对应视频id),从comment服务
// 在此处类似上边的写法,写评论数的实现

// 批量查询 is_favorite, 传入目标视频id切片和currentUser查is_favorite的切片(结果需要携带视频id,douyin里后续需要转成map):从favorite;
respIsFavoriteMap := make(chan map[int64]bool, 1)
Expand All @@ -86,15 +87,17 @@ func GetVideoLatestMap(idSet []int64, currentUser int64, respVideoMap chan map[i
errSlice = append(errSlice, err)
}

// @weitao 在此处类似上边的写法,把数据从你前面定义的数据chan里面拿到,把错误从对应的错误chan里面appen到errSlice里面

errChan <- errSlice // 记录错误的切片,至少应该返回一个空切片,否则chan会阻塞

// 更新数据
videoLatestMap := make(map[int64]core.Video, len(idSet)) // 视频切片的id是没有重复的
for _, id := range idSet {
videoLatestMap[id] = core.Video{ // 视频id对应的Video存储查到的关键字段
FavoriteCount: VideosFavoriteCountMap[id], // TODO:从拿到的MAP数据更新
CommentCount: 0, // TODO:从拿到的MAP数据更新
IsFavorite: IsFavoriteMap[id], // TODO:从拿到的MAP数据更新
FavoriteCount: VideosFavoriteCountMap[id], //
CommentCount: 0, // TODO: @weitao, 在此处从你返回的map里面读去对应id的评论数
IsFavorite: IsFavoriteMap[id], //
}
}
respVideoMap <- videoLatestMap // 返回数据
Expand Down

0 comments on commit 5b95b9c

Please sign in to comment.