feat(console): add CRUD support and update usage warning

Extend the console command configuration to include 'crud' alongside the existing 'curd'
command for better supporting CRUD operations in the application. Additionally, update the
user warning message to recommend using the visual generation features for CRUD functionality
within the system, indicating that further support for command-line CURD/CRUD will be phased out.Adjust the related fields handling in the Curd command class methods to use 'onlyField' for
consistency with the singular form of field manipulations, and ensure correct method parameter
names are reflected in the relation setup.
This commit is contained in:
wolfcode
2024-08-16 11:32:13 +08:00
parent ed0e14cb32
commit 6dfdffeab9
2 changed files with 5 additions and 4 deletions

View File

@@ -47,8 +47,8 @@ class Curd extends Command
protected function execute(Input $input, Output $output)
{
// CliEcho::error('请使用系统自带的 CURD 可视化生成功能(关联功能增加中~),命令行 curd 功能不再维护!');
// return false;
CliEcho::warn('请优先使用系统自带的 CURD/CRUD 可视化生成功能(关联功能增加中~),命令行 CURD/CRUD 功能将逐步下线!');
CliEcho::notice(PHP_EOL);
$table = $input->getOption('table');
$controllerFilename = $input->getOption('controllerFilename');
@@ -83,7 +83,7 @@ class Curd extends Command
'foreignKey' => $foreignKey[$key] ?? null,
'primaryKey' => $primaryKey[$key] ?? null,
'modelFilename' => $relationModelFilename[$key] ?? null,
'onlyFileds' => isset($relationOnlyFields[$key]) ? explode(",", $relationOnlyFields[$key]) : [],
'onlyField' => isset($relationOnlyFields[$key]) ? explode(",", $relationOnlyFields[$key]) : [],
'relationBindSelect' => $relationBindSelect[$key] ?? null,
];
}
@@ -114,7 +114,7 @@ class Curd extends Command
!empty($ignoreFields) && $build = $build->setIgnoreFields($ignoreFields);
foreach ($relations as $relation) {
$build = $build->setRelation($relation['table'], $relation['foreignKey'], $relation['primaryKey'], $relation['modelFilename'], $relation['onlyFileds'], $relation['relationBindSelect']);
$build = $build->setRelation($relation['table'], $relation['foreignKey'], $relation['primaryKey'], $relation['modelFilename'], $relation['onlyField'], $relation['relationBindSelect']);
}
$build = $build->render();

View File

@@ -7,6 +7,7 @@ return [
// 指令定义
'commands' => [
'curd' => 'app\common\command\Curd',
'crud' => 'app\common\command\Curd',
'node' => 'app\common\command\Node',
],