fix: 统一分页请求的 offset 语义

This commit is contained in:
zetaloop
2026-04-07 17:56:38 +08:00
parent 424b2b1cca
commit d153b5cf51
46 changed files with 334 additions and 346 deletions
@@ -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