...
|
...
|
@@ -30,7 +30,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS |
|
|
queryOptions := domain.NewQueryOptions().
|
|
|
WithOffsetLimit(req.Page, req.Size).
|
|
|
WithKV("title", req.Title).
|
|
|
WithKV("author", req.Author).
|
|
|
WithKV("authorId", req.Author).
|
|
|
WithKV("beginCreatedAt", req.BeginTime).
|
|
|
WithKV("endCreatedAt", req.EndTime)
|
|
|
total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
|
...
|
...
|
@@ -41,6 +41,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS |
|
|
Total: int(total),
|
|
|
List: make([]types.SystemArticleSearch, 0),
|
|
|
}
|
|
|
authorIds := make([]int64, 0)
|
|
|
lo.ForEach(articles, func(item *domain.Article, index int) {
|
|
|
images := make([]string, 0)
|
|
|
lo.ForEach(item.Images, func(img domain.Image, n int) {
|
...
|
...
|
@@ -49,6 +50,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS |
|
|
resp.List = append(resp.List, types.SystemArticleSearch{
|
|
|
Id: item.Id,
|
|
|
Title: item.Title,
|
|
|
AuthorId: item.AuthorId,
|
|
|
Author: item.Author.Name,
|
|
|
Images: images,
|
|
|
CreatedAt: item.CreatedAt,
|
...
|
...
|
@@ -58,6 +60,16 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS |
|
|
Tags: nil,
|
|
|
TargetUser: int(item.TargetUser),
|
|
|
})
|
|
|
authorIds = append(authorIds, item.AuthorId)
|
|
|
})
|
|
|
//查询用户数据,重新赋值更新用户名称
|
|
|
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
|
|
|
lo.ForEach(resp.List, func(item types.SystemArticleSearch, index int) {
|
|
|
for _, user := range users {
|
|
|
if user.Id == item.AuthorId {
|
|
|
resp.List[index].Author = user.Name
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|