From f301f149fbb54c491828a72ddb5c549157b98ca8 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sun, 6 Sep 2020 10:58:13 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E6=9B=B4=E6=96=B0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/permissions/controller/Permission.php | 16 +++++++++------- extend/catcher/library/ParseClass.php | 15 +++++++++++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/catch/permissions/controller/Permission.php b/catch/permissions/controller/Permission.php index e1b3d0b..84f5721 100644 --- a/catch/permissions/controller/Permission.php +++ b/catch/permissions/controller/Permission.php @@ -99,10 +99,11 @@ class Permission extends CatchController { $permission = $this->permissions->findBy($id); - if ($permission->parent_id) { + $params = $request->param(); + // 按钮类型 + if ($params['type'] == Permissions::BTN_TYPE && $permission->parent_id) { $parentPermission = $this->permissions->findBy($permission->parent_id); - $params = $request->param(); $permissionMark = $params['permission_mark']; if ($parentPermission->parent_id) { if (Str::contains($parentPermission->permission_mark, '@')) { @@ -204,14 +205,15 @@ class Permission extends CatchController public function getMethods($id, ParseClass $parseClass) { $permission = Permissions::where('id', $id)->find(); - $module = $permission->module; - $controller = explode('@', $permission->permission_mark)[0]; - $methods = $parseClass->setModule('catch')->setRule($module, $controller)->onlySelfMethods(); - - return CatchResponse::success($methods); + try { + $methods = $parseClass->setModule('catch')->setRule($module, $controller)->onlySelfMethods(); + return CatchResponse::success($methods); + }catch (\Exception $e) { + return CatchResponse::success([]); + } } } diff --git a/extend/catcher/library/ParseClass.php b/extend/catcher/library/ParseClass.php index 30c9ada..3897793 100644 --- a/extend/catcher/library/ParseClass.php +++ b/extend/catcher/library/ParseClass.php @@ -2,6 +2,8 @@ namespace catcher\library; +use think\exception\ClassNotFoundException; + class ParseClass { protected $namespace; @@ -74,18 +76,23 @@ class ParseClass return $methods; } + /** - * 获取 CLASS + * 获取class * - * @return \ReflectionClass + * @time 2020年09月06日 * @throws \ReflectionException + * @return \ReflectionClass */ public function getClass() { + $class = $this->namespace . $this->module . '\\controller\\'. ucfirst($this->controller); - return new \ReflectionClass($this->namespace . $this->module . '\\controller\\'. + if (class_exists($class)) { + return new \ReflectionClass($class); + } - ucfirst($this->controller)); + throw new ClassNotFoundException($this->controller . ' not found'); } /**