up
This commit is contained in:
@@ -22,7 +22,7 @@ export class CartController {
|
|||||||
@ApiResponse({ status: 200, description: 'Cart retrieved successfully' })
|
@ApiResponse({ status: 200, description: 'Cart retrieved successfully' })
|
||||||
@ApiResponse({ status: 404, description: 'Cart not found' })
|
@ApiResponse({ status: 404, description: 'Cart not found' })
|
||||||
async findOne(@UserId() userId: string, @RestId() restaurantId: string) {
|
async findOne(@UserId() userId: string, @RestId() restaurantId: string) {
|
||||||
return this.cartService.findOne(userId, restaurantId);
|
return this.cartService.getOrCreateCart(userId, restaurantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('items/:foodId/increment')
|
@Post('items/:foodId/increment')
|
||||||
|
|||||||
@@ -65,7 +65,11 @@ export class CartService {
|
|||||||
* Find cart by user and restaurant
|
* Find cart by user and restaurant
|
||||||
*/
|
*/
|
||||||
async findOne(userId: string, restaurantId: string): Promise<Cart> {
|
async findOne(userId: string, restaurantId: string): Promise<Cart> {
|
||||||
return this.getOrCreateCart(userId, restaurantId);
|
const cart = await this.getCartByRestaurant(userId, restaurantId);
|
||||||
|
if (!cart) {
|
||||||
|
throw new NotFoundException('Cart not found');
|
||||||
|
}
|
||||||
|
return cart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user