diff --git a/application/api/controller/Image.php b/application/api/controller/Image.php index 2076e37e..c1898f6f 100644 --- a/application/api/controller/Image.php +++ b/application/api/controller/Image.php @@ -26,15 +26,15 @@ class Image extends Base public function find() { - $id = $this->param('id'); + $id = $this->request->request('id'); $image = $this->model->where(['id' => $id])->find(); $this->response('success', $this->parseData($image)); } public function items() { - $page = $this->param('page', 1); - $rows = $this->param('rows', 20); + $page = $this->request->request('page', 1); + $rows = $this->request->request('rows', 20); $images = $this->model->paginate(null, false, [ 'page' => $page, 'list_rows' => $rows, @@ -49,7 +49,7 @@ class Image extends Base public function delete() { $user = new User(); - $data = str_replace(',', ',', $this->param('id')); + $data = str_replace(',', ',', $this->request->request('id')); if (strpos($data, ',') !== false) { $data = explode(',', $data); } diff --git a/application/common/traits/Core.php b/application/common/traits/Core.php index f32be611..7ea8674a 100644 --- a/application/common/traits/Core.php +++ b/application/common/traits/Core.php @@ -67,32 +67,4 @@ trait Core throw new HttpResponseException($response); } - - /** - * 获取客户端传过来的参数 - * - * @param string $name 参数名 - * @param null $default 默认值 - * @param string $filter 过滤方法 - * - * @return mixed|string - */ - protected function param($name = '', $default = null, $filter = '') - { - $data = request()->param($name, $default, $filter); - - if (is_array($data)) { - foreach ($data as &$value) { - if (is_string($value)) { - $value = trim($value); - } - } - } - - if (is_string($data)) { - return trim($data); - } - - return $data; - } } diff --git a/application/http/middleware/ApiAuthenticate.php b/application/http/middleware/ApiAuthenticate.php index 3dfe005b..d45ad599 100644 --- a/application/http/middleware/ApiAuthenticate.php +++ b/application/http/middleware/ApiAuthenticate.php @@ -27,7 +27,7 @@ class ApiAuthenticate } $user = null; - $token = $request->header('token', $this->param('token')); + $token = $request->header('token', $request->request('token')); if ($token) { if (!$user = Users::get(['token' => $token])) { $this->response('认证失败', [], 401);