|
@@ -393,3 +393,101 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
resp.Paging = response.GetPaging(pageIndex, pageSize, int(total))
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// HandleLikeOrTeaseByRoadVideoItemList 路演视频 点赞/吐槽 数据
|
|
|
+func HandleLikeOrTeaseByRoadVideoItemList(userId uint64, videoList []*response.RoadVideoItem) (err error) {
|
|
|
+ listLen := len(videoList)
|
|
|
+ if listLen == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ idArr := make([]uint32, 0)
|
|
|
+ for i := 0; i < listLen; i++ {
|
|
|
+ idArr = append(idArr, uint32(videoList[i].RoadVideoID))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 注:此处视频社区CommunityVideoID在点赞吐槽表中为CommunityQuestionID, 以source区分主键
|
|
|
+
|
|
|
+ // 获取点赞和吐槽数据
|
|
|
+ ybCommunityQuestionLikeTeaseMap := make(map[uint32]*yb_community_question_like_tease.YbCommunityQuestionLikeTease)
|
|
|
+ ybCommunityQuestionLikeTeaseList, err := yb_community_question_like_tease.GetByUserIdAndCommunityQuestionIds(userId, idArr, yb_community_question_like_tease.SourceRoadVideo)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range ybCommunityQuestionLikeTeaseList {
|
|
|
+ ybCommunityQuestionLikeTeaseMap[v.CommunityQuestionID] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取点赞和吐槽汇总数
|
|
|
+ likeMap := make(map[uint32]int)
|
|
|
+ teaseMap := make(map[uint32]int)
|
|
|
+
|
|
|
+ likeList, err := yb_community_question_like_tease.GetLikeNumCommentByCommunityQuestionIds(idArr, yb_community_question_like_tease.SourceRoadVideo)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range likeList {
|
|
|
+ likeMap[v.CommunityQuestionID] = v.Total
|
|
|
+ }
|
|
|
+
|
|
|
+ teaseList, err := yb_community_question_like_tease.GetTeaseNumCommentByCommunityQuestionIds(idArr, yb_community_question_like_tease.SourceRoadVideo)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range teaseList {
|
|
|
+ teaseMap[v.CommunityQuestionID] = v.Total
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range videoList {
|
|
|
+ if tmpTotal, ok := likeMap[uint32(v.RoadVideoID)]; ok {
|
|
|
+ v.LikeTotal = tmpTotal
|
|
|
+ }
|
|
|
+ if tmpTotal, ok := teaseMap[uint32(v.RoadVideoID)]; ok {
|
|
|
+ v.TeaseTotal = tmpTotal
|
|
|
+ }
|
|
|
+
|
|
|
+ if ybCommunityQuestionLikeTease, ok := ybCommunityQuestionLikeTeaseMap[uint32(v.RoadVideoID)]; ok {
|
|
|
+ //类型. 1-点赞 2-吐槽
|
|
|
+ v.OpType = ybCommunityQuestionLikeTease.OpType
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// HandleCommentByRoadVideoItemList 路演视频 -论数据
|
|
|
+func HandleCommentByRoadVideoItemList(questionList []*response.RoadVideoItem) (err error) {
|
|
|
+ listLen := len(questionList)
|
|
|
+ if listLen == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ idArr := make([]uint32, 0)
|
|
|
+
|
|
|
+ // 注:此处视频社区RoadVideoID在评论表中为CommunityQuestionID, 以source区分主键
|
|
|
+
|
|
|
+ // 问题ID-精选评论列表
|
|
|
+ questionIdCommentsMap := make(map[uint32][]*response.CommunityQuestionCommentListItem, 0)
|
|
|
+
|
|
|
+ for i := 0; i < listLen; i++ {
|
|
|
+ idArr = append(idArr, uint32(questionList[i].RoadVideoID))
|
|
|
+ questionIdCommentsMap[uint32(questionList[i].RoadVideoID)] = make([]*response.CommunityQuestionCommentListItem, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 精选评论数据
|
|
|
+ hotList, err := yb_community_question_comment.GetHotListByCommunityQuestionIds(idArr, yb_community_question_comment.SourceRoadVideo)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range hotList {
|
|
|
+ questionIdCommentsMap[v.CommunityQuestionID] = append(questionIdCommentsMap[v.CommunityQuestionID], &response.CommunityQuestionCommentListItem{
|
|
|
+ QaAvatarUrl: v.QaAvatarUrl,
|
|
|
+ Comment: v.Content,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range questionList {
|
|
|
+ comments := questionIdCommentsMap[uint32(v.RoadVideoID)]
|
|
|
+ v.CommentTotal = len(comments)
|
|
|
+ v.CommentList = comments
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|