This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Post, Param, UseGuards, Patch, Query, Body } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Param, UseGuards, Patch, Query, Body, Delete } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth, ApiParam, ApiHeader, ApiBody } from '@nestjs/swagger';
|
||||
import { OrdersService } from '../providers/orders.service';
|
||||
import { AuthGuard } from '../../auth/guards/auth.guard';
|
||||
@@ -13,8 +13,11 @@ import { Permissions } from 'src/common/decorators/permissions.decorator';
|
||||
import { Permission } from 'src/common/enums/permission.enum';
|
||||
import { AdminCreateOrderDto } from '../dto/admin-create-order.dto';
|
||||
import { AdminUpdateOrderFeesDto } from '../dto/admin-update-order-fees.dto';
|
||||
import { AdminAddOrderItemDto } from '../dto/admin-add-order-item.dto';
|
||||
import { AdminUpdateOrderItemDto } from '../dto/admin-update-order-item.dto';
|
||||
import { FoodOrderReportDto } from '../dto/food-order-report.dto';
|
||||
import { DailyOrderReportDto } from '../dto/daily-order-report.dto';
|
||||
import { AdminRefundOrderDto } from '../dto/admin-refund-order.dto';
|
||||
|
||||
@ApiTags('orders')
|
||||
@ApiBearerAuth()
|
||||
@@ -94,6 +97,78 @@ export class OrdersController {
|
||||
return this.ordersService.findOne(orderId, restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Patch('admin/orders/:orderId/fees')
|
||||
@ApiOperation({ summary: 'Update order delivery fee, packing fee, and preparation time' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiBody({ type: AdminUpdateOrderFeesDto })
|
||||
updateOrderFees(
|
||||
@Param('orderId') orderId: string,
|
||||
@Body() dto: AdminUpdateOrderFeesDto,
|
||||
@RestId() restId: string,
|
||||
) {
|
||||
return this.ordersService.updateOrderFees(orderId, restId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Post('admin/orders/:orderId/items')
|
||||
@ApiOperation({ summary: 'Add an item to an existing order' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiBody({ type: AdminAddOrderItemDto })
|
||||
addOrderItem(
|
||||
@Param('orderId') orderId: string,
|
||||
@Body() dto: AdminAddOrderItemDto,
|
||||
@RestId() restId: string,
|
||||
) {
|
||||
return this.ordersService.addOrderItem(orderId, restId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Patch('admin/orders/:orderId/items/:itemId')
|
||||
@ApiOperation({ summary: 'Update quantity of an order item' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiParam({ name: 'itemId', description: 'Order item ID' })
|
||||
@ApiBody({ type: AdminUpdateOrderItemDto })
|
||||
updateOrderItem(
|
||||
@Param('orderId') orderId: string,
|
||||
@Param('itemId') itemId: string,
|
||||
@Body() dto: AdminUpdateOrderItemDto,
|
||||
@RestId() restId: string,
|
||||
) {
|
||||
return this.ordersService.updateOrderItemQuantity(orderId, restId, itemId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Delete('admin/orders/:orderId/items/:itemId')
|
||||
@ApiOperation({ summary: 'Remove an item from an order' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiParam({ name: 'itemId', description: 'Order item ID' })
|
||||
removeOrderItem(
|
||||
@Param('orderId') orderId: string,
|
||||
@Param('itemId') itemId: string,
|
||||
@RestId() restId: string,
|
||||
) {
|
||||
return this.ordersService.removeOrderItem(orderId, restId, itemId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Post('admin/orders/:orderId/refund')
|
||||
@ApiOperation({ summary: 'Refund order payment(s) by amount' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiBody({ type: AdminRefundOrderDto })
|
||||
refundOrder(
|
||||
@Param('orderId') orderId: string,
|
||||
@Body() dto: AdminRefundOrderDto,
|
||||
@RestId() restId: string,
|
||||
) {
|
||||
return this.ordersService.refundOrder(orderId, restId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Patch('admin/orders/:orderId/:status')
|
||||
@@ -114,20 +189,6 @@ export class OrdersController {
|
||||
return this.ordersService.changeOrderStatus(orderId, restId, status, 'admin', dto?.desc);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Patch('admin/orders/:orderId/fees')
|
||||
@ApiOperation({ summary: 'Update order delivery fee, packing fee, and preparation time' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiBody({ type: AdminUpdateOrderFeesDto })
|
||||
updateOrderFees(
|
||||
@Param('orderId') orderId: string,
|
||||
@Body() dto: AdminUpdateOrderFeesDto,
|
||||
@RestId() restId: string,
|
||||
) {
|
||||
return this.ordersService.updateOrderFees(orderId, restId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.VIEW_REPORTS)
|
||||
@ApiOperation({ summary: 'Get Stats for report page' })
|
||||
|
||||
Reference in New Issue
Block a user