setName('admin:role:info') ->addOption('role-id', null, Option::VALUE_REQUIRED, '角色ID') ->setDescription('查看角色详情'); } protected function execute(Input $input, Output $output) { $roleId = $input->getOption('role-id'); if (empty($roleId)) { $output->error('角色ID不能为空'); return false; } try { $role = SystemAuth::find($roleId); if (empty($role)) { $output->error('角色ID ' . $roleId . ' 不存在'); return false; } $nodes = SystemAuthNode::where('auth_id', $roleId) ->column('node'); $output->info('角色详情'); $output->writeln('================================'); $output->info('角色ID: ' . $role->id); $output->comment('角色名称: ' . $role->title); $output->comment('状态: ' . ($role->status == 1 ? '启用' : '禁用')); $output->comment('排序: ' . $role->sort); if (!empty($role->remark)) { $output->comment('备注: ' . $role->remark); } $output->writeln('--------------------------------'); $output->info('权限节点列表 (' . count($nodes) . ' 个):'); foreach ($nodes as $node) { $output->comment(' - ' . $node); } } catch (\Throwable $e) { $output->error('获取角色详情失败: ' . $e->getMessage()); return false; } return true; } }