kevinlan@lpchku.com 4 months ago
parent
commit
1a855977d0
1 changed files with 5 additions and 8 deletions
  1. 5 8
      app/Http/Controllers/API/LibraryController.php

+ 5 - 8
app/Http/Controllers/API/LibraryController.php

@@ -18,10 +18,8 @@ class LibraryController extends Controller
      */
     public function index(Request $request)
     {
-        $pageSize = $request->get('pageSize', 10);
-        $libraries = Library::filter(['id', 'name','type','asset_id','project_id'])->allowed()->paginate($pageSize);
+        $libraries = Library::query()->filter($request->all())->allowed()->get(['id', 'name','type','asset_id','project_id']);
 
-        $total = $libraries->total();
         $containerCount = Container::query()->allowed()
             ->whereIn("library_id", $libraries->pluck("id")->toArray())
             ->selectRaw("count(*) as cut, library_id")
@@ -41,8 +39,7 @@ class LibraryController extends Controller
         });
 
         return $this->success([
-            'data' => $libraries,
-            'total' => $total
+            'data' => $libraries
         ]);
     }
 
@@ -122,9 +119,9 @@ class LibraryController extends Controller
             ->where("type", $type)->when($where, fn($query) => $query->where($where))
             ->get(['id', 'name', 'created_at', 'updated_at'])
             ->each(function ($libraries) {
-            // 设置固定的type值
-            $libraries->type = 'library';
-            $libraries->uniId=$libraries->type.'_'.$libraries->id;
+                // 设置固定的type值
+                $libraries->type = 'library';
+                $libraries->uniId=$libraries->type.'_'.$libraries->id;
             });
 
         return $this->success([