feat: 发布智能体版

This commit is contained in:
augushong
2026-03-26 20:22:34 +08:00
parent 7ee9e102a5
commit 8cc08bcb8c
138 changed files with 7964 additions and 660 deletions

View File

@@ -2,8 +2,8 @@
namespace base\common\command\tools\db;
use base\common\service\ToolsDbServiceBase;
use think\console\Command;
use app\common\service\tools\DbService;
use app\common\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
@@ -13,10 +13,11 @@ class ToolsDbExecuteBase extends Command
{
protected function configure()
{
parent::configure();
$this->setName('tools:db:execute')
->setDescription('执行 SQL 非查询语句INSERT/UPDATE/DELETE')
->addArgument('sql', null, 'SQL 执行语句')
->addOption('force', null, Option::VALUE_NONE, '跳过确认直接执行')
->addOption('transaction', null, Option::VALUE_NONE, '在事务中执行(失败自动回滚)')
->addOption('connection', null, Option::VALUE_OPTIONAL, '指定数据库连接配置')
->addOption('help', 'h', Option::VALUE_NONE, '显示帮助信息');
@@ -25,12 +26,12 @@ class ToolsDbExecuteBase extends Command
protected function execute($input, $output)
{
if ($input->getOption('help')) {
$service = new ToolsDbServiceBase();
$service = new DbService();
$service->showHelp('tools:db:execute', $output);
return;
}
$service = new ToolsDbServiceBase();
$service = new DbService();
if (!$service->checkDebugMode($output)) {
return;
@@ -45,7 +46,6 @@ class ToolsDbExecuteBase extends Command
return;
}
$force = $input->getOption('force');
$useTransaction = $input->getOption('transaction');
if (preg_match('/^\s*SELECT\s+/i', $sql)) {
@@ -53,17 +53,14 @@ class ToolsDbExecuteBase extends Command
return;
}
$output->writeln('');
$output->writeln('<comment>准备执行的 SQL</comment>');
$output->newLine();
$output->comment('准备执行的 SQL');
$output->writeln($sql);
$output->writeln('');
$output->newLine();
if (!$force) {
$confirm = $output->confirm($input, '<question>确定要执行此 SQL 语句吗?</question> ');
if (!$confirm) {
$output->writeln('<comment>操作已取消</comment>');
return;
}
if (!$output->confirm($input, '确定要执行此 SQL 语句吗?', true)) {
$output->comment('已取消。');
return;
}
try {
@@ -85,19 +82,19 @@ class ToolsDbExecuteBase extends Command
$endTime = microtime(true);
$executionTime = round(($endTime - $startTime) * 1000, 2);
$output->writeln('');
$output->writeln('<info>执行成功</info>');
$output->newLine();
$output->info('执行成功');
$output->writeln('影响行数:' . $affectedRows);
$output->writeln('执行时间:' . $executionTime . 'ms');
$output->writeln('');
$output->newLine();
} catch (\Exception $e) {
$output->writeln('');
$output->newLine();
$output->error('执行失败:' . $e->getMessage());
if ($useTransaction) {
$output->writeln('<comment>事务已回滚</comment>');
$output->comment('事务已回滚');
}
$output->writeln('');
$output->newLine();
return;
}
}
}
}