From 0348fa72dbeec1379b81cbb332eae3db447a2d49 Mon Sep 17 00:00:00 2001 From: Gogs Date: Thu, 6 Feb 2020 18:22:16 +0800 Subject: [PATCH] =?UTF-8?q?curd=E5=91=BD=E4=BB=A4=E6=96=B0=E5=A2=9E-a?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=8E=9F=E6=9D=A5?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=9C=A8admin=E5=BA=94=E7=94=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=B8=80=E9=94=AE=E7=94=9F=E6=88=90CRUD=EF=BC=8C?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=8F=AF=E4=BB=A5=E7=94=A8-a=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=8C=87=E5=AE=9A=E5=85=B6=E4=BB=96=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=90=8D=E7=A7=B0=E3=80=82=E9=80=82=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E5=A4=9A=E5=90=8E=E5=8F=B0=E5=85=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9C=BA=E6=99=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 43210167f..40c2b8953 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -152,6 +152,7 @@ class Crud extends Command $this ->setName('crud') ->addOption('table', 't', Option::VALUE_REQUIRED, 'table name without prefix', null) + ->addOption('module', 'a', Option::VALUE_OPTIONAL, 'app module name', null) ->addOption('controller', 'c', Option::VALUE_OPTIONAL, 'controller name', null) ->addOption('model', 'm', Option::VALUE_OPTIONAL, 'model name', null) ->addOption('fields', 'i', Option::VALUE_OPTIONAL, 'model visible fields', null) @@ -186,6 +187,12 @@ class Crud extends Command protected function execute(Input $input, Output $output) { $adminPath = dirname(__DIR__) . DS; + //应用模块 + $moduleName = $input->getOption('module'); + if (!$moduleName) { + $moduleName='admin'; + } + $modulePath = dirname($adminPath) . DS . $moduleName . DS; //数据库 $db = $input->getOption('db'); //表名 @@ -298,7 +305,6 @@ class Crud extends Command $prefix = Config::get($db . '.prefix'); //模块 - $moduleName = 'admin'; $modelModuleName = $local ? $moduleName : 'common'; $validateModuleName = $local ? $moduleName : 'common'; @@ -393,15 +399,15 @@ class Crud extends Command $lastValue = array_pop($viewArr); $viewArr[] = Loader::parseName($lastValue, 0); array_unshift($viewArr, 'view'); - $viewDir = $adminPath . strtolower(implode(DS, $viewArr)) . DS; + $viewDir = $modulePath . strtolower(implode(DS, $viewArr)) . DS; //最终将生成的文件路径 - $javascriptFile = ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'backend' . DS . $controllerBaseName . '.js'; + $javascriptFile = ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'backend' . DS . $moduleName .DS . $controllerBaseName . '.js'; $addFile = $viewDir . 'add.html'; $editFile = $viewDir . 'edit.html'; $indexFile = $viewDir . 'index.html'; $recyclebinFile = $viewDir . 'recyclebin.html'; - $langFile = $adminPath . 'lang' . DS . Lang::detect() . DS . $controllerBaseName . '.php'; + $langFile = $modulePath . 'lang' . DS . Lang::detect() . DS . $controllerBaseName . '.php'; //是否为删除模式 $delete = $input->getOption('delete'); -- Gitee