mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 02:22:48 +08:00
feat: 发布智能体版
This commit is contained in:
65
extend/base/common/command/admin/role/AdminRoleInfoBase.php
Normal file
65
extend/base/common/command/admin/role/AdminRoleInfoBase.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace base\common\command\admin\role;
|
||||
|
||||
use app\admin\model\SystemAuth;
|
||||
use app\admin\model\SystemAuthNode;
|
||||
use app\common\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
|
||||
class AdminRoleInfoBase extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user