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,20 +2,24 @@
namespace base\common\command\scheme;
use think\console\Command;
use app\common\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Input\Option;
use think\console\Input\Argument;
use think\console\Output;
use think\facade\Db;
use think\facade\Config;
use app\common\service\scheme\DbToSchemeService;
use app\common\service\scheme\SchemeToDbService;
use app\common\service\scheme\attribute\Table;
use ReflectionClass;
class Make extends Command
{
protected function configure()
{
parent::configure();
$this->setName('scheme:make')
->addOption('table', 't', Option::VALUE_REQUIRED, "The table name (without prefix)")
->addArgument('table', Argument::OPTIONAL, "The table name (without prefix)")
@@ -27,7 +31,7 @@ class Make extends Command
$table = $input->getOption('table') ?: $input->getArgument('table');
$service = new DbToSchemeService();
$compare = new SchemeToDbService();
$tables = [];
if ($table) {
$tables[] = $table;
@@ -39,7 +43,7 @@ class Make extends Command
$connection = Config::get('database.default', 'mysql');
$prefix = Config::get('database.connections.' . $connection . '.prefix', '');
$backupPrefix = Config::get('scheme.backup_prefix', 'backup');
foreach ($allTables as $t) {
if ($this->isBackupTable($t, $prefix, $backupPrefix)) {
continue;
@@ -50,7 +54,7 @@ class Make extends Command
if ($prefix && str_starts_with($t, $prefix)) {
$shortName = substr($t, strlen($prefix));
}
if (!in_array($shortName, $config) && !in_array($t, $config)) {
$tables[] = $shortName;
}
@@ -61,7 +65,7 @@ class Make extends Command
$output->writeln("Processing table: $t");
try {
$code = $service->generate($t);
// 提取类名以确定文件名
if (preg_match('/class\s+(\w+)/', $code, $matches)) {
$className = $matches[1];
@@ -78,17 +82,17 @@ class Make extends Command
}
}
}
// 确保目录存在
if (!is_dir(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
file_put_contents($path, $code);
$output->writeln("<info>Generated: $path</info>");
}
} catch (\Exception $e) {
$output->writeln("<error>Error processing $t: " . $e->getMessage() . "</error>");
$output->error("Error processing $t: " . $e->getMessage());
}
}
}