99
1010
1111abstract 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
0 commit comments