create order

This commit is contained in:
2025-11-30 23:52:55 +03:30
parent e5ad2e3b3a
commit 0923da619e
4 changed files with 234 additions and 13 deletions
+16 -6
View File
@@ -1,15 +1,25 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
import { OrdersService } from './orders.service';
import { CreateOrderDto } from './dto/create-order.dto';
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';
@Controller('orders')
@ApiTags('orders')
@Controller()
export class OrdersController {
constructor(private readonly ordersService: OrdersService) {}
@Post()
create(@Body() createOrderDto: CreateOrderDto) {
return this.ordersService.create(createOrderDto);
@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) {
return this.ordersService.create(userId, restaurantId);
}
@Get()