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