order print
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-18 00:15:12 +03:30
parent 02c3a2e01d
commit 2aefeb97d9
4 changed files with 14 additions and 3 deletions
@@ -1,9 +1,14 @@
import { IsArray, ValidateNested } from 'class-validator';
import { IsArray, IsNotEmpty, IsString, ValidateNested } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { OrderPrintValueDto } from './order-print-value.dto';
export class CreateOrderPrintDto {
@ApiProperty({ example: 'فرم چاپ سفارش' })
@IsString()
@IsNotEmpty()
title: string;
@ApiProperty({
type: [OrderPrintValueDto],
example: [{ fieldId: '', value: '' }],
@@ -1,4 +1,4 @@
import { Collection, Entity, OneToMany, OptionalProps, OneToOne } from '@mikro-orm/core';
import { Collection, Entity, OneToMany, OptionalProps, OneToOne, Property } from '@mikro-orm/core';
import { BaseEntity } from 'src/common/entities/base.entity';
import { Order } from './order.entity';
import { OrderPrintValue } from './order-print-value.entity';
@@ -7,6 +7,9 @@ import { OrderPrintValue } from './order-print-value.entity';
export class OrderPrint extends BaseEntity {
[OptionalProps]?: 'createdAt' | 'deletedAt';
@Property()
title: string;
@OneToMany(() => OrderPrintValue, (value) => value.orderPrint, { orphanRemoval: true })
values = new Collection<OrderPrintValue>(this);
@@ -33,6 +33,7 @@ export interface IOrderPrintValue {
export interface IOrderPrintResponse {
id: string;
title: string;
createdAt: Date;
deletedAt?: Date;
fileds: IOrderPrintValue[];
+3 -1
View File
@@ -377,8 +377,9 @@ export class OrderService {
if (print) {
await this.em.populate(print, ['values']);
print.values.removeAll();
print.title = dto.title;
} else {
print = this.em.create(OrderPrint, { order });
print = this.em.create(OrderPrint, { order, title: dto.title });
}
this.assignPrintValues(print, dto.fields, fieldMap);
@@ -401,6 +402,7 @@ export class OrderService {
private serializeOrderPrint(print: OrderPrint): IOrderPrintResponse {
return {
id: print.id,
title: print.title,
createdAt: print.createdAt,
deletedAt: print.deletedAt,
fileds: print.values.getItems().map((item) => ({