order item get
This commit is contained in:
@@ -112,6 +112,13 @@ export class OrderController {
|
||||
return this.orderService.findOrderOrFail(orderId);
|
||||
}
|
||||
|
||||
@Get('admin/orders/item/:id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiOperation({ summary: 'order item detail' })
|
||||
getOrderItem(@Param('id') itemId: string) {
|
||||
return this.orderService.findOrderItemOrFailByItemId(+itemId);
|
||||
}
|
||||
|
||||
|
||||
// @Patch('admin/orders/:orderId')
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { IsArray, } from 'class-validator';
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IAttachment, IField } from '../interface/order.interface';
|
||||
import { IField } from '../interface/order.interface';
|
||||
|
||||
export class CreatePrintFormDto {
|
||||
@ApiPropertyOptional({ example: [] })
|
||||
@ApiPropertyOptional({
|
||||
example: [{
|
||||
fieldId: 10, value: ''
|
||||
}]
|
||||
})
|
||||
@IsArray()
|
||||
printAttributes?: IField[]
|
||||
|
||||
@ApiPropertyOptional({ example: [] })
|
||||
@IsArray()
|
||||
printAttachments?: IAttachment[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ export class OrderService {
|
||||
|
||||
const { designerId, productId, ...itemRest } = item
|
||||
|
||||
let newProduct=currentItem.product
|
||||
let newProduct = currentItem.product
|
||||
|
||||
if (productId && productId !== currentItem.product.id) {
|
||||
|
||||
@@ -446,7 +446,7 @@ export class OrderService {
|
||||
const admin = adminId ? await this.adminService.findOrFail(adminId) : undefined
|
||||
const products = await this.productService.findProductsByIds(items.map(item => item.productId))
|
||||
const desiners = await this.adminService.findByIds(items.map(item => item.designerId).filter(id => id != null))
|
||||
|
||||
|
||||
const productMap = new Map(
|
||||
products.map(p => [Number(p.id), p])
|
||||
);
|
||||
@@ -629,4 +629,13 @@ export class OrderService {
|
||||
return orderItem
|
||||
}
|
||||
|
||||
async findOrderItemOrFailByItemId(itemId: number) {
|
||||
const orderItem = await this.orderItemRepository.findOne({ id: itemId },
|
||||
{ populate: ['order', 'order.user'] })
|
||||
if (!orderItem) {
|
||||
throw new BadRequestException('Order item not found')
|
||||
}
|
||||
return orderItem
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user