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 }