From 198cf5dff73a15b53c88bbb4da2705ec7532e736 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Fri, 29 Dec 2023 14:33:19 +0800 Subject: [PATCH] fixed update tweet's comment essence status error --- internal/dao/jinzhu/comments.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/dao/jinzhu/comments.go b/internal/dao/jinzhu/comments.go index d4b2671c..c30fda69 100644 --- a/internal/dao/jinzhu/comments.go +++ b/internal/dao/jinzhu/comments.go @@ -148,7 +148,7 @@ func (s *commentSrv) GetCommentRepliesByID(ids []int64) ([]*ms.CommentReplyForma return repliesFormated, nil } -func (s *commentManageSrv) HighlightComment(userId, commentId int64) (res int8, err error) { +func (s *commentManageSrv) HighlightComment(userId, commentId int64) (isEssence int8, err error) { post := &dbr.Post{} comment := &dbr.Comment{} db := s.db.Model(comment) @@ -161,8 +161,12 @@ func (s *commentManageSrv) HighlightComment(userId, commentId int64) (res int8, if post.UserID != userId { return 0, cs.ErrNoPermission } - comment.IsEssence = 1 - comment.IsEssence - return comment.IsEssence, db.Save(comment).Error + isEssence = 1 - comment.IsEssence + err = s.db.Model(comment).UpdateColumns(map[string]any{ + "is_essence": isEssence, + "modified_on": time.Now().Unix(), + }).Where("id=?", commentId).Error + return } func (s *commentManageSrv) DeleteComment(comment *ms.Comment) (err error) {