This commit is contained in:
2025-12-06 10:01:04 +03:30
parent 83829856ad
commit 63ab227290
5 changed files with 94 additions and 20 deletions
+33 -11
View File
@@ -1,11 +1,11 @@
import { Controller, Get, Post, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { Controller, Get, Post, Param, UseGuards, Patch } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth, ApiParam } from '@nestjs/swagger';
import { OrdersService } from './orders.service';
import { AuthGuard } from '../auth/guards/auth.guard';
import { UserId } from '../../common/decorators/user-id.decorator';
import { RestId } from 'src/common/decorators/rest-id.decorator';
import { AdminAuthGuard } from '../auth/guards/adminAuth.guard';
@ApiTags('orders')
@Controller()
export class OrdersController {
@@ -27,6 +27,13 @@ export class OrdersController {
return this.ordersService.findAll(restId);
}
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Get('public/orders/:id')
findOne(@Param('id') id: string) {
return this.ordersService.findOne(+id);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Get('admin/orders')
@@ -35,17 +42,32 @@ export class OrdersController {
return this.ordersService.findAll(restId);
}
@UseGuards(AuthGuard)
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Get('public/orders/:id')
findOne(@Param('id') id: string) {
return this.ordersService.findOne(+id);
@Patch('admin/orders/:orderId/confirm')
@ApiOperation({ summary: 'Accept an order' })
@ApiParam({ name: 'orderId', description: 'Order ID' })
acceptOrder(@Param('orderId') orderId: string) {
return this.ordersService.acceptOrder(orderId);
}
// @Patch(':id')
// update(@Param('id') id: string, @Body() updateOrderDto: UpdateOrderDto) {
// return this.ordersService.update(+id, updateOrderDto);
// }
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Patch('admin/orders/:orderId/reject')
@ApiOperation({ summary: 'Reject an order' })
@ApiParam({ name: 'orderId', description: 'Order ID' })
rejectOrder(@Param('orderId') orderId: string) {
return this.ordersService.acceptOrder(orderId);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Patch('admin/orders/:orderId/ready')
@ApiOperation({ summary: 'Ready for pickup an order' })
@ApiParam({ name: 'orderId', description: 'Order ID' })
readyForPickup(@Param('orderId') orderId: string) {
return this.ordersService.readyForDelivery(orderId);
}
// @Delete(':id')
// remove(@Param('id') id: string) {