...
|
...
|
@@ -152,11 +152,23 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini |
|
|
}
|
|
|
//保存数据
|
|
|
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
|
|
|
//保存评论
|
|
|
_, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
// 增加文章评论计数
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, articleInfo.Id)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//增加段落评论计数
|
|
|
if newComment.SectionId > 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, newComment.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
//增加评论回复计数
|
|
|
if pComment != nil {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id)
|
...
|
...
|
@@ -171,11 +183,6 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini |
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
//保存评论
|
|
|
_, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
return nil
|
|
|
}, true)
|
|
|
|
...
|
...
|
|