正在显示
1 个修改的文件
包含
21 行增加
和
14 行删除
@@ -267,22 +267,29 @@ func (l *MiniBusinessLogic) createMessage( | @@ -267,22 +267,29 @@ func (l *MiniBusinessLogic) createMessage( | ||
267 | at []int64) (err error) { | 267 | at []int64) (err error) { |
268 | 268 | ||
269 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) | 269 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) |
270 | - // 评论中携带了 @其他用户 | 270 | + var dupMap = make(map[int64]int64, 0) |
271 | + // 评论中携带了 @用户 | ||
271 | for i := range at { | 272 | for i := range at { |
272 | - var msg = &domain.MessageBusiness{ | ||
273 | - Type: msgType, | ||
274 | - OptType: optType, | ||
275 | - CompanyId: userToken.CompanyId, | ||
276 | - UserId: userToken.UserId, | ||
277 | - RecipientId: at[i], | ||
278 | - ArticleId: articleId, | ||
279 | - CommentId: commentId, | ||
280 | - CommentParentId: commentParentId, | ||
281 | - } | ||
282 | - msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg) | ||
283 | - if err != nil { | ||
284 | - return err | 273 | + if _, ok := dupMap[at[i]]; ok { /* ID去重 */ |
274 | + // do nothing ... | ||
275 | + } else { | ||
276 | + var msg = &domain.MessageBusiness{ | ||
277 | + Type: msgType, | ||
278 | + OptType: optType, | ||
279 | + CompanyId: userToken.CompanyId, | ||
280 | + UserId: userToken.UserId, | ||
281 | + RecipientId: at[i], | ||
282 | + ArticleId: articleId, | ||
283 | + CommentId: commentId, | ||
284 | + CommentParentId: commentParentId, | ||
285 | + } | ||
286 | + msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg) | ||
287 | + if err != nil { | ||
288 | + return err | ||
289 | + } | ||
290 | + dupMap[at[i]] = at[i] | ||
285 | } | 291 | } |
292 | + | ||
286 | } | 293 | } |
287 | return nil | 294 | return nil |
288 | } | 295 | } |
-
请 注册 或 登录 后发表评论