This commit is contained in:
2026-02-10 10:15:35 +03:30
parent e079527687
commit c060be3069
65 changed files with 461 additions and 461 deletions
@@ -3,7 +3,7 @@ import { ApiTags, ApiOperation, ApiBearerAuth, ApiParam, ApiHeader, ApiBody } fr
import { OrdersService } from '../providers/orders.service';
import { AuthGuard } from '../../auth/guards/auth.guard';
import { UserId } from '../../../common/decorators/user-id.decorator';
import { ShopId } from 'src/common/decorators/rest-id.decorator';
import { ShopId } from 'src/common/decorators/shop-id.decorator';
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
import { FindOrdersDto } from '../dto/find-orders.dto';
import { OrderStatus } from '../interface/order.interface';
@@ -22,16 +22,16 @@ export class OrdersController {
@Post('public/checkout')
@ApiHeader(API_HEADER_SLUG)
@ApiOperation({ summary: 'Checkout : create order and payment record' })
checkout(@UserId() userId: string, @ShopId() restaurantId: string) {
return this.ordersService.checkout(userId, restaurantId);
checkout(@UserId() userId: string, @ShopId() shopId: string) {
return this.ordersService.checkout(userId, shopId);
}
@UseGuards(AuthGuard)
@Get('public/orders')
@ApiHeader(API_HEADER_SLUG)
@ApiOperation({ summary: 'Get all orders with pagination and filters' })
findAll(@ShopId() restId: string, @Query() dto: FindOrdersDto, @UserId() userId: string) {
return this.ordersService.findAllForUser(restId, dto, userId);
findAll(@ShopId() shopId: string, @Query() dto: FindOrdersDto, @UserId() userId: string) {
return this.ordersService.findAllForUser(shopId, dto, userId);
}
@UseGuards(AuthGuard)
@@ -39,8 +39,8 @@ export class OrdersController {
@ApiParam({ name: 'orderId', description: 'Order ID' })
@ApiHeader(API_HEADER_SLUG)
@Get('public/orders/:orderId')
findOne(@Param('orderId') orderId: string, @ShopId() restId: string) {
return this.ordersService.findOne(orderId, restId);
findOne(@Param('orderId') orderId: string, @ShopId() shopId: string) {
return this.ordersService.findOne(orderId, shopId);
}
@UseGuards(AuthGuard)
@@ -58,9 +58,9 @@ export class OrdersController {
@Body() dto: UpdateOrderStatusDto,
@Param('id') orderId: string,
@Param('status') status: OrderStatus,
@ShopId() restId: string,
@ShopId() shopId: string,
) {
return this.ordersService.changeOrderStatus(orderId, restId, status, 'user', dto?.desc);
return this.ordersService.changeOrderStatus(orderId, shopId, status, 'user', dto?.desc);
}
/******************** Admin Routes **********************/
@@ -68,8 +68,8 @@ export class OrdersController {
@Permissions(Permission.MANAGE_ORDERS)
@Get('admin/orders')
@ApiOperation({ summary: 'Get all orders with pagination and filters' })
findAllAdmin(@ShopId() restId: string, @Query() dto: FindOrdersDto) {
return this.ordersService.findAllForAdmin(restId, dto);
findAllAdmin(@ShopId() shopId: string, @Query() dto: FindOrdersDto) {
return this.ordersService.findAllForAdmin(shopId, dto);
}
@UseGuards(AdminAuthGuard)
@@ -77,8 +77,8 @@ export class OrdersController {
@ApiOperation({ summary: 'Get an order By id for User' })
@ApiParam({ name: 'orderId', description: 'Order ID' })
@Get('admin/orders/:orderId')
findOneAsAdmin(@Param('orderId') orderId: string, @ShopId() restId: string) {
return this.ordersService.findOne(orderId, restId);
findOneAsAdmin(@Param('orderId') orderId: string, @ShopId() shopId: string) {
return this.ordersService.findOne(orderId, shopId);
}
@UseGuards(AdminAuthGuard)
@@ -96,17 +96,17 @@ export class OrdersController {
@Param('orderId') orderId: string,
@Body() dto: UpdateOrderStatusDto,
@Param('status') status: OrderStatus,
@ShopId() restId: string,
@ShopId() shopId: string,
) {
return this.ordersService.changeOrderStatus(orderId, restId, status, 'admin', dto?.desc);
return this.ordersService.changeOrderStatus(orderId, shopId, status, 'admin', dto?.desc);
}
@UseGuards(AdminAuthGuard)
@Permissions(Permission.VIEW_REPORTS)
@ApiOperation({ summary: 'Get Stats for report page' })
@Get('admin/orders/stats')
findStats(@ShopId() restId: string) {
return this.ordersService.getStats(restId);
findStats(@ShopId() shopId: string) {
return this.ordersService.getStats(shopId);
}
@UseGuards(AdminAuthGuard)
@@ -114,7 +114,7 @@ export class OrdersController {
@ApiOperation({ summary: 'Get product sales pie chart data for last month' })
@ApiHeader(API_HEADER_SLUG)
@Get('admin/orders/product-sales-pie-chart')
getFoodSalesPieChart(@ShopId() restId: string) {
return this.ordersService.getFoodSalesPieChart(restId);
getFoodSalesPieChart(@ShopId() shopId: string) {
return this.ordersService.getFoodSalesPieChart(shopId);
}
}