fix: 统一分页请求的 offset 语义
This commit is contained in:
@@ -33,7 +33,7 @@ func (l *ListPostsLogic) ListPosts(req *types.PostListReq) (resp *types.PostList
|
||||
if req.Limit <= 0 {
|
||||
req.Limit = 20
|
||||
}
|
||||
in := &communitypb.SearchPostsReq{Page: req.Offset, Limit: req.Limit}
|
||||
in := &communitypb.SearchPostsReq{Offset: req.Offset, Limit: req.Limit}
|
||||
if req.Tags != "" {
|
||||
in.Tags = strings.Split(req.Tags, ",")
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (l *ListPostsLogic) ListPosts(req *types.PostListReq) (resp *types.PostList
|
||||
for _, p := range posts.GetPosts() {
|
||||
liked := false
|
||||
if uid > 0 {
|
||||
likes, e := l.svcCtx.CommunityRpc.SearchPostLikes(l.ctx, &communitypb.SearchPostLikesReq{Page: 0, Limit: 1, PostId: &p.Id, UserId: &uid})
|
||||
likes, e := l.svcCtx.CommunityRpc.SearchPostLikes(l.ctx, &communitypb.SearchPostLikesReq{Offset: 0, Limit: 1, PostId: &p.Id, UserId: &uid})
|
||||
liked = e == nil && len(likes.GetPostLikes()) > 0
|
||||
}
|
||||
items = append(items, mapPost(l.ctx, l.svcCtx, p, liked))
|
||||
|
||||
Reference in New Issue
Block a user