fix: 统一分页请求的 offset 语义
This commit is contained in:
@@ -29,14 +29,13 @@ func NewListGamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListGam
|
||||
}
|
||||
|
||||
func (l *ListGamesLogic) ListGames(req *types.PageReq) (resp *types.GameListResp, err error) {
|
||||
page := req.Offset
|
||||
if req.Limit > 0 {
|
||||
page = req.Offset/req.Limit + 1
|
||||
if req.Limit <= 0 {
|
||||
req.Limit = 20
|
||||
}
|
||||
|
||||
all, err := l.svcCtx.GameRpc.SearchGames(l.ctx, &pb.SearchGamesReq{
|
||||
Page: page,
|
||||
Limit: req.Limit,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("ListGames err:%v", err)
|
||||
@@ -56,8 +55,8 @@ func (l *ListGamesLogic) ListGames(req *types.PageReq) (resp *types.GameListResp
|
||||
Items: list,
|
||||
Meta: types.PageMeta{
|
||||
Total: 0,
|
||||
Offset: req.Offset + 1,
|
||||
Limit: 20,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
},
|
||||
}, nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user