From 1165167619bae1f1652fd1cbd4f1dd2d1b35afe2 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 1 Dec 2025 22:58:56 +0330 Subject: [PATCH] order list --- src/modules/orders/orders.controller.ts | 5 ++++- src/modules/orders/orders.service.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/orders/orders.controller.ts b/src/modules/orders/orders.controller.ts index 21ab626..12e1ae0 100644 --- a/src/modules/orders/orders.controller.ts +++ b/src/modules/orders/orders.controller.ts @@ -22,7 +22,10 @@ export class OrdersController { return this.ordersService.create(userId, restaurantId); } - @Get() + @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(); } diff --git a/src/modules/orders/orders.service.ts b/src/modules/orders/orders.service.ts index 513045b..5933664 100644 --- a/src/modules/orders/orders.service.ts +++ b/src/modules/orders/orders.service.ts @@ -89,7 +89,6 @@ export class OrdersService { }; } else { // await this.cartService.clearCart(userId, restaurantId); - // For offline payment methods (cash on delivery, etc.), order is created and pending // Payment status will be updated when payment is confirmed // TODO: Implement offline payment confirmation flow if needed @@ -210,8 +209,12 @@ export class OrdersService { }; } - findAll() { - return `This action returns all orders`; + async findAll() { + const orders = await this.em.find(Order, {}, { populate: ['user', 'restaurant', 'address', 'paymentMethod'] }); + if (!orders) { + throw new NotFoundException('No orders found'); + } + return orders; } findOne(id: number) {