Procházet zdrojové kódy

Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev

From-wh před 2 roky
rodič
revize
b361986c0d
55 změnil soubory, kde provedl 334 přidání a 45 odebrání
  1. 13 7
      crmeb/app/adminapi/controller/v1/setting/SystemCrud.php
  2. 32 1
      crmeb/app/adminapi/controller/v1/setting/SystemMenus.php
  3. 1 1
      crmeb/app/adminapi/route/agent.php
  4. 1 1
      crmeb/app/adminapi/route/app.php
  5. 2 2
      crmeb/app/adminapi/route/cms.php
  6. 1 1
      crmeb/app/adminapi/route/crud.php
  7. 1 1
      crmeb/app/adminapi/route/diy.php
  8. 1 1
      crmeb/app/adminapi/route/export.php
  9. 1 1
      crmeb/app/adminapi/route/file.php
  10. 1 1
      crmeb/app/adminapi/route/finance.php
  11. 1 1
      crmeb/app/adminapi/route/freight.php
  12. 2 2
      crmeb/app/adminapi/route/live.php
  13. 1 1
      crmeb/app/adminapi/route/marketing.php
  14. 1 1
      crmeb/app/adminapi/route/merchant.php
  15. 1 1
      crmeb/app/adminapi/route/notify.php
  16. 2 2
      crmeb/app/adminapi/route/order.php
  17. 1 1
      crmeb/app/adminapi/route/product.php
  18. 1 1
      crmeb/app/adminapi/route/route.php
  19. 1 1
      crmeb/app/adminapi/route/setting.php
  20. 1 1
      crmeb/app/adminapi/route/statistic.php
  21. 2 2
      crmeb/app/adminapi/route/system.php
  22. 1 1
      crmeb/app/adminapi/route/user.php
  23. 3 1
      crmeb/app/dao/system/SystemRouteDao.php
  24. 1 2
      crmeb/app/model/system/SystemCrud.php
  25. 7 6
      crmeb/app/services/system/SystemCrudServices.php
  26. 27 2
      crmeb/app/services/system/SystemRouteServices.php
  27. 52 0
      crmeb/app/services/system/log/SystemFileInfoServices.php
  28. 139 1
      crmeb/crmeb/command/Util.php
  29. 3 0
      crmeb/crmeb/services/crud/Make.php
  30. 1 1
      crmeb/public/admin/index.html
  31. 2 0
      crmeb/public/admin/system_static/css/app.dd63f4d8.css
  32. 1 0
      crmeb/public/admin/system_static/css/chunk-1726de98.822786e8.css
  33. 1 0
      crmeb/public/admin/system_static/css/chunk-249e48fe.7805721e.css
  34. 1 0
      crmeb/public/admin/system_static/css/chunk-26798ce6.d517fe9e.css
  35. 1 0
      crmeb/public/admin/system_static/css/chunk-26da89b4.6c45ae97.css
  36. 1 0
      crmeb/public/admin/system_static/css/chunk-34dc580b.891304a1.css
  37. 1 0
      crmeb/public/admin/system_static/css/chunk-40c51cef.555bc19b.css
  38. 1 0
      crmeb/public/admin/system_static/css/chunk-43146ca4.f2ebd107.css
  39. 1 0
      crmeb/public/admin/system_static/css/chunk-4ca4f1ca.891304a1.css
  40. 1 0
      crmeb/public/admin/system_static/css/chunk-7d90b9a3.cbe02e34.css
  41. 1 0
      crmeb/public/admin/system_static/css/chunk-df056abe.eafdc5e6.css
  42. 1 0
      crmeb/public/admin/system_static/js/app.0d48ca32.js
  43. 7 0
      crmeb/public/admin/system_static/js/chunk-030292b9.9e0b36bd.js
  44. 1 0
      crmeb/public/admin/system_static/js/chunk-1726de98.bc8f762c.js
  45. 1 0
      crmeb/public/admin/system_static/js/chunk-249e48fe.fe0bf709.js
  46. 1 0
      crmeb/public/admin/system_static/js/chunk-26798ce6.e80d9d41.js
  47. 1 0
      crmeb/public/admin/system_static/js/chunk-26da89b4.980ebd6b.js
  48. 1 0
      crmeb/public/admin/system_static/js/chunk-2d0be348.fd22e013.js
  49. 1 0
      crmeb/public/admin/system_static/js/chunk-2d20ebf3.2927745c.js
  50. 1 0
      crmeb/public/admin/system_static/js/chunk-34dc580b.01666f92.js
  51. 1 0
      crmeb/public/admin/system_static/js/chunk-40c51cef.7a0e9cc2.js
  52. 1 0
      crmeb/public/admin/system_static/js/chunk-43146ca4.60b2bd7f.js
  53. 1 0
      crmeb/public/admin/system_static/js/chunk-4ca4f1ca.ed32b44e.js
  54. 1 0
      crmeb/public/admin/system_static/js/chunk-7d90b9a3.b47acfb1.js
  55. 1 0
      crmeb/public/admin/system_static/js/chunk-df056abe.92e5c863.js

