update
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-22 23:36:16 +03:30
parent d4212ac5e4
commit 8cd855827d
2 changed files with 22 additions and 7 deletions
@@ -87,9 +87,9 @@ export class OrderController {
@Delete('admin/orders/:orderId')
@UseGuards(AdminAuthGuard)
@Permissions(PermissionEnum.DELETE_ORDER)
@ApiOperation({ summary: 'Soft Delete Order ' })
softDeleteOrder(@Param('orderId') orderId: string) {
return this.orderService.softDeleteOrder(orderId);
@ApiOperation({ summary: 'Delete Order' })
deleteOrder(@Param('orderId') orderId: string) {
return this.orderService.deleteOrder(orderId);
}
+19 -4
View File
@@ -277,10 +277,25 @@ export class OrderService {
return order;
}
async softDeleteOrder(orderId: string): Promise<void> {
const order = await this.findOrderOrFail(orderId);
order.deletedAt = new Date();
await this.em.flush();
async deleteOrder(orderId: string): Promise<void> {
await this.em.transactional(async (em) => {
const order = await em.findOne(Order, { id: orderId }, { populate: ['print'] });
if (!order) {
throw new NotFoundException(`Order with ID ${orderId} not found.`);
}
await this.chatService.deleteChatsByRefId(orderId, em);
await em.nativeDelete(OrderDesigner, { order: { id: orderId } });
const printId = order.print?.id;
if (printId) {
await em.nativeUpdate(Order, { id: orderId }, { print: null });
await em.nativeDelete(OrderPrintValue, { orderPrint: { id: printId } });
await em.nativeDelete(OrderPrint, { id: printId });
}
await em.nativeDelete(Order, { id: orderId });
});
}