fix: 游戏列表按分页语义转换 offset

This commit is contained in:
zetaloop
2026-04-04 07:44:24 +08:00
parent f9cd65d809
commit 4bff651f78
@@ -29,9 +29,13 @@ func NewListGamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListGam
} }
func (l *ListGamesLogic) ListGames(req *types.PageReq) (resp *types.GameListResp, err error) { func (l *ListGamesLogic) ListGames(req *types.PageReq) (resp *types.GameListResp, err error) {
// todo: add your logic here and delete this line page := req.Offset
if req.Limit > 0 {
page = req.Offset/req.Limit + 1
}
all, err := l.svcCtx.GameRpc.SearchGames(l.ctx, &pb.SearchGamesReq{ all, err := l.svcCtx.GameRpc.SearchGames(l.ctx, &pb.SearchGamesReq{
Page: req.Offset, Page: page,
Limit: req.Limit, Limit: req.Limit,
}) })
if err != nil { if err != nil {