order refactor
This commit is contained in:
@@ -9,53 +9,35 @@ import { FindOrdersDto } from '../dto/find-orders.dto';
|
||||
import { OrderStatus } from '../interface/order-status';
|
||||
|
||||
@ApiTags('orders')
|
||||
@ApiBearerAuth()
|
||||
@ApiHeader({
|
||||
name: 'X-Slug',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
default: 'zhivan',
|
||||
},
|
||||
})
|
||||
@Controller()
|
||||
export class OrdersController {
|
||||
constructor(private readonly ordersService: OrdersService) {}
|
||||
constructor(private readonly ordersService: OrdersService) { }
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post('public/checkout')
|
||||
@ApiOperation({ summary: 'Checkout : create order and payment record' })
|
||||
@ApiHeader({
|
||||
name: 'X-Slug',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
default: 'zhivan',
|
||||
},
|
||||
})
|
||||
checkout(@UserId() userId: string, @RestId() restaurantId: string) {
|
||||
return this.ordersService.checkout(userId, restaurantId);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('public/orders')
|
||||
@ApiOperation({ summary: 'Get all orders with pagination and filters' })
|
||||
@ApiHeader({
|
||||
name: 'X-Slug',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
default: 'zhivan',
|
||||
},
|
||||
})
|
||||
findAll(@RestId() restId: string, @Query() dto: FindOrdersDto, @UserId() userId: string) {
|
||||
return this.ordersService.findAllForUser(restId, dto, userId);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get an order By id for User' })
|
||||
@ApiHeader({
|
||||
name: 'X-Slug',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
default: 'zhivan',
|
||||
},
|
||||
})
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@Get('public/orders/:orderId')
|
||||
findOne(@Param('orderId') orderId: string, @RestId() restId: string) {
|
||||
@@ -63,24 +45,14 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('public/orders/:id/cancel')
|
||||
@ApiOperation({ summary: 'Cancel an order By User' })
|
||||
@ApiHeader({
|
||||
name: 'X-Slug',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
default: 'zhivan',
|
||||
},
|
||||
})
|
||||
@ApiParam({ name: 'id', description: 'Order ID' })
|
||||
cancelOrder(@Param('id') id: string, @RestId() restId: string) {
|
||||
return this.ordersService.cancelOrderAsUser(id, restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/orders')
|
||||
@ApiOperation({ summary: 'Get all orders with pagination and filters' })
|
||||
findAllAdmin(@RestId() restId: string, @Query() dto: FindOrdersDto) {
|
||||
@@ -88,7 +60,6 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get an order By id for User' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@Get('admin/orders/:orderId')
|
||||
@@ -97,7 +68,6 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('admin/orders/:orderId/confirm')
|
||||
@ApiOperation({ summary: 'Accept an order' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@@ -106,7 +76,6 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('admin/orders/:id/prepare')
|
||||
@ApiOperation({ summary: 'Prepare an order By Admin' })
|
||||
@ApiParam({ name: 'id', description: 'Order ID' })
|
||||
@@ -115,7 +84,6 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('admin/orders/:orderId/reject')
|
||||
@ApiOperation({ summary: 'Reject an order' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@@ -142,7 +110,6 @@ export class OrdersController {
|
||||
// }
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('admin/orders/:orderId/:status')
|
||||
@ApiOperation({ summary: 'Update an order status' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
|
||||
Reference in New Issue
Block a user