|
@@ -5,6 +5,7 @@ import ( |
|
@@ -5,6 +5,7 @@ import ( |
5
|
|
5
|
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
8
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
9
|
|
10
|
|
10
|
"github.com/zeromicro/go-zero/core/logx"
|
11
|
"github.com/zeromicro/go-zero/core/logx"
|
|
@@ -32,7 +33,7 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch |
|
@@ -32,7 +33,7 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch |
32
|
cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
|
33
|
cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
|
33
|
req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
|
34
|
req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
|
34
|
if err != nil {
|
35
|
if err != nil {
|
35
|
- return nil, xerr.NewErrMsgErr("获取文章列表", err)
|
36
|
+ return nil, xerr.NewErrMsgErr("获取文章列表失败", err)
|
36
|
}
|
37
|
}
|
37
|
|
38
|
|
38
|
articleIds := []int64{}
|
39
|
articleIds := []int64{}
|
|
@@ -40,8 +41,43 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch |
|
@@ -40,8 +41,43 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch |
40
|
articleIds = append(articleIds, val.Id)
|
41
|
articleIds = append(articleIds, val.Id)
|
41
|
}
|
42
|
}
|
42
|
|
43
|
|
|
|
44
|
+ readFlag := map[int64]struct{}{}
|
|
|
45
|
+
|
|
|
46
|
+ if len(articleIds) > 0 {
|
|
|
47
|
+ queryOption := domain.NewQueryOptions().WithFindOnly().
|
|
|
48
|
+ MustWithKV("userId", req.UserId).MustWithKV("articleIds", articleIds)
|
|
|
49
|
+ _, userReadFlag, err := l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, queryOption)
|
|
|
50
|
+ if err != nil {
|
|
|
51
|
+ return nil, xerr.NewErrMsgErr("获取文章列表失败", err)
|
|
|
52
|
+ }
|
|
|
53
|
+ for _, val := range userReadFlag {
|
|
|
54
|
+ readFlag[val.ArticleId] = struct{}{}
|
|
|
55
|
+ }
|
|
|
56
|
+ }
|
|
|
57
|
+
|
43
|
resp = &types.MiniSearchArticleResponse{
|
58
|
resp = &types.MiniSearchArticleResponse{
|
44
|
Total: int(cnt),
|
59
|
Total: int(cnt),
|
|
|
60
|
+ List: make([]types.MiniSearchArticleItem, len(articleList)),
|
45
|
}
|
61
|
}
|
46
|
- return
|
62
|
+
|
|
|
63
|
+ for i, val := range articleList {
|
|
|
64
|
+
|
|
|
65
|
+ item := types.MiniSearchArticleItem{
|
|
|
66
|
+ ArticleId: val.Id,
|
|
|
67
|
+ Title: val.Title,
|
|
|
68
|
+ Author: val.Author.Name,
|
|
|
69
|
+ Images: []string{},
|
|
|
70
|
+ CreatedAt: val.CreatedAt,
|
|
|
71
|
+ MeReadFlag: 0,
|
|
|
72
|
+ }
|
|
|
73
|
+ if _, ok := readFlag[val.Id]; ok {
|
|
|
74
|
+ item.MeReadFlag = 1
|
|
|
75
|
+ }
|
|
|
76
|
+ for _, img := range val.Images {
|
|
|
77
|
+ item.Images = append(item.Images, img.Url)
|
|
|
78
|
+ }
|
|
|
79
|
+ resp.List[i] = item
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
|
82
|
+ return resp, nil
|
47
|
} |
83
|
} |