From 6a6c8ce91a9c31e06c885343cbb8a2e46a2a34c4 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 1 Dec 2025 12:04:05 +0330 Subject: [PATCH] up --- src/modules/cart/controllers/cart.controller.ts | 2 +- src/modules/cart/providers/cart.service.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/cart/controllers/cart.controller.ts b/src/modules/cart/controllers/cart.controller.ts index d00ddbe..67b0cc5 100644 --- a/src/modules/cart/controllers/cart.controller.ts +++ b/src/modules/cart/controllers/cart.controller.ts @@ -22,7 +22,7 @@ export class CartController { @ApiResponse({ status: 200, description: 'Cart retrieved successfully' }) @ApiResponse({ status: 404, description: 'Cart not found' }) async findOne(@UserId() userId: string, @RestId() restaurantId: string) { - return this.cartService.findOne(userId, restaurantId); + return this.cartService.getOrCreateCart(userId, restaurantId); } @Post('items/:foodId/increment') diff --git a/src/modules/cart/providers/cart.service.ts b/src/modules/cart/providers/cart.service.ts index f46bc40..f6b92cb 100644 --- a/src/modules/cart/providers/cart.service.ts +++ b/src/modules/cart/providers/cart.service.ts @@ -65,7 +65,11 @@ export class CartService { * Find cart by user and restaurant */ async findOne(userId: string, restaurantId: string): Promise { - return this.getOrCreateCart(userId, restaurantId); + const cart = await this.getCartByRestaurant(userId, restaurantId); + if (!cart) { + throw new NotFoundException('Cart not found'); + } + return cart; } /**