|
@@ -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
|
} |