Skip to content

Commit

Permalink
fix: 专栏文章统计信息获取修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Liusiyuan-git committed Feb 24, 2023
1 parent 7034ae0 commit f90fe20
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 19 additions & 1 deletion app/bff/interface/internal/biz/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,25 @@ func (r *ArticleUseCase) GetArticleListHot(ctx context.Context, page int32) ([]*
}

func (r *ArticleUseCase) GetColumnArticleList(ctx context.Context, id int32) ([]*Article, error) {
return r.repo.GetColumnArticleList(ctx, id)
articleList, err := r.repo.GetColumnArticleList(ctx, id)
if err != nil {
return nil, err
}
articleListStatistic, err := r.repo.GetArticleListStatistic(ctx, articleList)
if err != nil {
return nil, err
}
for _, item := range articleListStatistic {
for index, listItem := range articleList {
if listItem.Id == item.Id {
articleList[index].Agree = item.Agree
articleList[index].View = item.View
articleList[index].Collect = item.Collect
articleList[index].Comment = item.Comment
}
}
}
return articleList, nil
}

func (r *ArticleUseCase) GetArticleCount(ctx context.Context) (int32, error) {
Expand Down
8 changes: 6 additions & 2 deletions app/bff/interface/internal/service/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,12 @@ func (s *BffService) GetColumnArticleList(ctx context.Context, req *v1.GetColumn
reply := &v1.GetArticleListReply{Article: make([]*v1.GetArticleListReply_Article, 0, len(articleList))}
for _, item := range articleList {
reply.Article = append(reply.Article, &v1.GetArticleListReply_Article{
Id: item.Id,
Uuid: item.Uuid,
Id: item.Id,
Uuid: item.Uuid,
Agree: item.Agree,
Collect: item.Collect,
View: item.View,
Comment: item.Comment,
})
}
return reply, nil
Expand Down

0 comments on commit f90fe20

Please sign in to comment.