diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 662cbb061..37320f5cc 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -855,11 +855,13 @@ class SystemCrudServices extends BaseServices $validate = app()->make(Validate::class); $validate->setFilePathName($filePath['validate'] ?? '')->setbasePath($basePath)->handle($tableName, [ 'field' => $options['fromField'], + 'modelName' => $options['modelName'] ?? '', ]); //生成控制器 $controller = app()->make(Controller::class); $controller->setFilePathName($filePath['controller'] ?? '')->setbasePath($basePath)->handle($tableName, [ 'usePath' => $service->getUsePath(), + 'modelName' => $options['modelName'] ?? '', 'validateName' => '\\' . str_replace('/', '\\', $validate->getUsePath()) . 'Validate::class', 'field' => array_column($options['fromField'], 'field'), ]); diff --git a/crmeb/crmeb/services/crud/Controller.php b/crmeb/crmeb/services/crud/Controller.php index 7724c69b4..1b25d1a6c 100644 --- a/crmeb/crmeb/services/crud/Controller.php +++ b/crmeb/crmeb/services/crud/Controller.php @@ -90,6 +90,7 @@ class Controller extends Make [$className, $contentController] = $this->getStubContent($name, 'controller'); + $this->value['modelName'] = $options['modelName'] ?? $name; $this->value['nameCamel'] = Str::studly($name); $this->value['name'] = $className; $this->value['path'] = $this->getfolderPath($path); diff --git a/crmeb/crmeb/services/crud/Model.php b/crmeb/crmeb/services/crud/Model.php index d68aa4510..5795dd7cb 100644 --- a/crmeb/crmeb/services/crud/Model.php +++ b/crmeb/crmeb/services/crud/Model.php @@ -56,6 +56,7 @@ class Model extends Make $this->value['use-php'] = "use think\model\concern\SoftDelete;\n"; $this->value['content-php'] = $this->tab() . "use SoftDelete;\n"; } + $this->value['modelName'] = $options['modelName'] ?? $name; return parent::handle($name, $options); } diff --git a/crmeb/crmeb/services/crud/Validate.php b/crmeb/crmeb/services/crud/Validate.php index 321c7934f..bac961958 100644 --- a/crmeb/crmeb/services/crud/Validate.php +++ b/crmeb/crmeb/services/crud/Validate.php @@ -51,6 +51,7 @@ class Validate extends Make [$rule, $message] = $this->getRuleContent($options['field']); $this->value['rule-php'] = $rule; $this->value['message-php'] = $message; + $this->value['modelName'] = $options['modelName'] ?? $name; return parent::handle($name, $options); // TODO: Change the autogenerated stub } diff --git a/crmeb/crmeb/services/crud/stubs/controller/crudController.stub b/crmeb/crmeb/services/crud/stubs/controller/crudController.stub index 81fdaad43..5395b03c8 100644 --- a/crmeb/crmeb/services/crud/stubs/controller/crudController.stub +++ b/crmeb/crmeb/services/crud/stubs/controller/crudController.stub @@ -12,6 +12,7 @@ */ /** + * {%modelName%} * @author crud自动生成代码 * @date {%time%} */ diff --git a/crmeb/crmeb/services/crud/stubs/dao/crudDao.stub b/crmeb/crmeb/services/crud/stubs/dao/crudDao.stub index c3a64c8c4..fb580bac8 100644 --- a/crmeb/crmeb/services/crud/stubs/dao/crudDao.stub +++ b/crmeb/crmeb/services/crud/stubs/dao/crudDao.stub @@ -12,6 +12,7 @@ */ /** + * {%modelName%} * @author crud自动生成代码 * @date {%time%} */ diff --git a/crmeb/crmeb/services/crud/stubs/model/crudModel.stub b/crmeb/crmeb/services/crud/stubs/model/crudModel.stub index bea6353df..29eaf0230 100644 --- a/crmeb/crmeb/services/crud/stubs/model/crudModel.stub +++ b/crmeb/crmeb/services/crud/stubs/model/crudModel.stub @@ -12,6 +12,7 @@ */ /** + * {%modelName%} * @author crud自动生成代码 * @date {%time%} */ diff --git a/crmeb/crmeb/services/crud/stubs/model/getattr.stub b/crmeb/crmeb/services/crud/stubs/model/getattr.stub new file mode 100644 index 000000000..c445665cb --- /dev/null +++ b/crmeb/crmeb/services/crud/stubs/model/getattr.stub @@ -0,0 +1,4 @@ + public function get{%field%}Attr($value) + { +{%content-php%} + } diff --git a/crmeb/crmeb/services/crud/stubs/service/crudService.stub b/crmeb/crmeb/services/crud/stubs/service/crudService.stub index 6a3570bd1..d3917708a 100644 --- a/crmeb/crmeb/services/crud/stubs/service/crudService.stub +++ b/crmeb/crmeb/services/crud/stubs/service/crudService.stub @@ -12,6 +12,7 @@ */ /** + * {%modelName%} * @author crud自动生成代码 * @date {%time%} */ @@ -23,7 +24,6 @@ use think\exception\ValidateException; {%use-php%} /** - * {%modelName%} * Class CrudService * @date {%date%} * @package app\services\crud{%path%} diff --git a/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub b/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub index b77ce6a09..a26cc17a9 100644 --- a/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub +++ b/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub @@ -12,6 +12,7 @@ */ /** + * {%modelName%} * @author crud自动生成代码 * @date {%time%} */