From 05f44031d83e6af7716ccd922285fcf276613bcd Mon Sep 17 00:00:00 2001 From: Michael Li Date: Sat, 23 Sep 2023 14:36:56 +0800 Subject: [PATCH] fixed get hots tweet comments result not correct --- internal/dao/jinzhu/comments.go | 20 +++++--------------- internal/dao/jinzhu/jinzhu.go | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/internal/dao/jinzhu/comments.go b/internal/dao/jinzhu/comments.go index 93baa2d9..d4b2671c 100644 --- a/internal/dao/jinzhu/comments.go +++ b/internal/dao/jinzhu/comments.go @@ -26,8 +26,7 @@ type commentSrv struct { } type commentManageSrv struct { - db *gorm.DB - cms core.CommentMetricServantA + db *gorm.DB } func newCommentService(db *gorm.DB) core.CommentService { @@ -36,10 +35,9 @@ func newCommentService(db *gorm.DB) core.CommentService { } } -func newCommentManageService(db *gorm.DB, cms core.CommentMetricServantA) core.CommentManageService { +func newCommentManageService(db *gorm.DB) core.CommentManageService { return &commentManageSrv{ - db: db, - cms: cms, + db: db, } } @@ -181,19 +179,11 @@ func (s *commentManageSrv) DeleteComment(comment *ms.Comment) (err error) { return } db.Commit() - if err == nil { - // 对错误宽松处理,暂时就不处理 - s.cms.DeleteCommentMetric(comment.ID) - } return } -func (s *commentManageSrv) CreateComment(comment *ms.Comment) (res *ms.Comment, err error) { - if res, err = comment.Create(s.db); err == nil { - // 对错误宽松处理,暂时就不处理 - s.cms.AddCommentMetric(res.ID) - } - return +func (s *commentManageSrv) CreateComment(comment *ms.Comment) (*ms.Comment, error) { + return comment.Create(s.db) } func (s *commentManageSrv) CreateCommentReply(reply *ms.CommentReply) (res *ms.CommentReply, err error) { diff --git a/internal/dao/jinzhu/jinzhu.go b/internal/dao/jinzhu/jinzhu.go index 2a76456b..abd7f593 100644 --- a/internal/dao/jinzhu/jinzhu.go +++ b/internal/dao/jinzhu/jinzhu.go @@ -71,7 +71,7 @@ func NewDataService() (core.DataService, core.VersionInfo) { TweetManageService: newTweetManageService(db, cis), TweetHelpService: newTweetHelpService(db), CommentService: newCommentService(db), - CommentManageService: newCommentManageService(db, cms), + CommentManageService: newCommentManageService(db), UserManageService: newUserManageService(db), ContactManageService: newContactManageService(db), FollowingManageService: newFollowingManageService(db),