diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 43210167fde3f3096bf4b1bb2edd28c608e9bfc6..40c2b89535d2305a89a3ba6c490d9ace55948aa7 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');