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 ToolsDbQueryBase extends Command
{
protected function configure()
{
parent::configure();
$this->setName('tools:db:query')
->setDescription('执行 SQL 查询语句SELECT并显示结果')
->addArgument('sql', null, 'SQL 查询语句')
->addOption('format', null, Option::VALUE_OPTIONAL, '输出格式可选值table默认、json', 'table')
->addOption('limit', null, Option::VALUE_OPTIONAL, '限制显示行数')
->addOption('connection', null, Option::VALUE_OPTIONAL, '指定数据库连接配置')
->addOption('help', 'h', Option::VALUE_NONE, '显示帮助信息');
@@ -25,12 +26,12 @@ class ToolsDbQueryBase extends Command
protected function execute($input, $output)
{
if ($input->getOption('help')) {
$service = new ToolsDbServiceBase();
$service = new DbService();
$service->showHelp('tools:db:query', $output);
return;
}
$service = new ToolsDbServiceBase();
$service = new DbService();
if (!$service->checkDebugMode($output)) {
return;
@@ -45,7 +46,6 @@ class ToolsDbQueryBase extends Command
return;
}
$format = $input->getOption('format') ?: 'table';
$limit = $input->getOption('limit');
if (!preg_match('/^\s*SELECT\s+/i', $sql)) {
@@ -69,22 +69,16 @@ class ToolsDbQueryBase extends Command
$query = array_slice($query, 0, (int)$limit);
}
$output->writeln('');
if ($format === 'json') {
$service->formatJsonOutput($query, $output);
} else {
$service->formatTableOutput($query, $output);
}
$output->writeln('');
$output->writeln('<info>查询成功</info>');
$output->newLine();
$service->formatTableOutput($query, $output);
$output->newLine();
$output->info('查询成功');
$output->writeln('影响行数:' . count($query));
$output->writeln('执行时间:' . $executionTime . 'ms');
$output->writeln('');
$output->newLine();
} catch (\Exception $e) {
$output->error('查询失败:' . $e->getMessage());
return;
}
}
}
}