From 6dfdffeab95ea14abdcb73da6c63cb8eb55c2c67 Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:32:13 +0800 Subject: [PATCH] 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. --- app/common/command/Curd.php | 8 ++++---- config/console.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/common/command/Curd.php b/app/common/command/Curd.php index 4047662..febfbca 100644 --- a/app/common/command/Curd.php +++ b/app/common/command/Curd.php @@ -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(); diff --git a/config/console.php b/config/console.php index 8e97dd2..7a1bfb9 100644 --- a/config/console.php +++ b/config/console.php @@ -7,6 +7,7 @@ return [ // 指令定义 'commands' => [ 'curd' => 'app\common\command\Curd', + 'crud' => 'app\common\command\Curd', 'node' => 'app\common\command\Node', ],