|
|
|
@@ -22,14 +22,28 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
@ApiOperation({ summary: 'Get cart for current user and restaurant' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
async findOne(@UserId() userId: string, @RestId() restaurantId: string) {
|
|
|
|
|
return this.cartService.getOrCreateCart(userId, restaurantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('items/:foodId/increment')
|
|
|
|
|
@ApiOperation({ summary: 'Increment item quantity in cart by 1' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiParam({ name: 'foodId', description: 'Food ID to increment in cart' })
|
|
|
|
|
async incrementItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
|
|
|
|
|
return this.cartService.incrementItem(userId, restaurantId, foodId);
|
|
|
|
@@ -37,7 +51,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Post('items/:foodId/decrement')
|
|
|
|
|
@ApiOperation({ summary: 'Decrement item quantity in cart by 1 (removes item if quantity reaches 0)' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiParam({ name: 'foodId', description: 'Food ID to decrement in cart' })
|
|
|
|
|
async decrementItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
|
|
|
|
|
return this.cartService.decrementItem(userId, restaurantId, foodId);
|
|
|
|
@@ -45,7 +66,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Post('items/bulk')
|
|
|
|
|
@ApiOperation({ summary: 'Bulk add items to cart (increments quantity if items exist)' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: BulkAddItemsToCartDto })
|
|
|
|
|
bulkAddItems(
|
|
|
|
|
@UserId() userId: string,
|
|
|
|
@@ -57,7 +85,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Patch('items/:foodId')
|
|
|
|
|
@ApiOperation({ summary: 'Update item quantity in cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiParam({ name: 'foodId', description: 'Food ID in the cart' })
|
|
|
|
|
@ApiBody({ type: UpdateItemQuantityDto })
|
|
|
|
|
async updateItemQuantity(
|
|
|
|
@@ -71,7 +106,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Delete('items/:foodId')
|
|
|
|
|
@ApiOperation({ summary: 'Remove item from cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiParam({ name: 'foodId', description: 'Food ID in the cart' })
|
|
|
|
|
async removeItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
|
|
|
|
|
return this.cartService.removeItem(userId, restaurantId, foodId);
|
|
|
|
@@ -79,14 +121,28 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Delete()
|
|
|
|
|
@ApiOperation({ summary: 'Clear entire cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
async clearCart(@UserId() userId: string, @RestId() restaurantId: string) {
|
|
|
|
|
return this.cartService.clearCart(userId, restaurantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('apply-coupon')
|
|
|
|
|
@ApiOperation({ summary: 'Apply coupon to cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: ApplyCouponDto })
|
|
|
|
|
async applyCoupon(@UserId() userId: string, @RestId() restaurantId: string, @Body() applyCouponDto: ApplyCouponDto) {
|
|
|
|
|
return this.cartService.applyCoupon(userId, restaurantId, applyCouponDto);
|
|
|
|
@@ -94,14 +150,28 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Delete('coupon')
|
|
|
|
|
@ApiOperation({ summary: 'Remove coupon from cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
async removeCoupon(@UserId() userId: string, @RestId() restaurantId: string) {
|
|
|
|
|
return this.cartService.removeCoupon(userId, restaurantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('address')
|
|
|
|
|
@ApiOperation({ summary: 'Set address for cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: SetAddressDto })
|
|
|
|
|
async setAddress(@UserId() userId: string, @RestId() restaurantId: string, @Body() setAddressDto: SetAddressDto) {
|
|
|
|
|
return this.cartService.setAddress(userId, restaurantId, setAddressDto);
|
|
|
|
@@ -109,7 +179,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Patch('payment-method')
|
|
|
|
|
@ApiOperation({ summary: 'Set payment method for cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: SetPaymentMethodDto })
|
|
|
|
|
async setPaymentMethod(
|
|
|
|
|
@UserId() userId: string,
|
|
|
|
@@ -121,7 +198,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Patch('delivery-method')
|
|
|
|
|
@ApiOperation({ summary: 'Set delivery method for cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: SetDeliveryMethodDto })
|
|
|
|
|
setDeliveryMethod(
|
|
|
|
|
@UserId() userId: string,
|
|
|
|
@@ -133,7 +217,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Patch('description')
|
|
|
|
|
@ApiOperation({ summary: 'Set description for cart' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: SetDescriptionDto })
|
|
|
|
|
setDescription(
|
|
|
|
|
@UserId() userId: string,
|
|
|
|
@@ -145,7 +236,14 @@ export class CartController {
|
|
|
|
|
|
|
|
|
|
@Patch('table-number')
|
|
|
|
|
@ApiOperation({ summary: 'Set table number for cart (required when delivery method is DineIn)' })
|
|
|
|
|
@ApiHeader({ name: 'X-Slug', required: true, description: 'Restaurant slug identifier', example: 'zhivan' })
|
|
|
|
|
@ApiHeader({
|
|
|
|
|
name: 'X-Slug',
|
|
|
|
|
required: true,
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'zhivan',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ type: SetTableNumberDto })
|
|
|
|
|
setTableNumber(
|
|
|
|
|
@UserId() userId: string,
|
|
|
|
|