作者 郑周

1 系统消息,增加评论被隐藏的通知

@@ -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"
@@ -29,61 +28,69 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo @@ -29,61 +28,69 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo
29 // 小程序端人人员删除评论 28 // 小程序端人人员删除评论
30 func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) { 29 func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) {
31 var conn = l.svcCtx.DefaultDBConn() 30 var conn = l.svcCtx.DefaultDBConn()
32 - commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId) 31 + commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
33 if err != nil { 32 if err != nil {
34 return nil, xerr.NewErrMsgErr("删除评论信息失败", err) 33 return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
35 } 34 }
36 35
37 - if commetInfo.FromUserId != req.UserId { 36 + if commentInfo.FromUserId != req.UserId {
38 return nil, xerr.NewErrMsg("没有操作权限") 37 return nil, xerr.NewErrMsg("没有操作权限")
39 } 38 }
40 39
41 - if commetInfo.Show == domain.CommentShowDisable { 40 + if commentInfo.Show == domain.CommentShowDisable {
42 resp = &types.MiniDeleteArticleCommentResponse{ 41 resp = &types.MiniDeleteArticleCommentResponse{
43 - Id: commetInfo.Id, 42 + Id: commentInfo.Id,
44 } 43 }
45 return resp, nil 44 return resp, nil
46 } 45 }
47 - commetInfo.Show = domain.CommentShowDisable 46 + commentInfo.Show = domain.CommentShowDisable
48 47
49 // 变更回复数量 48 // 变更回复数量
50 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 {
51 - _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) 50 + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo)
52 if err != nil { 51 if err != nil {
53 return err 52 return err
54 } 53 }
55 // 减少上级评论的回复数量 54 // 减少上级评论的回复数量
56 - if commetInfo.Pid != 0 {  
57 - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid) 55 + if commentInfo.Pid != 0 {
  56 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
58 if err != nil { 57 if err != nil {
59 return err 58 return err
60 } 59 }
61 } 60 }
62 // 减少最顶层的评论回复计数 61 // 减少最顶层的评论回复计数
63 - if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {  
64 - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId) 62 + if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
  63 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
65 if err != nil { 64 if err != nil {
66 return err 65 return err
67 } 66 }
68 } 67 }
69 //减少加段落评论计数 68 //减少加段落评论计数
70 - if commetInfo.SectionId > 0 {  
71 - err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId) 69 + if commentInfo.SectionId > 0 {
  70 + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
72 if err != nil { 71 if err != nil {
73 return err 72 return err
74 } 73 }
75 } 74 }
76 // 减少文章的评论数 75 // 减少文章的评论数
77 - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId) 76 + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
78 if err != nil { 77 if err != nil {
79 return err 78 return err
80 } 79 }
  80 +
  81 + //// 评论被隐藏消息
  82 + //var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx)
  83 + //err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content)
  84 + //if err != nil {
  85 + // return err
  86 + //}
  87 +
81 return nil 88 return nil
82 }, true) 89 }, true)
83 90
84 if err != nil { 91 if err != nil {
85 return nil, xerr.NewErrMsgErr("删除评论信息失败", err) 92 return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
86 } 93 }
87 - resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id} 94 + resp = &types.MiniDeleteArticleCommentResponse{Id: commentInfo.Id}
88 return resp, nil 95 return resp, nil
89 } 96 }
@@ -2,6 +2,7 @@ package comment @@ -2,6 +2,7 @@ package comment
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 7 "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" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -61,49 +62,57 @@ func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *type @@ -61,49 +62,57 @@ func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *type
61 62
62 func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error { 63 func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error {
63 var conn = l.svcCtx.DefaultDBConn() 64 var conn = l.svcCtx.DefaultDBConn()
64 - commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId) 65 + commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId)
65 if err != nil { 66 if err != nil {
66 return xerr.NewErrMsgErr("删除评论信息失败", err) 67 return xerr.NewErrMsgErr("删除评论信息失败", err)
67 } 68 }
68 - if commetInfo.CompanyId != companyId { 69 + if commentInfo.CompanyId != companyId {
69 return xerr.NewErrMsg("没有操作权限") 70 return xerr.NewErrMsg("没有操作权限")
70 } 71 }
71 - if commetInfo.Show == domain.CommentShowDisable { 72 + if commentInfo.Show == domain.CommentShowDisable {
72 return nil 73 return nil
73 } 74 }
74 - commetInfo.Show = domain.CommentShowDisable 75 + commentInfo.Show = domain.CommentShowDisable
75 // 变更回复数量 76 // 变更回复数量
76 err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { 77 err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
77 - _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) 78 + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo)
78 if err != nil { 79 if err != nil {
79 return err 80 return err
80 } 81 }
81 // 减少上级评论的回复数量 82 // 减少上级评论的回复数量
82 - if commetInfo.Pid != 0 {  
83 - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid) 83 + if commentInfo.Pid != 0 {
  84 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
84 if err != nil { 85 if err != nil {
85 return err 86 return err
86 } 87 }
87 } 88 }
88 // 减少最顶层的评论回复计数 89 // 减少最顶层的评论回复计数
89 - if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {  
90 - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId) 90 + if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
  91 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
91 if err != nil { 92 if err != nil {
92 return err 93 return err
93 } 94 }
94 } 95 }
95 //减少加段落评论计数 96 //减少加段落评论计数
96 - if commetInfo.SectionId > 0 {  
97 - err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId) 97 + if commentInfo.SectionId > 0 {
  98 + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
98 if err != nil { 99 if err != nil {
99 return err 100 return err
100 } 101 }
101 } 102 }
102 // 减少文章的评论数 103 // 减少文章的评论数
103 - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId) 104 + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
104 if err != nil { 105 if err != nil {
105 return err 106 return err
106 } 107 }
  108 +
  109 + // 评论被隐藏消息
  110 + var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx)
  111 + err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content)
  112 + if err != nil {
  113 + return err
  114 + }
  115 +
107 return nil 116 return nil
108 }, true) 117 }, true)
109 118