mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-04 09:02:49 +08:00
feat: 发布智能体版
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace base\common\command\admin\role;
|
||||
|
||||
use app\admin\model\SystemAuth;
|
||||
use app\common\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
|
||||
class AdminRoleCreateBase extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this->setName('admin:role:create')
|
||||
->addOption('title', null, Option::VALUE_REQUIRED, '角色名称')
|
||||
->addOption('remark', null, Option::VALUE_OPTIONAL, '角色备注')
|
||||
->setDescription('创建角色');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$title = $input->getOption('title');
|
||||
$remark = $input->getOption('remark');
|
||||
|
||||
if (empty($title)) {
|
||||
$output->error('角色名称不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$auth = new SystemAuth();
|
||||
$auth->title = $title;
|
||||
$auth->remark = $remark ?? '';
|
||||
$auth->sort = 0;
|
||||
$auth->status = 1;
|
||||
$auth->save();
|
||||
|
||||
$output->info('角色创建成功');
|
||||
$output->info('角色ID: ' . $auth->id);
|
||||
$output->info('角色名称: ' . $auth->title);
|
||||
} catch (\Throwable $e) {
|
||||
$output->error('创建角色失败: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user