order
This commit is contained in:
@@ -223,12 +223,8 @@ export class OrderService {
|
||||
|
||||
async confirmOrderItem(userId: string, orderId: string, orderItemId: number) {
|
||||
|
||||
const orderItem = await this.orderItemRepository.findOne({ id: orderItemId, order: { id: orderId } },
|
||||
{ populate: ['order', 'order.user'] })
|
||||
const orderItem = await this.findOrderItemOrFail(orderId, orderItemId)
|
||||
|
||||
if (!orderItem) {
|
||||
throw new BadRequestException("Order Item not found")
|
||||
}
|
||||
|
||||
if (orderItem.order.user.id !== userId) {
|
||||
throw new BadRequestException("Order Item does not belong to you")
|
||||
@@ -516,7 +512,7 @@ export class OrderService {
|
||||
|
||||
async findOrderItemOrFail(orderId: string, itemId: number) {
|
||||
const orderItem = await this.orderItemRepository.findOne({ id: itemId, order: { id: orderId } },
|
||||
{ populate: [] })
|
||||
{ populate: ['order', 'order.user'] })
|
||||
if (!orderItem) {
|
||||
throw new BadRequestException('Order item not found')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user