...
|
...
|
@@ -2,7 +2,6 @@ package comment |
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
|
...
|
...
|
@@ -29,61 +28,69 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo |
|
|
// 小程序端人人员删除评论
|
|
|
func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) {
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
|
|
|
commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
|
|
|
}
|
|
|
|
|
|
if commetInfo.FromUserId != req.UserId {
|
|
|
if commentInfo.FromUserId != req.UserId {
|
|
|
return nil, xerr.NewErrMsg("没有操作权限")
|
|
|
}
|
|
|
|
|
|
if commetInfo.Show == domain.CommentShowDisable {
|
|
|
if commentInfo.Show == domain.CommentShowDisable {
|
|
|
resp = &types.MiniDeleteArticleCommentResponse{
|
|
|
Id: commetInfo.Id,
|
|
|
Id: commentInfo.Id,
|
|
|
}
|
|
|
return resp, nil
|
|
|
}
|
|
|
commetInfo.Show = domain.CommentShowDisable
|
|
|
commentInfo.Show = domain.CommentShowDisable
|
|
|
|
|
|
// 变更回复数量
|
|
|
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
|
|
|
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
|
|
|
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
// 减少上级评论的回复数量
|
|
|
if commetInfo.Pid != 0 {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid)
|
|
|
if commentInfo.Pid != 0 {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// 减少最顶层的评论回复计数
|
|
|
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId)
|
|
|
if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
|
|
|
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
//减少加段落评论计数
|
|
|
if commetInfo.SectionId > 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId)
|
|
|
if commentInfo.SectionId > 0 {
|
|
|
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// 减少文章的评论数
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId)
|
|
|
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
//// 评论被隐藏消息
|
|
|
//var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx)
|
|
|
//err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content)
|
|
|
//if err != nil {
|
|
|
// return err
|
|
|
//}
|
|
|
|
|
|
return nil
|
|
|
}, true)
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
|
|
|
}
|
|
|
resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id}
|
|
|
resp = &types.MiniDeleteArticleCommentResponse{Id: commentInfo.Id}
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|