From 269b100715231c0f02842cf72d04a131b1f1413f Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Sun, 23 Apr 2023 10:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=BA=E9=BB=98=E6=A8=A1=E5=9D=97=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/system/SystemCrudServices.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 99c208b4c..6f0673bc4 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -233,6 +233,7 @@ class SystemCrudServices extends BaseServices $tableComment = $data['tableComment'] ?? $data['menuName']; $tableField = $this->valueReplace($data['tableField']); $filePath = $this->valueReplace($data['filePath']); + $modelName = $data['modelName'] ?? $data['menuName'] ?? $tableName; if ($this->dao->value(['table_name' => $tableName])) { throw new AdminException(500048); @@ -293,7 +294,7 @@ class SystemCrudServices extends BaseServices 'is_header' => $data['pid'] ? 0 : 1, ]; - $res = $this->transaction(function () use ($tableInfo, $filePath, $tableName, $routeName, $data, $dataMenu) { + $res = $this->transaction(function () use ($tableInfo, $modelName, $filePath, $tableName, $routeName, $data, $dataMenu) { $menuInfo = app()->make(SystemMenusServices::class)->save($dataMenu); //写入路由权限 $cateId = app()->make(SystemRouteServices::class)->topCateId('adminapi'); @@ -301,7 +302,7 @@ class SystemCrudServices extends BaseServices [ 'path' => $routeName, 'method' => 'GET', - 'name' => $data['menuName'] . '列表接口', + 'name' => $modelName . '列表接口', 'app_name' => 'adminapi', 'cate_id' => $cateId, 'unique_auth' => '', @@ -310,7 +311,7 @@ class SystemCrudServices extends BaseServices [ 'path' => $routeName . '/create', 'method' => 'GET', - 'name' => $data['menuName'] . '获取创建表单接口', + 'name' => $modelName . '获取创建表单接口', 'app_name' => 'adminapi', 'cate_id' => $cateId, 'unique_auth' => Str::snake($tableName) . '-add', @@ -319,7 +320,7 @@ class SystemCrudServices extends BaseServices [ 'path' => $routeName, 'method' => 'POST', - 'name' => $data['menuName'] . '保存数据接口', + 'name' => $modelName . '保存数据接口', 'app_name' => 'adminapi', 'cate_id' => $cateId, 'unique_auth' => '', @@ -328,7 +329,7 @@ class SystemCrudServices extends BaseServices [ 'path' => $routeName . '//edit', 'method' => 'GET', - 'name' => $data['menuName'] . '获取修改表单接口', + 'name' => $modelName . '获取修改表单接口', 'app_name' => 'adminapi', 'cate_id' => $cateId, 'unique_auth' => '', @@ -337,7 +338,7 @@ class SystemCrudServices extends BaseServices [ 'path' => $routeName . '/', 'method' => 'PUT', - 'name' => $data['menuName'] . '修改数据接口', + 'name' => $modelName . '修改数据接口', 'app_name' => 'adminapi', 'cate_id' => $cateId, 'unique_auth' => '', @@ -346,7 +347,7 @@ class SystemCrudServices extends BaseServices [ 'path' => $routeName . '/', 'method' => 'DELETE', - 'name' => $data['menuName'] . '删除数据接口', + 'name' => $modelName . '删除数据接口', 'app_name' => 'adminapi', 'cate_id' => $cateId, 'unique_auth' => '', @@ -548,7 +549,7 @@ class SystemCrudServices extends BaseServices //生成路由 $route = app()->make(Route::class); $route->setFilePathName($filePath['route'] ?? '')->setbasePath($basePath)->handle($tableName, [ - 'menus' => $options['menuName'], + 'menus' => $options['modelName'] ?? $options['menuName'], 'route' => $routeName ]); //生成前台路由