diff --git a/app/common/controller/BaseController.php b/app/common/controller/BaseController.php index b13404f..4432c0f 100644 --- a/app/common/controller/BaseController.php +++ b/app/common/controller/BaseController.php @@ -4,10 +4,12 @@ namespace app\common\controller; use app\common\library\Auth; use app\common\library\token\TokenExpirationException; +use app\exception\MyBusinessException; +use support\exception\BusinessException; use support\Request; use HttpResponseException; use support\Response; -abstract class BaseController +class BaseController { /** * 无需登录的方法 @@ -189,7 +191,7 @@ abstract class BaseController 'time' => time(), $dataKey => $data, ]; - throw new \app\exception\HttpResponseException(json($result)); + throw new MyBusinessException(json_encode($result)); } public function ApiDataReturn($data) diff --git a/app/exception/HttpResponseException.php b/app/exception/HttpResponseException.php deleted file mode 100644 index a576e45..0000000 --- a/app/exception/HttpResponseException.php +++ /dev/null @@ -1,22 +0,0 @@ -response = $response; - } - - // 获取响应对象 - public function getResponse() - { - return $this->response; - } -} diff --git a/app/exception/MyBusinessException.php b/app/exception/MyBusinessException.php new file mode 100644 index 0000000..52b0cf3 --- /dev/null +++ b/app/exception/MyBusinessException.php @@ -0,0 +1,14 @@ + 'application/json'], $this->getMessage()); + } +}