From 9d56033b6d99753f9010d670525859113b074c7a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 17 Jun 2016 16:19:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4Response=E7=B1=BB=E7=9A=84res?= =?UTF-8?q?ult=E6=96=B9=E6=B3=95=20=E6=94=B9=E8=BF=9BJump=E9=87=8C?= =?UTF-8?q?=E9=9D=A2=E7=9A=84result=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Response.php | 19 ------------------- library/traits/controller/Jump.php | 9 ++++++++- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/library/think/Response.php b/library/think/Response.php index 4f8eb0f5..9507b698 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -180,25 +180,6 @@ class Response return $this; } - /** - * 返回封装后的API数据到客户端 - * @access public - * @param mixed $data 要返回的数据 - * @param integer $code 返回的code - * @param string $msg 提示信息 - * @return mixed - */ - public function result($data, $code = 0, $msg = '') - { - $result = [ - 'code' => $code, - 'msg' => $msg, - 'time' => $_SERVER['REQUEST_TIME'], - 'data' => $data, - ]; - return $this->data($result); - } - /** * 设置响应头 * @access public diff --git a/library/traits/controller/Jump.php b/library/traits/controller/Jump.php index 27b55c5d..40f3dacd 100644 --- a/library/traits/controller/Jump.php +++ b/library/traits/controller/Jump.php @@ -99,7 +99,14 @@ trait Jump */ protected function result($data, $code = 0, $msg = '', $type = '') { - return Response::create([], $type)->result($data, $code, $msg); + $result = [ + 'code' => $code, + 'msg' => $msg, + 'time' => $_SERVER['REQUEST_TIME'], + 'data' => $data, + ]; + $type = $type ?: $this->getResponseType(); + return Response::create([], $type)->data($data); } /**