mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 10:32:48 +08:00
feat: 发布智能体版
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user