作者 郑周

1 评论结构优化

@@ -46,19 +46,19 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. @@ -46,19 +46,19 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types.
46 46
47 var userMap = make(map[int64]*domain.User) 47 var userMap = make(map[int64]*domain.User)
48 var articleMap = make(map[int64]*domain.Article) 48 var articleMap = make(map[int64]*domain.Article)
49 - var commentMap = make(map[int64]*domain.Comment) 49 + var commentMap = make(map[int64]*domain.ArticleComment)
50 50
51 lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { 51 lo.ForEach(list, func(item *domain.UserLoveFlag, index int) {
52 var ( 52 var (
53 user *domain.User 53 user *domain.User
54 article *domain.Article 54 article *domain.Article
55 - comment *domain.Comment 55 + comment *domain.ArticleComment
56 ) 56 )
57 57
58 if item.CommentId != 0 { // 点赞评论 58 if item.CommentId != 0 { // 点赞评论
59 user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.CommentAuthor, l.svcCtx.UserRepository.FindOne) 59 user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.CommentAuthor, l.svcCtx.UserRepository.FindOne)
60 article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) 60 article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne)
61 - comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.CommentRepository.FindOne) 61 + comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne)
62 } else { 62 } else {
63 user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ArticleAuthor, l.svcCtx.UserRepository.FindOne) 63 user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ArticleAuthor, l.svcCtx.UserRepository.FindOne)
64 article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) 64 article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne)
@@ -70,7 +70,7 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. @@ -70,7 +70,7 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types.
70 return 70 return
71 } 71 }
72 72
73 -func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.Comment) types.MyLikeItem { 73 +func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyLikeItem {
74 item := types.MyLikeItem{ 74 item := types.MyLikeItem{
75 UserId: love.UserId, 75 UserId: love.UserId,
76 ArticleId: love.ArticleId, 76 ArticleId: love.ArticleId,
@@ -101,10 +101,11 @@ func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain @@ -101,10 +101,11 @@ func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain
101 101
102 if comment != nil { 102 if comment != nil {
103 item.Comment = &types.SimpleComment{ 103 item.Comment = &types.SimpleComment{
104 - Id: comment.Id,  
105 - //Content: comment.Content,  
106 - //CountLove: comment.CountLove,  
107 - //CountComment: comment.CountComment, 104 + Id: comment.Id,
  105 + Content: comment.Content,
  106 + CountLove: comment.CountUserLove,
  107 + CountComment: comment.CountReply,
  108 + Show: int(comment.Show),
108 } 109 }
109 } 110 }
110 111