正在显示
1 个修改的文件
包含
23 行增加
和
3 行删除
| @@ -2,6 +2,7 @@ package comment | @@ -2,6 +2,7 @@ package comment | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| @@ -44,13 +45,32 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | @@ -44,13 +45,32 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | ||
| 44 | return resp, nil | 45 | return resp, nil |
| 45 | } | 46 | } |
| 46 | commentInfo.Show = domain.CommentShowDisable | 47 | commentInfo.Show = domain.CommentShowDisable |
| 47 | - | 48 | + var childComment []*domain.ArticleComment |
| 49 | + if commentInfo.Pid == 0 { | ||
| 50 | + _, childComment, err = l.svcCtx.ArticleCommentRepository.Find( | ||
| 51 | + l.ctx, | ||
| 52 | + conn, | ||
| 53 | + domain.NewQueryOptions().WithFindOnly().MustWithKV("topId", commentInfo.Id), | ||
| 54 | + ) | ||
| 55 | + if err != nil { | ||
| 56 | + return nil, xerr.NewErrMsgErr("删除评论信息失败", err) | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + for _, val := range childComment { | ||
| 60 | + val.Show = domain.CommentShowDisable | ||
| 61 | + } | ||
| 48 | // 变更回复数量 | 62 | // 变更回复数量 |
| 49 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 63 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 50 | _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo) | 64 | _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo) |
| 51 | if err != nil { | 65 | if err != nil { |
| 52 | return err | 66 | return err |
| 53 | } | 67 | } |
| 68 | + for _, val := range childComment { | ||
| 69 | + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, val) | ||
| 70 | + if err != nil { | ||
| 71 | + return err | ||
| 72 | + } | ||
| 73 | + } | ||
| 54 | // 减少上级评论的回复数量 | 74 | // 减少上级评论的回复数量 |
| 55 | if commentInfo.Pid != 0 { | 75 | if commentInfo.Pid != 0 { |
| 56 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | 76 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) |
| @@ -67,13 +87,13 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | @@ -67,13 +87,13 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | ||
| 67 | } | 87 | } |
| 68 | //减少加段落评论计数 | 88 | //减少加段落评论计数 |
| 69 | if commentInfo.SectionId > 0 { | 89 | if commentInfo.SectionId > 0 { |
| 70 | - err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) | 90 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(len(childComment) + 1), commentInfo.SectionId) |
| 71 | if err != nil { | 91 | if err != nil { |
| 72 | return err | 92 | return err |
| 73 | } | 93 | } |
| 74 | } | 94 | } |
| 75 | // 减少文章的评论数 | 95 | // 减少文章的评论数 |
| 76 | - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) | 96 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(len(childComment) + 1), commentInfo.ArticleId) |
| 77 | if err != nil { | 97 | if err != nil { |
| 78 | return err | 98 | return err |
| 79 | } | 99 | } |
-
mentioned in commit 2391423a
-
请 注册 或 登录 后发表评论