This commit is contained in:
2025-11-30 22:32:08 +03:30
parent 8b4d60618a
commit 03064cfd53
3 changed files with 115 additions and 0 deletions
@@ -1,6 +1,7 @@
import { Controller, Get, Post, Body, Patch, Delete, UseGuards, Param } from '@nestjs/common';
import { CartService } from '../providers/cart.service';
import { AddItemToCartDto } from '../dto/add-item.dto';
import { BulkAddItemsToCartDto } from '../dto/bulk-add-items.dto';
import { UpdateItemQuantityDto } from '../dto/update-item.dto';
import { ApplyCouponDto } from '../dto/apply-coupon.dto';
import { SetAddressDto } from '../dto/set-address.dto';
@@ -35,6 +36,20 @@ export class CartController {
return this.cartService.addItem(userId, restaurantId, addItemDto);
}
@Post('items/bulk')
@ApiOperation({ summary: 'Bulk add items to cart (increments quantity if items exist)' })
@ApiBody({ type: BulkAddItemsToCartDto })
@ApiResponse({ status: 201, description: 'Items added to cart successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., insufficient stock, invalid items)' })
@ApiResponse({ status: 404, description: 'Food not found' })
bulkAddItems(
@UserId() userId: string,
@RestId() restaurantId: string,
@Body() bulkAddItemsDto: BulkAddItemsToCartDto,
) {
return this.cartService.bulkAddItems(userId, restaurantId, bulkAddItemsDto);
}
@Patch('items/:itemId')
@ApiOperation({ summary: 'Update item quantity in cart' })
@ApiParam({ name: 'itemId', description: 'Item ID in the cart' })