...
|
...
|
@@ -2,6 +2,7 @@ package comment |
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
...
|
...
|
@@ -80,14 +81,15 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI |
|
|
return err
|
|
|
}
|
|
|
// 减少上级评论的回复数量
|
|
|
if commentInfo.Pid != 0 {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// if commentInfo.Pid != 0 {
|
|
|
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
// }
|
|
|
// 减少最顶层的评论回复计数
|
|
|
if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
|
|
|
// if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
|
|
|
if commentInfo.TopId != 0 {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
|
|
|
if err != nil {
|
|
|
return err
|
...
|
...
|
@@ -95,15 +97,29 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI |
|
|
}
|
|
|
//减少加段落评论计数
|
|
|
if commentInfo.SectionId > 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
if commentInfo.TopId == 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 减少文章的评论数
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
if commentInfo.TopId == 0 {
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 评论被隐藏消息
|
...
|
...
|
@@ -142,14 +158,15 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId |
|
|
return err
|
|
|
}
|
|
|
// 增加上级评论的回复数量
|
|
|
if commetInfo.Pid != 0 {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// if commetInfo.Pid != 0 {
|
|
|
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
// }
|
|
|
// 增加最顶层的评论回复计数
|
|
|
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
|
|
|
// if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
|
|
|
if commetInfo.TopId != 0 {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId)
|
|
|
if err != nil {
|
|
|
return err
|
...
|
...
|
@@ -157,15 +174,29 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId |
|
|
}
|
|
|
//增加加段落评论计数
|
|
|
if commetInfo.SectionId > 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
if commetInfo.TopId == 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, commetInfo.CountReply+1, commetInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 增加文章的评论数
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
if commetInfo.TopId == 0 {
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, commetInfo.CountReply+1, commetInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}, true)
|
...
|
...
|
|