Kaynağa Gözat

fix(request): 修复分页参数验证逻辑

- 移除页码和每页数量的异常抛出逻辑
- 使用 max 函数确保页码最小值为 1
- 使用 min 函数限制每页数量最大值为 100
- 移除对 think\Exception 的依赖引用
runphp 3 hafta önce
ebeveyn
işleme
3046485682
1 değiştirilmiş dosya ile 2 ekleme ve 3 silme
  1. 2 3
      src/Request.php

+ 2 - 3
src/Request.php

@@ -3,7 +3,6 @@ declare(strict_types=1);
 
 namespace SixShop\Core;
 
-use think\Exception;
 use think\helper\Macroable;
 
 /**
@@ -24,8 +23,8 @@ class Request extends \think\Request
     {
         $page = $this->get('page/d', 1);
         $limit = $this->get('limit/d', $this->get('per_page/d', 10));
-        throw_if($page < 1, Exception::class, '页码不能小于1');
-        throw_if($limit < 1 || $limit > 200, Exception::class, '每页数量必须在1-200之间');
+        $page = max($page, 1);
+        $limit = min($limit, 1000);
         return ['page' => $page, 'list_rows' => $limit];
     }
 }