Roc 2 years ago
parent
commit
2d0a296c6d

+ 5 - 0
controller/community/comment.go

@@ -19,6 +19,11 @@ func Comment(c *gin.Context) {
 		return
 	}
 	userInfo := userService.GetInfoByClaims(c)
+
+	req.IsShowName = 0
+	if userInfo.NickName != `` { //非空串时为实名
+		req.IsShowName = 1
+	}
 	ybCommunityQuestionComment, err, errMsg := yb_community_question.Comment(userInfo, req.CommunityQuestionID, req.Content, req.SourceAgent, req.IsShowName)
 	if err != nil {
 		response.FailMsg(errMsg, err.Error(), c)

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

@@ -105,7 +105,7 @@ func GetNumCommentByCommunityQuestionIds(communityQuestionIds []uint32) (item []
 // GetLastHotListByCommunityQuestionIds 根据问答id列表获取最近精选的留言
 func GetLastHotListByCommunityQuestionIds(communityQuestionIds []uint32) (items []*YbCommunityQuestionComment, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
-		Where("community_question_comment_id in (SELECT MAX(community_question_comment_id) AS community_question_comment_id FROM yb_community_question_comment WHERE community_question_id IN (?) AND enabled = 1 AND is_hot = 1 AND type = 1)", communityQuestionIds).Group("community_question_id").
+		Where("community_question_comment_id in (SELECT MAX(community_question_comment_id) AS community_question_comment_id FROM yb_community_question_comment WHERE community_question_id IN (?) AND enabled = 1 AND is_hot = 1 AND type = 1 GROUP BY community_question_id)", communityQuestionIds).
 		Find(&items).Error
 	return
 }
@@ -113,7 +113,7 @@ func GetLastHotListByCommunityQuestionIds(communityQuestionIds []uint32) (items
 // GetLastMyListByCommunityQuestionIds 根据问答id列表获取我最近的留言
 func GetLastMyListByCommunityQuestionIds(userId uint64, communityQuestionIds []uint32) (items []*YbCommunityQuestionComment, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
-		Where("community_question_comment_id in (SELECT MAX(community_question_comment_id) AS community_question_comment_id FROM yb_community_question_comment WHERE user_id=? AND community_question_id IN (?) AND enabled = 1 AND type = 1)", userId, communityQuestionIds).Group("community_question_id").
+		Where("community_question_comment_id in (SELECT MAX(community_question_comment_id) AS community_question_comment_id FROM yb_community_question_comment WHERE user_id=? AND community_question_id IN (?) AND enabled = 1 AND type = 1 GROUP BY community_question_id)", userId, communityQuestionIds).
 		Find(&items).Error
 	return
 }