orders pagination

This commit is contained in:
2025-12-06 10:36:51 +03:30
parent 63ab227290
commit 8336e7f81a
5 changed files with 176 additions and 26 deletions
+16 -13
View File
@@ -1,11 +1,12 @@
import { Controller, Get, Post, Param, UseGuards, Patch } from '@nestjs/common';
import { Controller, Get, Post, Param, UseGuards, Patch, Query } 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';
import { FindOrdersDto } from './dto/find-orders.dto';
@ApiTags('orders')
@Controller()
export class OrdersController {
@@ -22,9 +23,9 @@ export class OrdersController {
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Get('public/orders')
@ApiOperation({ summary: 'Get all orders' })
findAll(@RestId() restId: string) {
return this.ordersService.findAll(restId);
@ApiOperation({ summary: 'Get all orders with pagination and filters' })
findAll(@RestId() restId: string, @Query() dto: FindOrdersDto) {
return this.ordersService.findAll(restId, dto);
}
@UseGuards(AuthGuard)
@@ -34,12 +35,19 @@ export class OrdersController {
return this.ordersService.findOne(+id);
}
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Patch('public/orders/:id/cancel')
cancelOrder(@Param('id') id: string) {
return this.ordersService.findOne(+id);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Get('admin/orders')
@ApiOperation({ summary: 'Get all orders' })
findAllAdmin(@RestId() restId: string) {
return this.ordersService.findAll(restId);
@ApiOperation({ summary: 'Get all orders with pagination and filters' })
findAllAdmin(@RestId() restId: string, @Query() dto: FindOrdersDto) {
return this.ordersService.findAll(restId, dto);
}
@UseGuards(AdminAuthGuard)
@@ -68,9 +76,4 @@ export class OrdersController {
readyForPickup(@Param('orderId') orderId: string) {
return this.ordersService.readyForDelivery(orderId);
}
// @Delete(':id')
// remove(@Param('id') id: string) {
// return this.ordersService.remove(+id);
// }
}