add:新增请求过滤空值方法

This commit is contained in:
JaguarJack
2021-01-17 09:39:18 +08:00
parent d4ec2d104f
commit 849493eea2
8 changed files with 127 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ namespace catcher\base;
use app\Request;
use catcher\exceptions\FailedException;
use catcher\exceptions\ValidateFailedException;
use think\App;
use catcher\Utils;
class CatchRequest extends Request
{
@@ -89,4 +89,22 @@ class CatchRequest extends Request
return parent::post($name, $default, $filter); // TODO: Change the autogenerated stub
}
/**
* 过滤空字段
*
* @time 2021年01月16日
* @return $this
*/
public function filterEmptyField(): CatchRequest
{
if ($this->isGet()) {
$this->get = Utils::filterEmptyValue($this->get);
} elseif ($this->isPost()) {
$this->post = Utils::filterEmptyValue($this->post);
} else {
$this->put = Utils::filterEmptyValue($this->put);
}
return $this;
}
}