@@ -1955,15 +1955,6 @@
|
|||||||
"length": 26,
|
"length": 26,
|
||||||
"mappedType": "character"
|
"mappedType": "character"
|
||||||
},
|
},
|
||||||
"quantity": {
|
|
||||||
"name": "quantity",
|
|
||||||
"type": "int",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"mappedType": "integer"
|
|
||||||
},
|
|
||||||
"description": {
|
"description": {
|
||||||
"name": "description",
|
"name": "description",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20260626160000 extends Migration {
|
||||||
|
|
||||||
|
override async up(): Promise<void> {
|
||||||
|
this.addSql(`alter table "request_items" drop column "quantity";`);
|
||||||
|
}
|
||||||
|
|
||||||
|
override async down(): Promise<void> {
|
||||||
|
this.addSql(`alter table "request_items" add column "quantity" int not null default 1;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
IsString,
|
IsString,
|
||||||
IsArray,
|
IsArray,
|
||||||
IsNumber,
|
|
||||||
IsNotEmpty,
|
IsNotEmpty,
|
||||||
ArrayMinSize,
|
ArrayMinSize,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
Min,
|
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
@@ -36,11 +34,6 @@ export class CreateRequestItemDto {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
productId: string;
|
productId: string;
|
||||||
|
|
||||||
@IsNumber()
|
|
||||||
@Min(1, { message: 'Quantity must be at least 1' })
|
|
||||||
@ApiProperty({ minimum: 1 })
|
|
||||||
quantity: number;
|
|
||||||
|
|
||||||
@ApiPropertyOptional({ type: [RequestItemDto], description: 'Product attribute field values' })
|
@ApiPropertyOptional({ type: [RequestItemDto], description: 'Product attribute field values' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@@ -69,7 +62,6 @@ export class CreateRequestDto {
|
|||||||
example: [
|
example: [
|
||||||
{
|
{
|
||||||
productId: '01ARZ3NDEKTSV4RRFFQ69G5FAV',
|
productId: '01ARZ3NDEKTSV4RRFFQ69G5FAV',
|
||||||
quantity: 100,
|
|
||||||
attributes: [{ fieldId: 'field_01', value: 'blue' }],
|
attributes: [{ fieldId: 'field_01', value: 'blue' }],
|
||||||
attachments: [{ type: 'image', url: 'https://example.com/photo.jpg' }],
|
attachments: [{ type: 'image', url: 'https://example.com/photo.jpg' }],
|
||||||
description: 'توضیحات',
|
description: 'توضیحات',
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ export class RequestItem extends BaseEntity {
|
|||||||
@ManyToOne(() => Request)
|
@ManyToOne(() => Request)
|
||||||
request!: Request;
|
request!: Request;
|
||||||
|
|
||||||
@Property({ type: 'int' })
|
|
||||||
quantity!: number;
|
|
||||||
|
|
||||||
@Property({ type: 'text', nullable: true })
|
@Property({ type: 'text', nullable: true })
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export class RequestService {
|
|||||||
const requestItem = em.create(RequestItem, {
|
const requestItem = em.create(RequestItem, {
|
||||||
request,
|
request,
|
||||||
product,
|
product,
|
||||||
quantity: item.quantity,
|
|
||||||
attributes: item.attributes,
|
attributes: item.attributes,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
attachments: item.attachments,
|
attachments: item.attachments,
|
||||||
@@ -143,7 +142,6 @@ export class RequestService {
|
|||||||
const requestItem = em.create(RequestItem, {
|
const requestItem = em.create(RequestItem, {
|
||||||
request,
|
request,
|
||||||
product,
|
product,
|
||||||
quantity: item.quantity,
|
|
||||||
attributes: item.attributes,
|
attributes: item.attributes,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
attachments: item.attachments,
|
attachments: item.attachments,
|
||||||
@@ -179,7 +177,6 @@ export class RequestService {
|
|||||||
const requestItem = em.create(RequestItem, {
|
const requestItem = em.create(RequestItem, {
|
||||||
request,
|
request,
|
||||||
product,
|
product,
|
||||||
quantity: item.quantity,
|
|
||||||
attributes: item.attributes,
|
attributes: item.attributes,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
attachments: item.attachments,
|
attachments: item.attachments,
|
||||||
|
|||||||
Reference in New Issue
Block a user