feat(admin): add ignoreNode property to skip unnecessary node generation

- Add $ignoreNode property to Goods controller to specify methods to ignore
- Update Node service to check and skip ignored methods during node generation
- This change helps to filter out unnecessary nodes, improving system performance and readability
This commit is contained in:
wolfcode
2024-11-28 10:54:15 +08:00
parent e7f09d9c68
commit 08ea79033c
2 changed files with 12 additions and 0 deletions

View File

@@ -20,6 +20,12 @@ use think\response\Json;
class Goods extends AdminController
{
/**
* 过滤不需要生成的权限节点 默认 CURD 中会自动生成部分节点 可以在此处过滤
* @var array[]
*/
protected array $ignoreNode = ['export'];
public function __construct(App $app)
{
parent::__construct($app);

View File

@@ -67,6 +67,12 @@ class Node
// 遍历读取所有方法的注释的参数信息
foreach ($methods as $method) {
// 忽略的节点
$properties = $reflectionClass->getDefaultProperties();
$ignoreNode = $properties['ignoreNode'] ?? [];
if (!empty($ignoreNode)) if (in_array($method->name, $ignoreNode)) continue;
// 读取NodeAnnotation的注解
$nodeAnnotation = $reader->getMethodAnnotation($method, NodeAnnotation::class);
if (!empty($nodeAnnotation)) {