Skip to content

Commit ab546fa

Browse files
author
lobtao
committed
update
1 parent 270c1c2 commit ab546fa

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/BaseRpc.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
abstract class BaseRpc {
12+
1213
protected $func;
1314
protected $args;
1415
protected $callback;
@@ -26,9 +27,9 @@ protected function exception_handler($exception) {
2627
if ($exception instanceof RpcException) {
2728
$errMsg = $exception->getMessage();
2829
} else {
29-
if(config('showerror')){
30+
if (config('showerror')) {
3031
$errMsg = $exception->getMessage();
31-
}else{
32+
} else {
3233
$errMsg = '系统异常';
3334
}
3435
}
@@ -41,7 +42,9 @@ protected function exception_handler($exception) {
4142
$msg = sprintf("Trace:%s\nClass: %s\nFile: %s\nLine: %s\n异常描述: %s", $exception->getTraceAsString(), get_class($exception), $exception->getFile(), $exception->getLine(), $exception->getMessage());
4243
if (class_exists('\think\facade\Log')) {
4344
\think\facade\Log::error($msg);
44-
} else {
45+
} else if (class_exists('\workermvc\Log')) {
46+
\workermvc\Log::error($msg);
47+
} else if (is_callable(['\think\Log', 'error'])) {
4548
\think\Log::error($msg);
4649
}
4750

@@ -60,9 +63,9 @@ protected function callFunc($func, $args) {
6063
$params = explode('_', $func, 2);
6164
if (count($params) != 2) throw new RpcException('请求参数错误');
6265

63-
$svname = ucfirst($params[0]);
66+
$svname = ucfirst($params[0]);
6467
$classname = $this->namespace . $svname . 'Service';
65-
$funcname = $params[1];
68+
$funcname = $params[1];
6669
if (!class_exists($classname)) throw new RpcException('' . $classname . '不存在!');
6770

6871
$object = new $classname();
@@ -76,7 +79,7 @@ protected function callFunc($func, $args) {
7679
* ajax返回
7780
* @param $result
7881
* @param $callback
79-
* @return \think\response\Json|\think\response\Jsonp
82+
* @return string
8083
*/
8184
protected function ajaxReturn($result, $callback) {
8285

src/RpcController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class RpcController extends BaseRpc{
1010
* 主方法
1111
* @param $namespace
1212
* @param null $filter
13-
* @return \think\response\Json|\think\response\Jsonp
13+
* @return string
1414
*/
1515
public function handle($namespace, $filter = null) {
1616

0 commit comments

Comments
 (0)