From ab546fa21fd22c23b50e3010b3ecf3a8db4196b2 Mon Sep 17 00:00:00 2001 From: lobtao Date: Thu, 7 Jun 2018 22:33:40 +0800 Subject: [PATCH] update --- src/BaseRpc.php | 15 +++++++++------ src/RpcController.php | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/BaseRpc.php b/src/BaseRpc.php index 0d21aaa..66594a5 100644 --- a/src/BaseRpc.php +++ b/src/BaseRpc.php @@ -9,6 +9,7 @@ abstract class BaseRpc { + protected $func; protected $args; protected $callback; @@ -26,9 +27,9 @@ protected function exception_handler($exception) { if ($exception instanceof RpcException) { $errMsg = $exception->getMessage(); } else { - if(config('showerror')){ + if (config('showerror')) { $errMsg = $exception->getMessage(); - }else{ + } else { $errMsg = '系统异常'; } } @@ -41,7 +42,9 @@ protected function exception_handler($exception) { $msg = sprintf("Trace:%s\nClass: %s\nFile: %s\nLine: %s\n异常描述: %s", $exception->getTraceAsString(), get_class($exception), $exception->getFile(), $exception->getLine(), $exception->getMessage()); if (class_exists('\think\facade\Log')) { \think\facade\Log::error($msg); - } else { + } else if (class_exists('\workermvc\Log')) { + \workermvc\Log::error($msg); + } else if (is_callable(['\think\Log', 'error'])) { \think\Log::error($msg); } @@ -60,9 +63,9 @@ protected function callFunc($func, $args) { $params = explode('_', $func, 2); if (count($params) != 2) throw new RpcException('请求参数错误'); - $svname = ucfirst($params[0]); + $svname = ucfirst($params[0]); $classname = $this->namespace . $svname . 'Service'; - $funcname = $params[1]; + $funcname = $params[1]; if (!class_exists($classname)) throw new RpcException('类' . $classname . '不存在!'); $object = new $classname(); @@ -76,7 +79,7 @@ protected function callFunc($func, $args) { * ajax返回 * @param $result * @param $callback - * @return \think\response\Json|\think\response\Jsonp + * @return string */ protected function ajaxReturn($result, $callback) { diff --git a/src/RpcController.php b/src/RpcController.php index 59a6a95..04e36e3 100644 --- a/src/RpcController.php +++ b/src/RpcController.php @@ -10,7 +10,7 @@ class RpcController extends BaseRpc{ * 主方法 * @param $namespace * @param null $filter - * @return \think\response\Json|\think\response\Jsonp + * @return string */ public function handle($namespace, $filter = null) {