|
@@ -43,33 +43,47 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS |
|
@@ -43,33 +43,47 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS |
43
|
}
|
43
|
}
|
44
|
authorIds := make([]int64, 0)
|
44
|
authorIds := make([]int64, 0)
|
45
|
lo.ForEach(articles, func(item *domain.Article, index int) {
|
45
|
lo.ForEach(articles, func(item *domain.Article, index int) {
|
|
|
46
|
+ authorIds = append(authorIds, item.AuthorId)
|
|
|
47
|
+ })
|
|
|
48
|
+ //查询用户数据,重新赋值更新用户名称
|
|
|
49
|
+ _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
|
|
|
50
|
+ //获取标签
|
|
|
51
|
+ _, tags, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions())
|
|
|
52
|
+ lo.ForEach(articles, func(item *domain.Article, index int) {
|
|
|
53
|
+ //图片
|
46
|
images := make([]string, 0)
|
54
|
images := make([]string, 0)
|
47
|
lo.ForEach(item.Images, func(img domain.Image, n int) {
|
55
|
lo.ForEach(item.Images, func(img domain.Image, n int) {
|
48
|
images = append(images, img.Url)
|
56
|
images = append(images, img.Url)
|
49
|
})
|
57
|
})
|
|
|
58
|
+ //发布人
|
|
|
59
|
+ author := item.Author.Name
|
|
|
60
|
+ for _, user := range users {
|
|
|
61
|
+ if user.Id == item.AuthorId {
|
|
|
62
|
+ author = user.Name
|
|
|
63
|
+ }
|
|
|
64
|
+ }
|
|
|
65
|
+ //标签
|
|
|
66
|
+ articleTags := make([]string, 0)
|
|
|
67
|
+ lo.ForEach(item.Tags, func(tagId int64, index int) {
|
|
|
68
|
+ for _, t := range tags {
|
|
|
69
|
+ if t.Id == tagId {
|
|
|
70
|
+ articleTags = append(articleTags, t.Name)
|
|
|
71
|
+ }
|
|
|
72
|
+ }
|
|
|
73
|
+ })
|
50
|
resp.List = append(resp.List, types.SystemArticleSearch{
|
74
|
resp.List = append(resp.List, types.SystemArticleSearch{
|
51
|
Id: item.Id,
|
75
|
Id: item.Id,
|
52
|
Title: item.Title,
|
76
|
Title: item.Title,
|
53
|
AuthorId: item.AuthorId,
|
77
|
AuthorId: item.AuthorId,
|
54
|
- Author: item.Author.Name,
|
78
|
+ Author: author,
|
55
|
Images: images,
|
79
|
Images: images,
|
56
|
CreatedAt: item.CreatedAt,
|
80
|
CreatedAt: item.CreatedAt,
|
57
|
CountLove: item.CountLove,
|
81
|
CountLove: item.CountLove,
|
58
|
CountComment: item.CountComment,
|
82
|
CountComment: item.CountComment,
|
59
|
Show: int(item.Show),
|
83
|
Show: int(item.Show),
|
60
|
- Tags: nil,
|
84
|
+ Tags: articleTags,
|
61
|
TargetUser: int(item.TargetUser),
|
85
|
TargetUser: int(item.TargetUser),
|
62
|
})
|
86
|
})
|
63
|
- authorIds = append(authorIds, item.AuthorId)
|
|
|
64
|
- })
|
|
|
65
|
- //查询用户数据,重新赋值更新用户名称
|
|
|
66
|
- _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
|
|
|
67
|
- lo.ForEach(resp.List, func(item types.SystemArticleSearch, index int) {
|
|
|
68
|
- for _, user := range users {
|
|
|
69
|
- if user.Id == item.AuthorId {
|
|
|
70
|
- resp.List[index].Author = user.Name
|
|
|
71
|
- }
|
|
|
72
|
- }
|
|
|
73
|
})
|
87
|
})
|
74
|
- return resp, nil
|
88
|
+ return
|
75
|
} |
89
|
} |