+ 13 - 7
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -88,11 +88,13 @@ class SystemCrud extends AuthController
             }
             //收集列表展示数据
             if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete', 'addSoftDelete'])) {
-                $columnField[] = [
-                    'field' => $item['field'],
-                    'name' => $item['table_name'],
-                    'type' => $item['from_type'],
-                ];
+                if (isset($item['primaryKey']) && !$item['primaryKey']) {
+                    $columnField[] = [
+                        'field' => $item['field'],
+                        'name' => $item['table_name'],
+                        'type' => $item['from_type'],
+                    ];
+                }
             }
             //收集表单展示数据
             if ($item['from_type']) {
@@ -252,10 +254,10 @@ class SystemCrud extends AuthController
 
             }
         }
-        
+
         //调整排序
         $makeData = [];
-        $names = ['model', 'dao', 'service', 'controller', 'validate', 'router', 'api', 'pages'];
+        $names = ['controller', 'validate', 'service', 'dao', 'model', 'route', 'router', 'api', 'pages'];
         foreach ($names as $name) {
             if (isset($data[$name])) {
                 $makeData[] = $data[$name];
@@ -272,6 +274,7 @@ class SystemCrud extends AuthController
             $item['default_comment'] = $item['comment'];
             $item['default_default'] = $item['default'];
             $item['is_table'] = !!$item['is_table'];
+            $item['required'] = !!$item['required'];
             $item['primaryKey'] = isset($item['primaryKey']) ? (int)$item['primaryKey'] : 0;
             $info['field']['tableField'][$key] = $item;
         }
@@ -569,6 +572,9 @@ class SystemCrud extends AuthController
             ]
         ];
         foreach ((array)$info->field['tableField'] as $item) {
+            if (isset($item['primaryKey']) && $item['primaryKey']) {
+                continue;
+            }
             if (isset($item['is_table']) && $item['is_table']) {
                 if (in_array($item['from_type'], ['frameImageOne', 'frameImages'])) {
                     $keyName = 'slot';

+ 32 - 1
crmeb/app/adminapi/controller/v1/setting/SystemMenus.php

@@ -130,14 +130,45 @@ class SystemMenus extends AuthController
         }
         $data = [];
 
+        $uniqueAuthAll = $this->services->getColumn(['is_del' => 0, 'is_show' => 1], 'unique_auth');
+        $uniqueAuthAll = array_filter($uniqueAuthAll, function ($item) {
+            return !!$item;
+        });
+        $uniqueAuthAll = array_unique($uniqueAuthAll);
+
+        $uniqueFn = function ($path) use ($uniqueAuthAll) {
+            $attPath = explode('/', $path);
+            $uniqueAuth = '';
+            if ($attPath) {
+                $pathData = [];
+                foreach ($attPath as $vv) {
+                    if (strstr($vv, '<') === false || strstr($vv, '?>') === false) {
+                        $pathData[] = $vv;
+                    }
+                }
+                $uniqueAuth = implode('-', $pathData);
+            }
+
+            if (in_array($uniqueAuth, $uniqueAuthAll)) {
+                $uniqueAuth .= '-' . uniqid();
+            }
+
+            array_push($uniqueAuthAll, $uniqueAuth);
+
+            return $uniqueAuth;
+        };
+
         foreach ($menus as $menu) {
             if (empty($menu['menu_name'])) {
                 return app('json')->fail(400198);
             }
+            if (isset($menu['unique_auth']) && $menu['unique_auth']) {
+                $menu['unique_auth'] = explode('/', $menu['api_url']);
+            }
             $data[] = [
                 'methods' => $menu['method'],
                 'menu_name' => $menu['menu_name'],
-                'unique_auth' => $menu['unique_auth'] ?? '',
+                'unique_auth' => !empty($menu['unique_auth']) ? $menu['unique_auth'] : $uniqueFn($menu['api_url']),
                 'api_url' => $menu['api_url'],
                 'pid' => $menu['path'],
                 'auth_type' => 2,

+ 1 - 1
crmeb/app/adminapi/route/agent.php

@@ -102,4 +102,4 @@ Route::group('agent', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'agent', 'mark_name' => '分销']);
+])->option(['mark' => 'agent', 'mark_name' => '分销模块']);

+ 1 - 1
crmeb/app/adminapi/route/app.php

@@ -136,4 +136,4 @@ Route::group('app', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'app', 'mark_name' => '应用']);
+])->option(['mark' => 'app', 'mark_name' => '应用模块']);

