From d88b571fc310ade7733d3ad06034ee6c0bccff72 Mon Sep 17 00:00:00 2001 From: zhaoxiang Date: Mon, 1 Jul 2019 11:39:21 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=9B=A0=E4=B8=BAPHP=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E5=BC=BA=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E8=80=83=E8=99=91=E5=88=B0=E6=A1=86=E6=9E=B6=E7=9A=84=E9=80=9A?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=BF=87=E6=BB=A4=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/http/middleware/RequestFilter.php | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/application/http/middleware/RequestFilter.php b/application/http/middleware/RequestFilter.php index 93c6801..18059c5 100644 --- a/application/http/middleware/RequestFilter.php +++ b/application/http/middleware/RequestFilter.php @@ -7,13 +7,12 @@ use app\util\DataType; use app\util\ReturnCode; use think\facade\Cache; use think\facade\Validate; -use think\Request as re; class RequestFilter { /** - * 接口请求字段过滤 + * 接口请求字段过滤【只验证数据的合法性,不再过滤数据】 * @param \think\facade\Request $request * @param \Closure $next * @return mixed|\think\response\Json @@ -22,17 +21,14 @@ class RequestFilter { public function handle($request, \Closure $next) { $apiInfo = $request->API_CONF_DETAIL; $data = $request->param(); - $method = $request->method(); $has = Cache::has('RequestFields:NewRule:' . $apiInfo['hash']); if ($has) { $newRule = cache('RequestFields:NewRule:' . $apiInfo['hash']); - $rule = cache('RequestFields:Rule:' . $apiInfo['hash']); } else { $rule = AdminFields::all(['hash' => $apiInfo['hash'], 'type' => 0]); $newRule = $this->buildValidateRule($rule); cache('RequestFields:NewRule:' . $apiInfo['hash'], $newRule); - cache('RequestFields:Rule:' . $apiInfo['hash'], $rule); } if ($newRule) { @@ -42,30 +38,6 @@ class RequestFilter { } } - $newData = []; - foreach ($rule as $item) { - $newData[$item['field_name']] = isset($data[$item['field_name']]) ? $data[$item['field_name']] : ''; - if (!$item['is_must'] && $item['default'] !== '' && !isset($data[$item['field_name']])) { - $newData[$item['field_name']] = $item['default']; - } - } - - /** - * TODO::等待研究没有测试通过 - */ - switch ($method) { - case 'GET': - (new re())->withGet($newData); - break; - case 'POST': - (new re())->withPost($newData); - break; - case 'DELETE': - case 'PUT': - (new re())->withInput($newData); - break; - } - return $next($request); }