作者 庄敏学

文章列表bug

@@ -389,12 +389,12 @@ type ( @@ -389,12 +389,12 @@ type (
389 SystemArticleSearch { 389 SystemArticleSearch {
390 Id int64 `json:"id"` //id 390 Id int64 `json:"id"` //id
391 Title string `json:"title"` //标题 391 Title string `json:"title"` //标题
392 - AuthorId int64 `json:"author"` //发布人ID 392 + AuthorId int64 `json:"authorId"` //发布人ID
393 Author string `json:"author"` //发布人 393 Author string `json:"author"` //发布人
394 Images []string `json:"images"` //图片 394 Images []string `json:"images"` //图片
395 CreatedAt int64 `json:"createdAt"` //文章的创建日期 395 CreatedAt int64 `json:"createdAt"` //文章的创建日期
396 CountLove int `json:"countLove"` //点赞数量 396 CountLove int `json:"countLove"` //点赞数量
397 - CountComment int `json:"CountComment"` //评论数量 397 + CountComment int `json:"countComment"` //评论数量
398 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 398 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
399 Tags []string `json:"tags"` //标签 399 Tags []string `json:"tags"` //标签
400 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 400 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
@@ -43,15 +43,26 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS @@ -43,15 +43,26 @@ 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 + lo.ForEach(articles, func(item *domain.Article, index int) {
46 images := make([]string, 0) 51 images := make([]string, 0)
47 lo.ForEach(item.Images, func(img domain.Image, n int) { 52 lo.ForEach(item.Images, func(img domain.Image, n int) {
48 images = append(images, img.Url) 53 images = append(images, img.Url)
49 }) 54 })
  55 + author := item.Author.Name
  56 + for _, user := range users {
  57 + if user.Id == item.AuthorId {
  58 + author = user.Name
  59 + }
  60 + }
50 resp.List = append(resp.List, types.SystemArticleSearch{ 61 resp.List = append(resp.List, types.SystemArticleSearch{
51 Id: item.Id, 62 Id: item.Id,
52 Title: item.Title, 63 Title: item.Title,
53 AuthorId: item.AuthorId, 64 AuthorId: item.AuthorId,
54 - Author: item.Author.Name, 65 + Author: author,
55 Images: images, 66 Images: images,
56 CreatedAt: item.CreatedAt, 67 CreatedAt: item.CreatedAt,
57 CountLove: item.CountLove, 68 CountLove: item.CountLove,
@@ -60,16 +71,6 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS @@ -60,16 +71,6 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
60 Tags: nil, 71 Tags: nil,
61 TargetUser: int(item.TargetUser), 72 TargetUser: int(item.TargetUser),
62 }) 73 })
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 }) 74 })
74 - return resp, nil 75 + return
75 } 76 }
@@ -1172,12 +1172,12 @@ type SystemArticleSearchResponse struct { @@ -1172,12 +1172,12 @@ type SystemArticleSearchResponse struct {
1172 type SystemArticleSearch struct { 1172 type SystemArticleSearch struct {
1173 Id int64 `json:"id"` //id 1173 Id int64 `json:"id"` //id
1174 Title string `json:"title"` //标题 1174 Title string `json:"title"` //标题
1175 - AuthorId int64 `json:"author"` //发布人ID 1175 + AuthorId int64 `json:"authorId"` //发布人ID
1176 Author string `json:"author"` //发布人 1176 Author string `json:"author"` //发布人
1177 Images []string `json:"images"` //图片 1177 Images []string `json:"images"` //图片
1178 CreatedAt int64 `json:"createdAt"` //文章的创建日期 1178 CreatedAt int64 `json:"createdAt"` //文章的创建日期
1179 CountLove int `json:"countLove"` //点赞数量 1179 CountLove int `json:"countLove"` //点赞数量
1180 - CountComment int `json:"CountComment"` //评论数量 1180 + CountComment int `json:"countComment"` //评论数量
1181 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 1181 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
1182 Tags []string `json:"tags"` //标签 1182 Tags []string `json:"tags"` //标签
1183 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 1183 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]