作者 tangxvhui

Revert "修正bug"

This reverts commit b944dfaa.
@@ -2,7 +2,6 @@ package comment @@ -2,7 +2,6 @@ package comment
2 2
3 import ( 3 import (
4 "context" 4 "context"
5 -  
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
@@ -45,32 +44,13 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini @@ -45,32 +44,13 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini
45 return resp, nil 44 return resp, nil
46 } 45 }
47 commentInfo.Show = domain.CommentShowDisable 46 commentInfo.Show = domain.CommentShowDisable
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 - } 47 +
62 // 变更回复数量 48 // 变更回复数量
63 err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { 49 err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
64 _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo) 50 _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo)
65 if err != nil { 51 if err != nil {
66 return err 52 return err
67 } 53 }
68 - for _, val := range childComment {  
69 - _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, val)  
70 - if err != nil {  
71 - return err  
72 - }  
73 - }  
74 // 减少上级评论的回复数量 54 // 减少上级评论的回复数量
75 if commentInfo.Pid != 0 { 55 if commentInfo.Pid != 0 {
76 err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) 56 err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
@@ -87,13 +67,13 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini @@ -87,13 +67,13 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini
87 } 67 }
88 //减少加段落评论计数 68 //减少加段落评论计数
89 if commentInfo.SectionId > 0 { 69 if commentInfo.SectionId > 0 {
90 - err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(len(childComment) + 1), commentInfo.SectionId) 70 + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
91 if err != nil { 71 if err != nil {
92 return err 72 return err
93 } 73 }
94 } 74 }
95 // 减少文章的评论数 75 // 减少文章的评论数
96 - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(len(childComment) + 1), commentInfo.ArticleId) 76 + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
97 if err != nil { 77 if err != nil {
98 return err 78 return err
99 } 79 }