From 36bff958346e076ba9578bba23a692a37dd16f1c Mon Sep 17 00:00:00 2001 From: 1005281342 <1005281342@qq.com> Date: Tue, 31 May 2022 22:54:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A2=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=99=A8atUserID=E5=B1=9E=E6=80=A7=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/comment.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/service/comment.go b/internal/service/comment.go index 7986212d..2b0a2dcc 100644 --- a/internal/service/comment.go +++ b/internal/service/comment.go @@ -186,21 +186,22 @@ func (svc *Service) DeletePostComment(comment *model.Comment) error { return svc.dao.DeleteComment(comment) } -func (svc *Service) createPostPreHandler(commentID int64, userID, atUserID int64) (*model.Post, *model.Comment, error) { +func (svc *Service) createPostPreHandler(commentID int64, userID, atUserID int64) (*model.Post, *model.Comment, int64, + error) { // 加载Comment comment, err := svc.dao.GetCommentByID(commentID) if err != nil { - return nil, nil, err + return nil, nil, atUserID, err } // 加载comment的post post, err := svc.dao.GetPostByID(comment.PostID) if err != nil { - return nil, nil, err + return nil, nil, atUserID, err } if post.CommentCount >= global.AppSetting.MaxCommentCount { - return nil, nil, errcode.MaxCommentCount + return nil, nil, atUserID, errcode.MaxCommentCount } if userID == atUserID { @@ -215,12 +216,16 @@ func (svc *Service) createPostPreHandler(commentID int64, userID, atUserID int64 } } - return post, comment, nil + return post, comment, atUserID, nil } func (svc *Service) CreatePostCommentReply(commentID int64, content string, userID, atUserID int64) (*model.CommentReply, error) { - var post, comment, err = svc.createPostPreHandler(commentID, userID, atUserID) - if err != nil { + var ( + post *model.Post + comment *model.Comment + err error + ) + if post, comment, atUserID, err = svc.createPostPreHandler(commentID, userID, atUserID); err != nil { return nil, err }