+ 2 - 2
crmeb/app/adminapi/route/cms.php

@@ -33,7 +33,7 @@ Route::group('cms', function () {
         Route::put('cms/relation/:id', 'v1.cms.Article/relation')->name('Relation')->option(['real_name' => '文章关联商品']);
         //取消关联
         Route::put('cms/unrelation/:id', 'v1.cms.Article/unrelation')->name('UnRelation')->option(['real_name' => '取消文章关联商品']);
-    })->option(['parent' => 'cms', 'cate_name' => '文章']);
+    })->option(['parent' => 'cms', 'cate_name' => '文章管理']);
 
     /** 文章分类 */
     Route::group(function () {
@@ -61,4 +61,4 @@ Route::group('cms', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'cms', 'mark_name' => '文章']);
+])->option(['mark' => 'cms', 'mark_name' => '文章模块']);

+ 1 - 1
crmeb/app/adminapi/route/crud.php

@@ -32,4 +32,4 @@ Route::group(function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'crud', 'mark_name' => 'CRUD']);
+])->option(['mark' => 'crud', 'mark_name' => '代码生成']);

+ 1 - 1
crmeb/app/adminapi/route/diy.php

@@ -73,4 +73,4 @@ Route::group('diy', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'diy', 'mark_name' => 'DIY']);
+])->option(['mark' => 'diy', 'mark_name' => '页面装修']);

+ 1 - 1
crmeb/app/adminapi/route/export.php

@@ -43,4 +43,4 @@ Route::group('export', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'export', 'mark_name' => '导出']);
+])->option(['mark' => 'export', 'mark_name' => '数据导出']);

+ 1 - 1
crmeb/app/adminapi/route/file.php

@@ -47,4 +47,4 @@ Route::group('file', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'file', 'mark_name' => '附件']);
+])->option(['mark' => 'file', 'mark_name' => '素材管理']);

+ 1 - 1
crmeb/app/adminapi/route/finance.php

@@ -66,4 +66,4 @@ Route::group('finance', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'finance', 'mark_name' => '财务']);
+])->option(['mark' => 'finance', 'mark_name' => '财务管理']);

+ 1 - 1
crmeb/app/adminapi/route/freight.php

@@ -39,4 +39,4 @@ Route::group('freight', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'freight', 'mark_name' => '物流']);
+])->option(['mark' => 'freight', 'mark_name' => '物流管理']);

+ 2 - 2
crmeb/app/adminapi/route/live.php

@@ -68,11 +68,11 @@ Route::group('live', function () {
         Route::get('room/set_show/:id/:is_show', 'v1.marketing.live.LiveRoom/setShow')->option(['real_name' => '设置直播间是否显示']);
         //同步直播间状态
         Route::get('room/syncRoom', 'v1.marketing.live.LiveRoom/syncRoom')->option(['real_name' => '同步直播间状态']);
-    })->option(['parent' => 'live', 'cate_name' => '播间']);
+    })->option(['parent' => 'live', 'cate_name' => '播间']);
 
 })->middleware([
     \app\http\middleware\AllowOriginMiddleware::class,
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'live', 'mark_name' => '直播']);
+])->option(['mark' => 'live', 'mark_name' => '直播管理']);

