This commit is contained in:
2025-12-03 10:28:21 +03:30
parent afbe480db6
commit 46d1f96115
2 changed files with 43 additions and 29 deletions
+18 -20
View File
@@ -1,7 +1,6 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
import { Controller, Get, Post, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { OrdersService } from './orders.service';
import { UpdateOrderDto } from './dto/update-order.dto';
import { AuthGuard } from '../auth/guards/auth.guard';
import { UserId } from '../../common/decorators/user-id.decorator';
import { RestId } from 'src/common/decorators/rest-id.decorator';
@@ -13,35 +12,34 @@ export class OrdersController {
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Post('public/orders')
@ApiOperation({ summary: 'Create a new order from cart' })
@ApiResponse({ status: 201, description: 'Order created successfully' })
@ApiResponse({ status: 400, description: 'Bad request - cart validation failed' })
@ApiResponse({ status: 404, description: 'Cart, user, restaurant, address, or payment method not found' })
create(@UserId() userId: string, @RestId() restaurantId: string) {
@Post('public/checkout')
@ApiOperation({ summary: 'Checkout : create order and payment record' })
checkout(@UserId() userId: string, @RestId() restaurantId: string) {
return this.ordersService.checkout(userId, restaurantId);
}
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Get('public/orders')
@ApiOperation({ summary: 'Get all orders' })
@ApiResponse({ status: 200, description: 'Orders fetched successfully' })
@ApiResponse({ status: 404, description: 'No orders found' })
findAll() {
return this.ordersService.findAll();
}
@Get(':id')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Get('public/orders/:id')
findOne(@Param('id') id: string) {
return this.ordersService.findOne(+id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() updateOrderDto: UpdateOrderDto) {
return this.ordersService.update(+id, updateOrderDto);
}
// @Patch(':id')
// update(@Param('id') id: string, @Body() updateOrderDto: UpdateOrderDto) {
// return this.ordersService.update(+id, updateOrderDto);
// }
@Delete(':id')
remove(@Param('id') id: string) {
return this.ordersService.remove(+id);
}
// @Delete(':id')
// remove(@Param('id') id: string) {
// return this.ordersService.remove(+id);
// }
}