cart and coupon

This commit is contained in:
2025-12-06 20:26:37 +03:30
parent a7d28ab882
commit e342c00e25
9 changed files with 114 additions and 122 deletions
@@ -20,8 +20,6 @@ export class CartController {
@Get()
@ApiOperation({ summary: 'Get cart for current user and restaurant' })
@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.getOrCreateCart(userId, restaurantId);
}
@@ -29,9 +27,6 @@ export class CartController {
@Post('items/:foodId/increment')
@ApiOperation({ summary: 'Increment item quantity in cart by 1' })
@ApiParam({ name: 'foodId', description: 'Food ID to increment in cart' })
@ApiResponse({ status: 201, description: 'Item incremented in cart successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., insufficient stock)' })
@ApiResponse({ status: 404, description: 'Food not found' })
async incrementItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
return this.cartService.incrementItem(userId, restaurantId, foodId);
}
@@ -39,8 +34,6 @@ export class CartController {
@Post('items/:foodId/decrement')
@ApiOperation({ summary: 'Decrement item quantity in cart by 1 (removes item if quantity reaches 0)' })
@ApiParam({ name: 'foodId', description: 'Food ID to decrement in cart' })
@ApiResponse({ status: 200, description: 'Item decremented in cart successfully' })
@ApiResponse({ status: 404, description: 'Item not found in cart' })
async decrementItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
return this.cartService.decrementItem(userId, restaurantId, foodId);
}
@@ -48,9 +41,6 @@ export class CartController {
@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,
@@ -63,9 +53,6 @@ export class CartController {
@ApiOperation({ summary: 'Update item quantity in cart' })
@ApiParam({ name: 'foodId', description: 'Food ID in the cart' })
@ApiBody({ type: UpdateItemQuantityDto })
@ApiResponse({ status: 200, description: 'Item quantity updated successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., insufficient stock)' })
@ApiResponse({ status: 404, description: 'Item not found in cart' })
async updateItemQuantity(
@UserId() userId: string,
@RestId() restaurantId: string,
@@ -94,8 +81,6 @@ export class CartController {
@Post('apply-coupon')
@ApiOperation({ summary: 'Apply coupon to cart' })
@ApiBody({ type: ApplyCouponDto })
@ApiResponse({ status: 200, description: 'Coupon applied successfully' })
@ApiResponse({ status: 400, description: 'Invalid coupon code' })
async applyCoupon(@UserId() userId: string, @RestId() restaurantId: string, @Body() applyCouponDto: ApplyCouponDto) {
return this.cartService.applyCoupon(userId, restaurantId, applyCouponDto);
}
@@ -110,9 +95,6 @@ export class CartController {
@Patch('address')
@ApiOperation({ summary: 'Set address for cart' })
@ApiBody({ type: SetAddressDto })
@ApiResponse({ status: 200, description: 'Address set successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., address does not belong to user)' })
@ApiResponse({ status: 404, description: 'Address not found' })
async setAddress(@UserId() userId: string, @RestId() restaurantId: string, @Body() setAddressDto: SetAddressDto) {
return this.cartService.setAddress(userId, restaurantId, setAddressDto);
}
@@ -120,9 +102,6 @@ export class CartController {
@Patch('payment-method')
@ApiOperation({ summary: 'Set payment method for cart' })
@ApiBody({ type: SetPaymentMethodDto })
@ApiResponse({ status: 200, description: 'Payment method set successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., payment method is not active)' })
@ApiResponse({ status: 404, description: 'Payment method not found for restaurant' })
async setPaymentMethod(
@UserId() userId: string,
@RestId() restaurantId: string,