+ 1 - 1
crmeb/app/adminapi/route/marketing.php

@@ -203,4 +203,4 @@ Route::group('marketing', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'marketing', 'mark_name' => '营销']);
+])->option(['mark' => 'marketing', 'mark_name' => '营销活动']);

+ 1 - 1
crmeb/app/adminapi/route/merchant.php

@@ -66,4 +66,4 @@ Route::group('merchant', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'merchant', 'mark_name' => '物流']);
+])->option(['mark' => 'merchant', 'mark_name' => '门店核销']);

+ 1 - 1
crmeb/app/adminapi/route/notify.php

@@ -48,4 +48,4 @@ Route::group('notify', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'notify', 'mark_name' => '消息']);
+])->option(['mark' => 'notify', 'mark_name' => '消息通知']);

+ 2 - 2
crmeb/app/adminapi/route/order.php

@@ -110,7 +110,7 @@ Route::group('order', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'order', 'mark_name' => '订单']);
+])->option(['mark' => 'order', 'mark_name' => '订单管理']);
 
 /**
  * 售后 相关路由
@@ -137,4 +137,4 @@ Route::group('refund', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'refund', 'mark_name' => '退款']);
+])->option(['mark' => 'refund', 'mark_name' => '退款订单']);

+ 1 - 1
crmeb/app/adminapi/route/product.php

@@ -118,4 +118,4 @@ Route::group('product', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'product', 'mark_name' => '商品']);
+])->option(['mark' => 'product', 'mark_name' => '商品管理']);

+ 1 - 1
crmeb/app/adminapi/route/route.php

@@ -36,7 +36,7 @@ Route::group(function () {
     Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
     //测试
     Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
-})->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录']);
+})->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录相关']);
 
 /**
  * miss 路由

+ 1 - 1
crmeb/app/adminapi/route/setting.php

@@ -363,4 +363,4 @@ Route::group('setting', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'setting', 'mark_name' => '设置']);
+])->option(['mark' => 'setting', 'mark_name' => '系统设置']);

+ 1 - 1
crmeb/app/adminapi/route/statistic.php

@@ -89,4 +89,4 @@ Route::group('statistic', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'statistic', 'mark_name' => '统计']);
+])->option(['mark' => 'statistic', 'mark_name' => '程序统计']);

+ 2 - 2
crmeb/app/adminapi/route/system.php

@@ -189,7 +189,7 @@ Route::group('system', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'system', 'mark_name' => '维护']);
+])->option(['mark' => 'system', 'mark_name' => '系统维护']);
 
 Route::group('system', function () {
 
@@ -217,5 +217,5 @@ Route::group('system', function () {
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminEditorTokenMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'system_file', 'mark_name' => '文件']);
+])->option(['mark' => 'system_file', 'mark_name' => '文件管理']);
 

+ 1 - 1
crmeb/app/adminapi/route/user.php

@@ -185,4 +185,4 @@ Route::group('user', function () {
     \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
     \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
     \app\adminapi\middleware\AdminLogMiddleware::class
-])->option(['mark' => 'user', 'mark_name' => '用户']);
+])->option(['mark' => 'user', 'mark_name' => '用户管理']);

+ 3 - 1
crmeb/app/dao/system/SystemRouteDao.php

@@ -47,6 +47,8 @@ class SystemRouteDao extends BaseDao
      */
     public function deleteRoutes(array $ids)
     {
-        return $this->getModel()->where('id', 'in', $ids)->delete();
+        return $this->getModel()::destroy(function ($q) use ($ids) {
+            $q->whereIn('id', $ids);
+        }, true);
     }
 }

+ 1 - 2
crmeb/app/model/system/SystemCrud.php

@@ -56,8 +56,7 @@ class SystemCrud extends BaseModel
         return json_decode($value, true);
     }
 
-
-    public function getRoutesIdAttr($value)
+    public function getRouteIdsAttr($value)
     {
         return json_decode($value, true);
     }

+ 7 - 6
crmeb/app/services/system/SystemCrudServices.php

@@ -29,7 +29,6 @@ use crmeb\services\crud\ViewPages;
 use crmeb\services\crud\ViewRouter;
 use crmeb\services\FileService;
 use Phinx\Db\Adapter\AdapterFactory;
