...
|
...
|
@@ -5,6 +5,7 @@ import ( |
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
...
|
...
|
@@ -32,7 +33,7 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch |
|
|
cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
|
|
|
req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("获取文章列表", err)
|
|
|
return nil, xerr.NewErrMsgErr("获取文章列表失败", err)
|
|
|
}
|
|
|
|
|
|
articleIds := []int64{}
|
...
|
...
|
@@ -40,8 +41,43 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch |
|
|
articleIds = append(articleIds, val.Id)
|
|
|
}
|
|
|
|
|
|
readFlag := map[int64]struct{}{}
|
|
|
|
|
|
if len(articleIds) > 0 {
|
|
|
queryOption := domain.NewQueryOptions().WithFindOnly().
|
|
|
MustWithKV("userId", req.UserId).MustWithKV("articleIds", articleIds)
|
|
|
_, userReadFlag, err := l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, queryOption)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("获取文章列表失败", err)
|
|
|
}
|
|
|
for _, val := range userReadFlag {
|
|
|
readFlag[val.ArticleId] = struct{}{}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
resp = &types.MiniSearchArticleResponse{
|
|
|
Total: int(cnt),
|
|
|
List: make([]types.MiniSearchArticleItem, len(articleList)),
|
|
|
}
|
|
|
return
|
|
|
|
|
|
for i, val := range articleList {
|
|
|
|
|
|
item := types.MiniSearchArticleItem{
|
|
|
ArticleId: val.Id,
|
|
|
Title: val.Title,
|
|
|
Author: val.Author.Name,
|
|
|
Images: []string{},
|
|
|
CreatedAt: val.CreatedAt,
|
|
|
MeReadFlag: 0,
|
|
|
}
|
|
|
if _, ok := readFlag[val.Id]; ok {
|
|
|
item.MeReadFlag = 1
|
|
|
}
|
|
|
for _, img := range val.Images {
|
|
|
item.Images = append(item.Images, img.Url)
|
|
|
}
|
|
|
resp.List[i] = item
|
|
|
}
|
|
|
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|