From c776c344261927328d2ff797da44f85ff8e82e41 Mon Sep 17 00:00:00 2001 From: Wisp X <1591788658@qq.com> Date: Sun, 4 Aug 2019 15:38:14 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BC=98=E5=8C=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=8A=B6=E6=80=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Base.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index eec469e4..d7e06f9d 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -32,7 +32,7 @@ class Base extends Controller } if (!$this->config['open_api']) { - $this->response('API is not open yet.', 500); + $this->response('API is not open yet.', [], 500); } $this->token = $this->request->header('token'); @@ -54,11 +54,11 @@ class Base extends Controller protected function auth($token) { if (!$token) { - $this->response('Token does not exist.', 500); + $this->response('Token does not exist.', [], 401); } $this->user = Users::get(['token' => $token]); if (!$this->user) { - $this->response('Authentication failed', 500); + $this->response('Authentication failed', [], 401); } } @@ -66,12 +66,12 @@ class Base extends Controller * 返回数据给客户端并中断输出 * * @param string $msg 提示信息 - * @param null $data 数据 + * @param array $data 数据 * @param int $code 状态码 * * @throws HttpResponseException */ - protected function response($msg = '', $data = null, $code = 200) + protected function response($msg = '', $data = [], $code = 200) { $response = Response::create([ 'code' => $code,