修改modulejson信息

This commit is contained in:
JaguarJack 2020-07-03 21:24:42 +08:00
parent 1abcc5045f
commit fda520bad3
7 changed files with 53 additions and 19 deletions

View File

@ -1,7 +1,8 @@
{ {
"name": "登陆", "name": "登陆",
"alias": "login", "alias": "login",
"description": "", "description": "login 模块",
"version": "1.0.0",
"keywords": [], "keywords": [],
"order": 1, "order": 1,
"services": [ "services": [

View File

@ -92,7 +92,7 @@ class Permission extends CatchController
// 如果是父分类需要更新所有子分类的模块 // 如果是父分类需要更新所有子分类的模块
if (!$permission->parent_id) { if (!$permission->parent_id) {
$this->permissions->updateBy($permission->parent_id, [ $this->permissions->updateBy($permission->id, [
'module' => $permission->module, 'module' => $permission->module,
], 'parent_id'); ], 'parent_id');
} }

View File

@ -1,7 +1,8 @@
{ {
"name": "权限管理", "name": "权限管理",
"alias": "permissions", "alias": "permissions",
"description": "", "description": "全县管理模块",
"version": "1.0.0",
"keywords": [], "keywords": [],
"order": 2, "order": 2,
"services": [ "services": [

View File

@ -1,14 +1,15 @@
{ {
"name": "系统管理", "name": "系统管理",
"alias": "system", "alias": "system",
"description": "", "description": "系统管理模块",
"keywords": [], "version": "1.0.0",
"order": 2, "keywords": [],
"services": [ "order": 2,
"catchAdmin\\system\\SystemService" "services": [
], "\\catchAdmin\\system\\SystemService"
"aliases": {}, ],
"files": [], "aliases": [],
"requires": [], "files": [],
"enable": true "requires": [],
"enable": true
} }

View File

@ -2,6 +2,7 @@
"name": "微信管理", "name": "微信管理",
"alias": "wechat", "alias": "wechat",
"description": "catchadmin 微信管理模块", "description": "catchadmin 微信管理模块",
"version": "1.0.0",
"keywords": [ "keywords": [
"wechat", "wechat",
"module" "module"

View File

@ -16,6 +16,16 @@ class CreateModuleCommand extends Command
protected $stubDir; protected $stubDir;
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $description;
protected $namespaces; protected $namespaces;
protected function configure() protected function configure()
@ -30,6 +40,21 @@ class CreateModuleCommand extends Command
try { try {
$this->module = strtolower($input->getArgument('module')); $this->module = strtolower($input->getArgument('module'));
$this->name = $output->ask($input, '请输入模块中文名称');
if (!$this->name) {
while (true) {
$this->name = $output->ask($input, '请输入模块中文名称');
if ($this->name) {
break;
}
}
}
$this->description = $output->ask($input, '请输入模块描述');
$this->description = $this->description ? : '';
$this->moduleDir = CatchAdmin::moduleDirectory($this->module); $this->moduleDir = CatchAdmin::moduleDirectory($this->module);
$this->stubDir = __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR; $this->stubDir = __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR;
@ -135,7 +160,9 @@ class CreateModuleCommand extends Command
{ {
$service = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'service.stub'); $service = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'service.stub');
$content = str_replace(['{NAMESPACE}', '{SERVICE}'], [substr($this->namespaces, 0, -1), ucfirst($this->module) . 'Service'], $service); $content = str_replace(['{NAMESPACE}', '{SERVICE}'],
[substr($this->namespaces, 0, -1),
ucfirst($this->module) . 'Service'], $service);
file_put_contents($this->moduleDir . ucfirst($this->module) . 'Service.php', $content); file_put_contents($this->moduleDir . ucfirst($this->module) . 'Service.php', $content);
@ -151,7 +178,9 @@ class CreateModuleCommand extends Command
{ {
$moduleJson = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'module.stub'); $moduleJson = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'module.stub');
$content = str_replace(['{MODULE}', '{SERVICE}'], [$this->module, '\\\\'. str_replace('\\', '\\\\',$this->namespaces . ucfirst($this->module) . 'Service')], $moduleJson); $content = str_replace(['{NAME}','{DESCRIPTION}','{MODULE}', '{SERVICE}'],
[$this->name, $this->description,
$this->module, '\\\\'. str_replace('\\', '\\\\',$this->namespaces . ucfirst($this->module) . 'Service')], $moduleJson);
file_put_contents($this->moduleDir . 'module.json', $content); file_put_contents($this->moduleDir . 'module.json', $content);
} }

View File

@ -1,7 +1,8 @@
{ {
"name": "", "name": "{NAME}",
"alias": "{MODULE}", "alias": "{MODULE}",
"description": "", "description": "{DESCRIPTION}",
"version": "1.0.0",
"keywords": [], "keywords": [],
"order": 0, "order": 0,
"services": [ "services": [