update:更新获取方法
This commit is contained in:
parent
96751d6974
commit
f301f149fb
@ -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([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user