作者 zhuangmx

Merge branch 'dev' into test

@@ -153,7 +153,8 @@ func (l *MiniSubscribeLogic) ReplyComment(conn transaction.Conn, article *domain @@ -153,7 +153,8 @@ func (l *MiniSubscribeLogic) ReplyComment(conn transaction.Conn, article *domain
153 msg.ToUser = openId 153 msg.ToUser = openId
154 msg.Page = fmt.Sprintf("/pages/detail/more-comment?id=%v", article.Id) //跳转页面 帖子评论聚合页 154 msg.Page = fmt.Sprintf("/pages/detail/more-comment?id=%v", article.Id) //跳转页面 帖子评论聚合页
155 //备注 155 //备注
156 - msg.Data["thing9"] = &subscribe.DataItem{Value: fmt.Sprintf("您的帖子最近已有%v人评论,点击查看详情", article.CountComment)} 156 + userCount, _ := l.svcCtx.ArticleCommentRepository.CommentUserCount(l.ctx, conn, comment.CompanyId, comment.ArticleId)
  157 + msg.Data["thing9"] = &subscribe.DataItem{Value: fmt.Sprintf("您的帖子最近已有%v人评论,点击查看详情", userCount)}
157 //发送微信订阅消息 158 //发送微信订阅消息
158 err = subCtx.Send(msg) 159 err = subCtx.Send(msg)
159 err = l.saveAndDecrease(conn, comment.CompanyId, article.AuthorId, domain.SubscribeTypeReplyComment, msg, err) 160 err = l.saveAndDecrease(conn, comment.CompanyId, article.AuthorId, domain.SubscribeTypeReplyComment, msg, err)
@@ -168,9 +169,9 @@ func (l *MiniSubscribeLogic) ReplyComment(conn transaction.Conn, article *domain @@ -168,9 +169,9 @@ func (l *MiniSubscribeLogic) ReplyComment(conn transaction.Conn, article *domain
168 msg.ToUser = toOpenId 169 msg.ToUser = toOpenId
169 msg.Page = fmt.Sprintf("/pages/detail/reply-comment?id=%v&commentId=%v", article.Id, comment.Pid) //跳转页面评论聚合页 170 msg.Page = fmt.Sprintf("/pages/detail/reply-comment?id=%v&commentId=%v", article.Id, comment.Pid) //跳转页面评论聚合页
170 //备注 171 //备注
171 - parent, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, comment.Pid)  
172 - if err == nil && parent.Id > 0 {  
173 - msg.Data["thing9"] = &subscribe.DataItem{Value: fmt.Sprintf("您的评论最近已有%v人回复,点击查看详情", parent.CountReply)} 172 + replyCount, err := l.svcCtx.ArticleCommentRepository.ReplyUserCount(l.ctx, conn, comment.CompanyId, comment.Pid)
  173 + if err == nil {
  174 + msg.Data["thing9"] = &subscribe.DataItem{Value: fmt.Sprintf("您的评论最近已有%v人回复,点击查看详情", replyCount)}
174 //发送微信订阅消息 175 //发送微信订阅消息
175 err = subCtx.Send(msg) 176 err = subCtx.Send(msg)
176 err = l.saveAndDecrease(conn, comment.CompanyId, comment.ToUserId, domain.SubscribeTypeReplyComment, msg, err) 177 err = l.saveAndDecrease(conn, comment.CompanyId, comment.ToUserId, domain.SubscribeTypeReplyComment, msg, err)
@@ -210,6 +211,10 @@ func (l *MiniSubscribeLogic) LikeArticle(conn transaction.Conn, article *domain. @@ -210,6 +211,10 @@ func (l *MiniSubscribeLogic) LikeArticle(conn transaction.Conn, article *domain.
210 if err != nil || openId == "" { 211 if err != nil || openId == "" {
211 return nil 212 return nil
212 } 213 }
  214 + newArticle, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, article.Id)
  215 + if err != nil {
  216 + return xerr.NewErrMsgErr("未获取到帖子信息", err)
  217 + }
213 msg := &subscribe.Message{ 218 msg := &subscribe.Message{
214 ToUser: openId, 219 ToUser: openId,
215 TemplateID: domain.SubscribeTemplateLike, 220 TemplateID: domain.SubscribeTemplateLike,
@@ -222,7 +227,7 @@ func (l *MiniSubscribeLogic) LikeArticle(conn transaction.Conn, article *domain. @@ -222,7 +227,7 @@ func (l *MiniSubscribeLogic) LikeArticle(conn transaction.Conn, article *domain.
222 //动态内容 227 //动态内容
223 "thing8": &subscribe.DataItem{Value: article.GetSubscribeMessageTitle()}, 228 "thing8": &subscribe.DataItem{Value: article.GetSubscribeMessageTitle()},
224 //被赞次数 229 //被赞次数
225 - "number4": &subscribe.DataItem{Value: article.CountLove}, 230 + "number4": &subscribe.DataItem{Value: newArticle.CountLove},
226 //温馨提示 231 //温馨提示
227 "thing5": &subscribe.DataItem{Value: "这条内容很受欢迎哦,快来看看吧"}, 232 "thing5": &subscribe.DataItem{Value: "这条内容很受欢迎哦,快来看看吧"},
228 }, 233 },
@@ -243,6 +248,11 @@ func (l *MiniSubscribeLogic) LikeComment(conn transaction.Conn, comment *domain. @@ -243,6 +248,11 @@ func (l *MiniSubscribeLogic) LikeComment(conn transaction.Conn, comment *domain.
243 if err != nil || openId == "" { 248 if err != nil || openId == "" {
244 return nil 249 return nil
245 } 250 }
  251 + //获取被赞次数
  252 + newComment, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, comment.Id)
  253 + if err != nil {
  254 + return xerr.NewErrMsgErr("未获取到评论信息", err)
  255 + }
246 msg := &subscribe.Message{ 256 msg := &subscribe.Message{
247 ToUser: openId, 257 ToUser: openId,
248 TemplateID: domain.SubscribeTemplateLike, 258 TemplateID: domain.SubscribeTemplateLike,
@@ -255,7 +265,7 @@ func (l *MiniSubscribeLogic) LikeComment(conn transaction.Conn, comment *domain. @@ -255,7 +265,7 @@ func (l *MiniSubscribeLogic) LikeComment(conn transaction.Conn, comment *domain.
255 //动态内容 265 //动态内容
256 "thing8": &subscribe.DataItem{Value: comment.GetSubscribeMessageContent()}, 266 "thing8": &subscribe.DataItem{Value: comment.GetSubscribeMessageContent()},
257 //被赞次数 267 //被赞次数
258 - "number4": &subscribe.DataItem{Value: comment.CountUserLove}, 268 + "number4": &subscribe.DataItem{Value: newComment.CountUserLove},
259 //温馨提示 269 //温馨提示
260 "thing5": &subscribe.DataItem{Value: "这条内容很受欢迎哦,快来看看吧"}, 270 "thing5": &subscribe.DataItem{Value: "这条内容很受欢迎哦,快来看看吧"},
261 }, 271 },
@@ -437,6 +437,28 @@ func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, @@ -437,6 +437,28 @@ func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context,
437 437
438 } 438 }
439 439
  440 +// CommentUserCount 统计评论人数
  441 +func (repository *ArticleCommentRepository) CommentUserCount(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) (int64, error) {
  442 + var (
  443 + err error
  444 + tx = conn.DB()
  445 + c int64
  446 + )
  447 + err = tx.Model(&models.ArticleComment{}).Where("company_id = ? and article_id = ?", companyId, articleId).Group("user_id").Count(&c).Error
  448 + return c, err
  449 +}
  450 +
  451 +// ReplyUserCount 统计回复人数
  452 +func (repository *ArticleCommentRepository) ReplyUserCount(ctx context.Context, conn transaction.Conn, companyId int64, commentId int64) (int64, error) {
  453 + var (
  454 + err error
  455 + tx = conn.DB()
  456 + c int64
  457 + )
  458 + err = tx.Model(&models.ArticleComment{}).Where("company_id = ? and pid = ?", companyId, commentId).Group("user_id").Count(&c).Error
  459 + return c, err
  460 +}
  461 +
440 func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository { 462 func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository {
441 return &ArticleCommentRepository{CachedRepository: cache} 463 return &ArticleCommentRepository{CachedRepository: cache}
442 } 464 }
@@ -80,6 +80,10 @@ type ArticleCommentRepository interface { @@ -80,6 +80,10 @@ type ArticleCommentRepository interface {
80 // 特定的查询 80 // 特定的查询
81 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, 81 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
82 topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error) 82 topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error)
  83 + // CommentUserCount 统计帖子评论人数
  84 + CommentUserCount(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) (int64, error)
  85 + // ReplyUserCount 统计评论回复人数
  86 + ReplyUserCount(ctx context.Context, conn transaction.Conn, companyId int64, commentId int64) (int64, error)
83 } 87 }
84 88
85 // 运营点数 填写的最大值 89 // 运营点数 填写的最大值