cart
This commit is contained in:
@@ -19,66 +19,65 @@ export class CartController {
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Get cart for current user and shop' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
async findOne(@UserId() userId: string, @ShopId() restaurantId: string) {
|
||||
return this.cartService.getOrCreateCart(userId, restaurantId);
|
||||
async findOne(@UserId() userId: string, @ShopId() shopId: string) {
|
||||
return this.cartService.getOrCreateCart(userId, shopId);
|
||||
}
|
||||
|
||||
@Post('items/:foodId/increment')
|
||||
@Post('product/:productId/increment')
|
||||
@ApiOperation({ summary: 'Increment item quantity in cart by 1' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiParam({ name: 'foodId', description: 'Product ID to increment in cart' })
|
||||
async incrementItem(@UserId() userId: string, @ShopId() restaurantId: string, @Param('foodId') foodId: string) {
|
||||
return this.cartService.incrementItem(userId, restaurantId, foodId, 1);
|
||||
@ApiParam({ name: 'productId', description: 'Product ID to increment in cart' })
|
||||
async incrementItem(@UserId() userId: string, @ShopId() shopId: string, @Param('productId') productId: string) {
|
||||
return this.cartService.incrementItem(userId, shopId, productId, 1);
|
||||
}
|
||||
|
||||
@Post('items/:foodId/decrement')
|
||||
@Post('product/:productId/decrement')
|
||||
@ApiOperation({ summary: 'Decrement item quantity in cart by 1 (removes item if quantity reaches 0)' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiParam({ name: 'foodId', description: 'Product ID to decrement in cart' })
|
||||
async decrementItem(@UserId() userId: string, @ShopId() restaurantId: string, @Param('foodId') foodId: string) {
|
||||
return this.cartService.decrementItem(userId, restaurantId, foodId);
|
||||
@ApiParam({ name: 'productId', description: 'Product ID to decrement in cart' })
|
||||
async decrementItem(@UserId() userId: string, @ShopId() shopId: string, @Param('productId') productId: string) {
|
||||
return this.cartService.decrementItem(userId, shopId, productId);
|
||||
}
|
||||
|
||||
@Post('items/bulk')
|
||||
@Post('product/bulk')
|
||||
@ApiOperation({ summary: 'Bulk add items to cart (increments quantity if items exist)' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiBody({ type: BulkAddItemsToCartDto })
|
||||
bulkAddItems(
|
||||
@UserId() userId: string,
|
||||
@ShopId() restaurantId: string,
|
||||
@ShopId() shopId: string,
|
||||
@Body() bulkAddItemsDto: BulkAddItemsToCartDto,
|
||||
) {
|
||||
return this.cartService.bulkAddItems(userId, restaurantId, bulkAddItemsDto);
|
||||
return this.cartService.bulkAddItems(userId, shopId, bulkAddItemsDto);
|
||||
}
|
||||
|
||||
@Delete('items/:foodId')
|
||||
@Delete('product/:productId')
|
||||
@ApiOperation({ summary: 'Remove item from cart' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiParam({ name: 'foodId', description: 'Product ID in the cart' })
|
||||
async removeItem(@UserId() userId: string, @ShopId() restaurantId: string, @Param('foodId') foodId: string) {
|
||||
return this.cartService.removeItem(userId, restaurantId, foodId);
|
||||
@ApiParam({ name: 'productId', description: 'Product ID in the cart' })
|
||||
async removeItem(@UserId() userId: string, @ShopId() shopId: string, @Param('productId') productId: string) {
|
||||
return this.cartService.removeItem(userId, shopId, productId);
|
||||
}
|
||||
|
||||
@Delete()
|
||||
@ApiOperation({ summary: 'Clear entire cart' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
async clearCart(@UserId() userId: string, @ShopId() restaurantId: string) {
|
||||
return this.cartService.clearCart(userId, restaurantId);
|
||||
async clearCart(@UserId() userId: string, @ShopId() shopId: string) {
|
||||
return this.cartService.clearCart(userId, shopId);
|
||||
}
|
||||
|
||||
@Post('apply-coupon')
|
||||
@Post('coupon')
|
||||
@ApiOperation({ summary: 'Apply coupon to cart' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiBody({ type: ApplyCouponDto })
|
||||
async applyCoupon(@UserId() userId: string, @ShopId() restaurantId: string, @Body() applyCouponDto: ApplyCouponDto) {
|
||||
return this.cartService.applyCoupon(userId, restaurantId, applyCouponDto);
|
||||
async applyCoupon(@UserId() userId: string, @ShopId() shopId: string, @Body() applyCouponDto: ApplyCouponDto) {
|
||||
return this.cartService.applyCoupon(userId, shopId, applyCouponDto);
|
||||
}
|
||||
|
||||
@Delete('coupon')
|
||||
@ApiOperation({ summary: 'Remove coupon from cart' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
async removeCoupon(@UserId() userId: string, @ShopId() restaurantId: string) {
|
||||
return this.cartService.removeCoupon(userId, restaurantId);
|
||||
async removeCoupon(@UserId() userId: string, @ShopId() shopId: string) {
|
||||
return this.cartService.removeCoupon(userId, shopId);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +85,7 @@ export class CartController {
|
||||
@ApiOperation({ summary: 'Set all cart params' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiBody({ type: SetAllCartParmsDto })
|
||||
setAllCartParams(@UserId() userId: string, @ShopId() restaurantId: string, @Body() dto: SetAllCartParmsDto) {
|
||||
return this.cartService.setAllCartParams(userId, restaurantId, dto);
|
||||
setAllCartParams(@UserId() userId: string, @ShopId() shopId: string, @Body() dto: SetAllCartParmsDto) {
|
||||
return this.cartService.setAllCartParams(userId, shopId, dto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user