liaofei 2 лет назад
Родитель
Сommit
948343e294
1 измененных файлов с 12 добавлено и 1 удалено
  1. 12 1
      crmeb/app/services/system/SystemRouteServices.php

+ 12 - 1
crmeb/app/services/system/SystemRouteServices.php

@@ -100,7 +100,7 @@ class SystemRouteServices extends BaseServices
 
         $route = $this->app->route->getRuleList();
         $action_arr = ['index', 'read', 'create', 'save', 'edit', 'update', 'delete'];
-        
+
         foreach ($route as &$item) {
             $real_name = $item['option']['real_name'] ?? '';
             if (is_array($real_name)) {
@@ -124,6 +124,16 @@ class SystemRouteServices extends BaseServices
      */
     public function syncRoute(string $app = 'adminapi')
     {
+        $id = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => '全部权限', 'pid' => 0], 'id');
+        if (!$id) {
+            $res = app()->make(SystemRouteCateServices::class)->save([
+                'app_name' => $app,
+                'name' => '全部权限',
+                'pid' => 0,
+                'add_time' => time(),
+            ]);
+            $id = $res->id;
+        }
         $listAll = $this->getRouteListAll($app);
         //保持新增的权限路由
         $data = $this->dao->selectList(['app_name' => $app], 'path,method')->toArray();
@@ -133,6 +143,7 @@ class SystemRouteServices extends BaseServices
                 $save[] = [
                     'name' => $item['option']['real_name'] ?? $item['name'],
                     'path' => $item['rule'],
+                    'cate_id' => $id,
                     'app_name' => $app,
                     'type' => isset($item['option']['is_common']) && $item['option']['is_common'] ? 1 : 0,
                     'method' => $item['method'],