[REFACTOR] 優化資料庫查詢效能:在多個 Service 與 Controller 中加入 select 欄位限制,並新增租戶資料表索引 Migration。
This commit is contained in:
@@ -13,7 +13,7 @@ class InventoryService implements InventoryServiceInterface
|
||||
{
|
||||
public function getAllWarehouses()
|
||||
{
|
||||
return Warehouse::all();
|
||||
return Warehouse::select('id', 'name', 'code', 'type')->get();
|
||||
}
|
||||
|
||||
public function getTopInventoryValue(int $limit = 5): \Illuminate\Support\Collection
|
||||
@@ -38,12 +38,14 @@ class InventoryService implements InventoryServiceInterface
|
||||
|
||||
public function getAllProducts()
|
||||
{
|
||||
return Product::with(['baseUnit', 'largeUnit'])->get();
|
||||
return Product::select('id', 'name', 'code', 'base_unit_id', 'large_unit_id')
|
||||
->with(['baseUnit:id,name', 'largeUnit:id,name'])
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getUnits()
|
||||
{
|
||||
return \App\Modules\Inventory\Models\Unit::all();
|
||||
return \App\Modules\Inventory\Models\Unit::select('id', 'name')->get();
|
||||
}
|
||||
|
||||
public function getInventoriesByIds(array $ids, array $with = [])
|
||||
|
||||
Reference in New Issue
Block a user