This commit is contained in:
2026-01-27 15:51:29 +03:30
parent 355d4afaa2
commit 18400efd55
2 changed files with 14 additions and 2 deletions
@@ -26,6 +26,13 @@ export class OrderController {
return this.orderService.createOrderAsUser(userId, body);
}
@Get('public/order/:id')
@UseGuards(AuthGuard)
@ApiOperation({ summary: 'order detail' })
orderDetail(@Param('id') orderId: string, @UserId() userId: string) {
return this.orderService.getOrderAsUser(userId, orderId);
}
@Delete('public/order/:id')
@UseGuards(AuthGuard)
@ApiOperation({ summary: 'Delete order ' })
+7 -2
View File
@@ -116,7 +116,6 @@ export class OrderService {
return orderItem
}
async updateOrderItemAsUser(userId: string, orderId: string, itemId: string, dto: UpdateOrderItemDtoAsUser) {
const order = await this.findOrderOrFail(orderId)
@@ -147,7 +146,6 @@ export class OrderService {
return orderItem
}
async removeOrderItemAsAdmin(orderId: string, itemId: string) {
const order = await this.findOrderOrFail(orderId)
@@ -296,6 +294,13 @@ export class OrderService {
await this.em.flush()
}
async getOrderAsUser(userId: string, orderId: string) {
const order = await this.findOrderOrFail(orderId)
if (order.user.id !== userId) {
throw new BadRequestException("This order is not belongs to you")
}
}
// ==================== Entity Methods ====================
private async createOrderItem(order: Order, product: Product, dto: CreateOrderItemParam, em?: EntityManager) {