This commit is contained in:
2025-12-17 22:17:06 +03:30
parent b663bfa592
commit 4319be7a04
4 changed files with 9 additions and 27 deletions
@@ -22,8 +22,8 @@ export class BulkReserveFoodDto {
description: 'Array of food reservations to create',
type: [BulkReserveFoodItemDto],
example: [
{ foodId: 'food-123', quantity: 5, expiresAt: '2024-12-31T23:59:59Z' },
{ foodId: 'food-789', quantity: 3, expiresAt: '2024-12-31T23:59:59Z' },
{ foodId: 'food-123', quantity: 5 },
{ foodId: 'food-789', quantity: 3 },
],
})
@IsNotEmpty()
@@ -1,4 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { CreateInventoryDto } from './create-inventory.dto';
export class UpdateInventoryDto extends PartialType(CreateInventoryDto) {}
+2 -2
View File
@@ -143,7 +143,7 @@ export class InventoryService {
const foodIds = [...new Set(items.map(item => item.foodId))];
// Load all foods in one query
const foods = await em.find(Food, { id: { $in: foodIds } }, { lockMode: LockMode.PESSIMISTIC_WRITE });
const foods = await em.find(Food, { id: { $in: foodIds } });
// Verify all foods exist and belong to the restaurant
const foodMap = new Map<string, Food>();
@@ -160,7 +160,7 @@ export class InventoryService {
// Load all existing inventories in one query
const existingInventories = await em.find(Inventory, {
food: { id: { $in: foodIds } },
});
},{ lockMode: LockMode.PESSIMISTIC_WRITE });
const inventoryMap = new Map<string, Inventory>();
for (const inventory of existingInventories) {