正在显示
7 个修改的文件
包含
98 行增加
和
38 行删除
@@ -185,14 +185,15 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | @@ -185,14 +185,15 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | ||
185 | } | 185 | } |
186 | } | 186 | } |
187 | //增加评论回复计数 | 187 | //增加评论回复计数 |
188 | - if pComment != nil { | ||
189 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id) | ||
190 | - if err != nil { | ||
191 | - return err | ||
192 | - } | ||
193 | - } | 188 | + // if pComment != nil { |
189 | + // err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id) | ||
190 | + // if err != nil { | ||
191 | + // return err | ||
192 | + // } | ||
193 | + // } | ||
194 | // 增加最顶层的评论回复计数 | 194 | // 增加最顶层的评论回复计数 |
195 | - if newComment.TopId != 0 && newComment.Pid != newComment.TopId { | 195 | + // if newComment.TopId != 0 && newComment.Pid != newComment.TopId { |
196 | + if newComment.TopId != 0 { | ||
196 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, newComment.TopId) | 197 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, newComment.TopId) |
197 | if err != nil { | 198 | if err != nil { |
198 | return err | 199 | return err |
@@ -2,6 +2,7 @@ package comment | @@ -2,6 +2,7 @@ package comment | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
@@ -52,14 +53,15 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | @@ -52,14 +53,15 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | ||
52 | return err | 53 | return err |
53 | } | 54 | } |
54 | // 减少上级评论的回复数量 | 55 | // 减少上级评论的回复数量 |
55 | - if commentInfo.Pid != 0 { | ||
56 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | ||
57 | - if err != nil { | ||
58 | - return err | ||
59 | - } | ||
60 | - } | 56 | + // if commentInfo.Pid != 0 { |
57 | + // err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | ||
58 | + // if err != nil { | ||
59 | + // return err | ||
60 | + // } | ||
61 | + // } | ||
61 | // 减少最顶层的评论回复计数 | 62 | // 减少最顶层的评论回复计数 |
62 | - if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId { | 63 | + // if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId { |
64 | + if commentInfo.TopId != 0 { | ||
63 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId) | 65 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId) |
64 | if err != nil { | 66 | if err != nil { |
65 | return err | 67 | return err |
@@ -67,18 +69,32 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | @@ -67,18 +69,32 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | ||
67 | } | 69 | } |
68 | //减少加段落评论计数 | 70 | //减少加段落评论计数 |
69 | if commentInfo.SectionId > 0 { | 71 | if commentInfo.SectionId > 0 { |
72 | + if commentInfo.TopId == 0 { | ||
73 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.SectionId) | ||
74 | + if err != nil { | ||
75 | + return err | ||
76 | + } | ||
77 | + } else { | ||
70 | err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) | 78 | err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) |
71 | if err != nil { | 79 | if err != nil { |
72 | return err | 80 | return err |
73 | } | 81 | } |
74 | } | 82 | } |
83 | + } | ||
75 | // 减少文章的评论数 | 84 | // 减少文章的评论数 |
85 | + if commentInfo.TopId == 0 { | ||
86 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.ArticleId) | ||
87 | + if err != nil { | ||
88 | + return err | ||
89 | + } | ||
90 | + } else { | ||
76 | err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) | 91 | err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) |
77 | if err != nil { | 92 | if err != nil { |
78 | return err | 93 | return err |
79 | } | 94 | } |
95 | + } | ||
80 | 96 | ||
81 | - //// 评论被隐藏消息 | 97 | + // 评论被隐藏消息 |
82 | //var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx) | 98 | //var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx) |
83 | //err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content) | 99 | //err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content) |
84 | //if err != nil { | 100 | //if err != nil { |
@@ -70,13 +70,13 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | @@ -70,13 +70,13 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | ||
70 | // 设置为显示评论 | 70 | // 设置为显示评论 |
71 | if commetInfo.Show != domain.CommentShowEnable { | 71 | if commetInfo.Show != domain.CommentShowEnable { |
72 | commetInfo.Show = domain.CommentShowEnable | 72 | commetInfo.Show = domain.CommentShowEnable |
73 | - increaseCount = 1 | 73 | + increaseCount = commetInfo.CountReply + 1 |
74 | } | 74 | } |
75 | case 2: | 75 | case 2: |
76 | // 设置为隐藏评论 | 76 | // 设置为隐藏评论 |
77 | if commetInfo.Show != domain.CommentShowDisable { | 77 | if commetInfo.Show != domain.CommentShowDisable { |
78 | commetInfo.Show = domain.CommentShowDisable | 78 | commetInfo.Show = domain.CommentShowDisable |
79 | - increaseCount = -1 | 79 | + increaseCount = -(commetInfo.CountReply + 1) |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
@@ -88,14 +88,15 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | @@ -88,14 +88,15 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | ||
88 | } | 88 | } |
89 | if increaseCount != 0 { | 89 | if increaseCount != 0 { |
90 | // 增加上级评论的回复数量 | 90 | // 增加上级评论的回复数量 |
91 | - if commetInfo.Pid != 0 { | ||
92 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.Pid) | ||
93 | - if err != nil { | ||
94 | - return err | ||
95 | - } | ||
96 | - } | 91 | + // if commetInfo.Pid != 0 { |
92 | + // err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.Pid) | ||
93 | + // if err != nil { | ||
94 | + // return err | ||
95 | + // } | ||
96 | + // } | ||
97 | // 增加最顶层的评论回复计数 | 97 | // 增加最顶层的评论回复计数 |
98 | - if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | 98 | + // if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { |
99 | + if commetInfo.TopId != 0 { | ||
99 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.TopId) | 100 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.TopId) |
100 | if err != nil { | 101 | if err != nil { |
101 | return err | 102 | return err |
@@ -2,6 +2,7 @@ package comment | @@ -2,6 +2,7 @@ package comment | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" |
6 | 7 | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
@@ -80,14 +81,15 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI | @@ -80,14 +81,15 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI | ||
80 | return err | 81 | return err |
81 | } | 82 | } |
82 | // 减少上级评论的回复数量 | 83 | // 减少上级评论的回复数量 |
83 | - if commentInfo.Pid != 0 { | ||
84 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | ||
85 | - if err != nil { | ||
86 | - return err | ||
87 | - } | ||
88 | - } | 84 | + // if commentInfo.Pid != 0 { |
85 | + // err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | ||
86 | + // if err != nil { | ||
87 | + // return err | ||
88 | + // } | ||
89 | + // } | ||
89 | // 减少最顶层的评论回复计数 | 90 | // 减少最顶层的评论回复计数 |
90 | - if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId { | 91 | + // if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId { |
92 | + if commentInfo.TopId != 0 { | ||
91 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId) | 93 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId) |
92 | if err != nil { | 94 | if err != nil { |
93 | return err | 95 | return err |
@@ -95,16 +97,30 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI | @@ -95,16 +97,30 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI | ||
95 | } | 97 | } |
96 | //减少加段落评论计数 | 98 | //减少加段落评论计数 |
97 | if commentInfo.SectionId > 0 { | 99 | if commentInfo.SectionId > 0 { |
100 | + if commentInfo.TopId == 0 { | ||
101 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.SectionId) | ||
102 | + if err != nil { | ||
103 | + return err | ||
104 | + } | ||
105 | + } else { | ||
98 | err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) | 106 | err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) |
99 | if err != nil { | 107 | if err != nil { |
100 | return err | 108 | return err |
101 | } | 109 | } |
102 | } | 110 | } |
111 | + } | ||
103 | // 减少文章的评论数 | 112 | // 减少文章的评论数 |
113 | + if commentInfo.TopId == 0 { | ||
114 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.ArticleId) | ||
115 | + if err != nil { | ||
116 | + return err | ||
117 | + } | ||
118 | + } else { | ||
104 | err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) | 119 | err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) |
105 | if err != nil { | 120 | if err != nil { |
106 | return err | 121 | return err |
107 | } | 122 | } |
123 | + } | ||
108 | 124 | ||
109 | // 评论被隐藏消息 | 125 | // 评论被隐藏消息 |
110 | var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx) | 126 | var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx) |
@@ -142,14 +158,15 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId | @@ -142,14 +158,15 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId | ||
142 | return err | 158 | return err |
143 | } | 159 | } |
144 | // 增加上级评论的回复数量 | 160 | // 增加上级评论的回复数量 |
145 | - if commetInfo.Pid != 0 { | ||
146 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid) | ||
147 | - if err != nil { | ||
148 | - return err | ||
149 | - } | ||
150 | - } | 161 | + // if commetInfo.Pid != 0 { |
162 | + // err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid) | ||
163 | + // if err != nil { | ||
164 | + // return err | ||
165 | + // } | ||
166 | + // } | ||
151 | // 增加最顶层的评论回复计数 | 167 | // 增加最顶层的评论回复计数 |
152 | - if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | 168 | + // if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { |
169 | + if commetInfo.TopId != 0 { | ||
153 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId) | 170 | err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId) |
154 | if err != nil { | 171 | if err != nil { |
155 | return err | 172 | return err |
@@ -157,16 +174,30 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId | @@ -157,16 +174,30 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId | ||
157 | } | 174 | } |
158 | //增加加段落评论计数 | 175 | //增加加段落评论计数 |
159 | if commetInfo.SectionId > 0 { | 176 | if commetInfo.SectionId > 0 { |
177 | + if commetInfo.TopId == 0 { | ||
178 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, commetInfo.CountReply+1, commetInfo.SectionId) | ||
179 | + if err != nil { | ||
180 | + return err | ||
181 | + } | ||
182 | + } else { | ||
160 | err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId) | 183 | err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId) |
161 | if err != nil { | 184 | if err != nil { |
162 | return err | 185 | return err |
163 | } | 186 | } |
164 | } | 187 | } |
188 | + } | ||
165 | // 增加文章的评论数 | 189 | // 增加文章的评论数 |
190 | + if commetInfo.TopId == 0 { | ||
191 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, commetInfo.CountReply+1, commetInfo.ArticleId) | ||
192 | + if err != nil { | ||
193 | + return err | ||
194 | + } | ||
195 | + } else { | ||
166 | err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId) | 196 | err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId) |
167 | if err != nil { | 197 | if err != nil { |
168 | return err | 198 | return err |
169 | } | 199 | } |
200 | + } | ||
170 | return nil | 201 | return nil |
171 | }, true) | 202 | }, true) |
172 | 203 |
@@ -40,6 +40,9 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) | @@ -40,6 +40,9 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) | ||
40 | MustWithKV("accountFrom", []string{domain.AccountFromSearchJoin}) | 40 | MustWithKV("accountFrom", []string{domain.AccountFromSearchJoin}) |
41 | if req.AuditFlag != nil && *req.AuditFlag >= 0 { | 41 | if req.AuditFlag != nil && *req.AuditFlag >= 0 { |
42 | queryOptions.MustWithKV("auditStatus", []int{*req.AuditFlag}) | 42 | queryOptions.MustWithKV("auditStatus", []int{*req.AuditFlag}) |
43 | + if *req.AuditFlag == 2 { | ||
44 | + queryOptions.MustWithKV("unscoped", true) | ||
45 | + } | ||
43 | } | 46 | } |
44 | if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { | 47 | if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { |
45 | return nil, xerr.NewErrMsgErr("查询审核列表失败", err) | 48 | return nil, xerr.NewErrMsgErr("查询审核列表失败", err) |
@@ -41,6 +41,11 @@ func (l *MiniUserAuditLogic) MiniUserAudit(req *types.MiniUserAuditRequest) (err | @@ -41,6 +41,11 @@ func (l *MiniUserAuditLogic) MiniUserAudit(req *types.MiniUserAuditRequest) (err | ||
41 | if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { | 41 | if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { |
42 | return err | 42 | return err |
43 | } | 43 | } |
44 | + if req.Status == domain.UserAuditStatusReject { | ||
45 | + if user, err = l.svcCtx.UserRepository.Delete(ctx, conn, user); err != nil { | ||
46 | + return err | ||
47 | + } | ||
48 | + } | ||
44 | return nil | 49 | return nil |
45 | }, true); err != nil { | 50 | }, true); err != nil { |
46 | return xerr.NewErrMsgErr("审核失败", err) | 51 | return xerr.NewErrMsgErr("审核失败", err) |
@@ -144,6 +144,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | @@ -144,6 +144,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | ||
144 | ) | 144 | ) |
145 | queryFunc := func() (interface{}, error) { | 145 | queryFunc := func() (interface{}, error) { |
146 | tx = tx.Model(&ms) | 146 | tx = tx.Model(&ms) |
147 | + if v, ok := queryOptions["unscoped"]; ok && v.(bool) { | ||
148 | + tx.Unscoped() | ||
149 | + } | ||
147 | if v, ok := queryOptions["companyId"]; ok { | 150 | if v, ok := queryOptions["companyId"]; ok { |
148 | tx.Where("company_id = ?", v) | 151 | tx.Where("company_id = ?", v) |
149 | } | 152 | } |
-
请 注册 或 登录 后发表评论