Parcourir la source

fix:列表数据调整

Roc il y a 2 ans
Parent
commit
0da53ee3e5

+ 3 - 2
logic/yb_community_question/yb_community_question_comment.go

@@ -336,13 +336,14 @@ func HandleCommentByCommunityQuestionItemList(userId uint64, questionList []*res
 		userIds = append(userIds, v.UserID)
 	}
 
+	//需要查询的我的问答的评论
 	myIdArr := make([]uint32, 0)
 	for id := range idMap {
 		myIdArr = append(myIdArr, id)
 	}
 
 	//获取我的评论数据
-	myList, err := yb_community_question_comment.GetLastMyListByCommunityQuestionIds(userId, idArr)
+	myList, err := yb_community_question_comment.GetLastMyListByCommunityQuestionIds(userId, myIdArr)
 	if err != nil {
 		return
 	}
@@ -352,7 +353,7 @@ func HandleCommentByCommunityQuestionItemList(userId uint64, questionList []*res
 
 	// 获取留言汇总数
 	numCommentMap := make(map[uint32]int)
-	numCommentList, err := yb_community_question_comment.GetNumCommentByCommunityQuestionIds(idArr)
+	numCommentList, err := yb_community_question_comment.GetNumCommentByCommunityQuestionIds(idArr, userId)
 	if err != nil {
 		return
 	}

+ 3 - 3
models/tables/yb_community_question_comment/query.go

@@ -94,11 +94,11 @@ type NumCommentByCommunityQuestion struct {
 	Total               int    `json:"total"`
 }
 
-// GetNumCommentByCommunityQuestionIds 获取用户最新的留言
-func GetNumCommentByCommunityQuestionIds(communityQuestionIds []uint32) (item []*NumCommentByCommunityQuestion, err error) {
+// GetNumCommentByCommunityQuestionIds 获取用户留言的汇总数
+func GetNumCommentByCommunityQuestionIds(communityQuestionIds []uint32, userId uint64) (item []*NumCommentByCommunityQuestion, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
 		Select("community_question_id, count(1) total").
-		Where("community_question_id in (?) and type=1 and enabled = 1 ", communityQuestionIds).Group("community_question_id").Scan(&item).Error
+		Where("community_question_id in (?) and type=1 and enabled = 1 and (is_hot = 1 or user_id=?) ", communityQuestionIds, userId).Group("community_question_id").Scan(&item).Error
 	return
 }