-use think\exception\ValidateException;
 use think\facade\Db;
 use think\helper\Str;
 use think\migration\db\Table;
@@ -582,8 +581,8 @@ class SystemCrudServices extends BaseServices
                     $menuInfo = $meunService->save($dataMenu);
                 }
                 //删除掉添加的路由权限
-                if ($crudInfo->routes_id) {
-                    $routeService->deleteRoutes($crudInfo->routes_id);
+                if ($crudInfo->route_ids) {
+                    $routeService->deleteRoutes($crudInfo->route_ids);
                 }
                 //删除掉权限路由
                 if ($crudInfo->menu_ids) {
@@ -689,7 +688,7 @@ class SystemCrudServices extends BaseServices
                 'menu_ids' => json_encode($menuIds),//生成的菜单id
                 'menu_id' => $menuInfo->id,//生成的菜单id
                 'make_path' => json_encode($makePath),
-                'routes_id' => json_encode($routeIds),
+                'route_ids' => json_encode($routeIds),
             ];
 
             if ($crudInfo) {
@@ -700,8 +699,6 @@ class SystemCrudServices extends BaseServices
                 $res = $this->dao->save($crudDate);
             }
 
-//            throw new ValidateException('测试中');
-
             return $res;
         });
 
@@ -781,6 +778,9 @@ class SystemCrudServices extends BaseServices
         $table = new Table($tableName, ['comment' => $tableComment], $this->getAdapter());
         //创建字段
         foreach ($tableField as $item) {
+            if (isset($item['primaryKey']) && $item['primaryKey']) {
+                continue;
+            }
             $option = [];
             if (isset($item['limit'])) {
                 $option['limit'] = (int)$item['limit'];
@@ -842,6 +842,7 @@ class SystemCrudServices extends BaseServices
         $dao = app()->make(Dao::class);
         $dao->setFilePathName($filePath['dao'] ?? '')->setbasePath($basePath)->handle($tableName, [
             'usePath' => $model->getUsePath(),
+            'modelName' => $options['modelName'] ?? '',
         ]);
         //生成service
         $service = app()->make(Service::class);

+ 27 - 2
crmeb/app/services/system/SystemRouteServices.php

@@ -97,8 +97,11 @@ class SystemRouteServices extends BaseServices
         foreach ($list as $key => $item) {
             if (!empty($item['children'])) {
                 foreach ($item['children'] as $k => $v) {
-                    if (isset($v['cate_id']) && isset($v['method']) && $v['method'] === 'DELETE') {
-                        $v['method'] = 'DEL';
+                    if (isset($v['cate_id']) && isset($v['method'])) {
+                        if ($v['method'] === 'DELETE') {
+                            $v['method'] = 'DEL';
+                        }
+                        $v['pid'] = $v['cate_id'];
                         $list[$key]['children'][$k] = $v;
                     }
                 }
@@ -108,6 +111,28 @@ class SystemRouteServices extends BaseServices
         return get_tree_children($list);
     }
 
+    /**
+     * @param array $importData
+     * @return bool
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/4/26
+     */
+    public function importData(array $importData)
+    {
+        foreach ($importData as $item) {
+            $id = $this->dao->value(['method' => $item['method'], 'path' => $item['path']], 'id');
+            if ($id) {
+                $this->dao->update($id, [
+                    'request' => $item['request'],
+                    'response' => $item['response'],
+                    'request_type' => $item['request_type'],
+                ]);
+            }
+        }
+        return true;
+    }
+
     /**
      * 获取某个应用下的所有路由权限
      * @param string $app

+ 52 - 0
crmeb/app/services/system/log/SystemFileInfoServices.php

@@ -21,4 +21,56 @@ class SystemFileInfoServices extends BaseServices
     {
         $this->dao = $dao;
     }
+
+    public function syncfile()
+    {
+        $list = $this->flattenArray($this->scanDirectory());
+//        $this->dao->saveAll($list);
+    }
+
+    public function scanDirectory($dir = '')
+    {
+        if ($dir == '') $dir = root_path();
+        $result = array();
+        $files = scandir($dir);
+        foreach ($files as $file) {
+            if ($file != '.' && $file != '..') {
+                $path = $dir . '/' . $file;
+                $fileInfo = array(
+                    'name' => $file,
+                    'update_time' => date('Y-m-d H:i:s', filemtime($path)),
+                    'create_time' => date('Y-m-d H:i:s', filectime($path)),
+                    'path' => str_replace(root_path(), '', $dir),
+                    'full_path' => str_replace(root_path(), '', $path),
+                );
+                if (is_dir($path)) {
+                    $fileInfo['type'] = 'dir';
+                    $fileInfo['contents'] = $this->scanDirectory($path);
+                } else {
+                    $fileInfo['type'] = 'file';
+                }
+                $result[] = $fileInfo;
+            }
+        }
+        return $result;
+    }
+
+    public function flattenArray($arr)
+    {
+        $result = array();
+        foreach ($arr as $item) {
+            $result[] = array(
+                'name' => $item['name'],
+                'type' => $item['type'],
+                'update_time' => $item['update_time'],
+                'create_time' => $item['create_time'],
+                'path' => $item['path'],
+                'full_path' => $item['full_path'],
+            );
+            if (isset($item['contents'])) {
+                $result = array_merge($result, $this->flattenArray($item['contents']));
+            }
+        }
+        return $result;
+    }
 }

+ 139 - 1
crmeb/crmeb/command/Util.php

@@ -3,6 +3,7 @@
 namespace crmeb\command;
 
 
+use app\services\system\log\SystemFileInfoServices;
 use app\services\system\SystemRouteServices;
 use crmeb\exceptions\AdminException;
 use think\console\Command;
@@ -18,10 +19,11 @@ class Util extends Command
     protected function configure()
     {
         $this->setName('util')
-            ->addArgument('type', Argument::REQUIRED, '类型replace/route')
+            ->addArgument('type', Argument::REQUIRED, '类型replace/route/file/apifox')
             ->addOption('h', null, Option::VALUE_REQUIRED, '替换成当前域名')
             ->addOption('u', null, Option::VALUE_REQUIRED, '替换的域名')
             ->addOption('a', null, Option::VALUE_REQUIRED, '应用名')
+            ->addOption('f', null, Option::VALUE_REQUIRED, '导入文件路径,文件只能在项目根目录下或者根目录下的其他文件夹内')
             ->setDescription('工具类');
     }
 
@@ -48,6 +50,16 @@ class Util extends Command
                 }
                 app()->make(SystemRouteServices::class)->syncRoute($appName);
                 break;
+            case 'file':
+                app()->make(SystemFileInfoServices::class)->syncfile();
+                break;
+            case 'apifox':
+                $filePath = $input->getOption('f');
+                if (!$filePath) {
+                    return $output->error('缺少导入文件地址');
+                }
+                $this->import($filePath);
+                break;
         }
 
         $output->info('执行成功');
@@ -87,4 +99,130 @@ class Util extends Command
             }
         });
     }
+
+    /**
+     * 导入数据
+     * @param string $filePath
+     * @return mixed
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/4/26
+     */
+    protected function import(string $filePath)
+    {
+        $preg = '/\{+[a-zA-Z0-9]+\}/';
+
+        $res = file_get_contents(app()->getRootPath() . $filePath);
+
+        $data = json_decode($res, true)['apiCollection'][0]['items'];
+
+        $route = [];
+        foreach ($data as $item) {
+            foreach ($item['items'] as $value) {
+                if (isset($value['api'])) {
+                    $path = str_replace('//', '/', str_replace('{}', '', $value['api']['path']));
+                    $paramePath = $this->getPathValue($value['api']['parameters']['path'] ?? []);
+                    if (strstr($path, ':') !== false) {
+                        $path = str_replace(':', '', $path);
+                    }
+                    if (preg_match_all($preg, $path, $matches)) {
+                        $paramePathMatche = [];
+                        if (isset($matches[0]) && $matches[0]) {
+                            foreach ($matches[0] as $v) {
+                                $paramePathMatche[] = str_replace(['{', '}'], ['<', '>'], $v);
+                            }
+                        }
+                        if ($paramePathMatche) {
+                            $paramePath = implode('/', $paramePathMatche);
+                        }
+                    }
+                    if ($path[0] === '/') {
+                        $path = substr($path, 1);
+                    }
+                    $route[] = [
+                        'method' => strtoupper($value['api']['method']),
+                        'path' => $path . $paramePath,
+                        'request_type' => $value['api']['requestBody']['type'],
+                        'request' => $this->getRequest($value['api']['requestBody']['parameters'] ?? []),
+                        'response' => $this->getResponse($value['api']['responses'][0]['jsonSchema']['properties'] ?? []),
+                    ];
+                }
+            }
+        }
+
+        return app()->make(SystemRouteServices::class)->importData($route);
+    }
+
+    /**
+     * 获取请求返回数据
+     * @param array $options
+     * @param string $parentId
+     * @return array
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/4/26
+     */
+    protected function getResponse(array $options, $parentId = '')
+    {
+        $response = [];
+        foreach ($options as $key => $option) {
+            $id = uniqid();
+            $response[] = [
+                'attribute' => $key,
+                'type' => $option['type'],
+                'trip' => '',
+                'id' => $id,
+                'parentId' => $parentId,
+            ];
+            if (isset($option['properties'])) {
+                $response = array_merge($response, $this->getResponse($option['properties'], $id));
+            }
+        }
+
+        return $response;
+    }
+
+    /**
+     * 获取请求数据
+     * @param array $options
+     * @return array
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/4/26
+     */
+    protected function getRequest(array $options)
+    {
+        $request = [];
+        foreach ($options as $option) {
+            $request[] = [
+                'attribute' => $option['name'],
+                'type' => $option['type'] === 'text' ? 'string' : $option['type'],
+                'must' => 0,
+                'trip' => $option['description'],
+                'id' => $option['id'],
+            ];
+        }
+        return $request;
+    }
+
+    /**
+     * 处理path路径
+     * @param array $options
+     * @return string
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/4/26
+     */
+    protected function getPathValue(array $options)
+    {
+        $path = [];
+        foreach ($options as $option) {
+            if (strstr($option['name'], '?') !== false) {
+                $option['name'] = str_replace('?', '', $option['name']) . '?';
+            }
+            $path[] = '<' . $option['name'] . '>';
+        }
+
+        return implode('/', $path);
+    }
 }

+ 3 - 0
crmeb/crmeb/services/crud/Make.php

@@ -238,6 +238,9 @@ abstract class Make
         if (isset($this->value['use-php']) && !empty($options['usePath'])) {
             $this->value['use-php'] = "use " . str_replace('/', '\\', $options['usePath']) . ";\n";
         }
+        if (isset($this->value['modelName']) && !$this->value['modelName'] && !empty($options['modelName'])) {
+            $this->value['modelName'] = $options['modelName'];
+        }
 
         $contentStr = str_replace($this->var, $this->value, $content);
         $filePath = $this->getFilePathName($path, $this->value['nameCamel']);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/index.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 2 - 0
crmeb/public/admin/system_static/css/app.dd63f4d8.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-1726de98.822786e8.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-249e48fe.7805721e.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-26798ce6.d517fe9e.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-26da89b4.6c45ae97.css


+ 1 - 0
crmeb/public/admin/system_static/css/chunk-34dc580b.891304a1.css

@@ -0,0 +1 @@
+[data-v-aa8a590c] .center{text-align:center;margin-right:0!important;margin-left:5px}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-40c51cef.555bc19b.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-43146ca4.f2ebd107.css


+ 1 - 0
crmeb/public/admin/system_static/css/chunk-4ca4f1ca.891304a1.css

@@ -0,0 +1 @@
+[data-v-aa8a590c] .center{text-align:center;margin-right:0!important;margin-left:5px}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-7d90b9a3.cbe02e34.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-df056abe.eafdc5e6.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/app.0d48ca32.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 7 - 0
crmeb/public/admin/system_static/js/chunk-030292b9.9e0b36bd.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-1726de98.bc8f762c.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-249e48fe.fe0bf709.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-26798ce6.e80d9d41.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-26da89b4.980ebd6b.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-2d0be348.fd22e013.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-2d20ebf3.2927745c.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-34dc580b.01666f92.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-40c51cef.7a0e9cc2.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-43146ca4.60b2bd7f.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-4ca4f1ca.ed32b44e.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-7d90b9a3.b47acfb1.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/js/chunk-df056abe.92e5c863.js