Ver código fonte

修复Matchexchange-My接口分页参数问题

- 修复当客户端未传per_page字段时,每页条数错误显示为1的问题
- 当protobuf的per_page字段为0时,正确使用默认值20
- 确保分页逻辑符合预期,避免数据显示不完整
AI Assistant 6 meses atrás
pai
commit
e3c07d47f9

+ 7 - 2
app/Module/AppGame/Handler/Matchexchange/MyHandler.php

@@ -47,8 +47,13 @@ class MyHandler extends BaseHandler
             $pageNum = $page ? $page->getPage() : 1;
             $pageSize = $page ? $page->getPerPage() : 20;
 
-            // 限制分页大小,确保不为0
-            $pageSize = max(min($pageSize, 100), 1);
+            // 当per_page为0时使用默认值20(protobuf未传该字段时返回0)
+            if ($pageSize <= 0) {
+                $pageSize = 20;
+            }
+
+            // 限制分页大小
+            $pageSize = min($pageSize, 100);
             $pageNum = max($pageNum, 1);
 
             // 调用服务获取用户订单列表