Files
shop-api/src/modules/product/DTO/addVariant.dto.ts
T
2025-10-26 16:57:53 +03:30

107 lines
3.4 KiB
TypeScript

import { Expose } from "class-transformer";
import { IsNotEmpty, IsNumber, IsOptional, Min } from "class-validator";
import { ApiProperty } from "../../../common/decorator/swggerDocs";
import { IsValidId } from "../../../common/decorator/validation.decorator";
import { ColorModel } from "../../category/models/color.model";
import { MeterageModel } from "../../category/models/meterage.model";
import { SizeModel } from "../../category/models/size.model";
import { WarrantyModel } from "../../warranty/models/warranty.model";
// import { ShipmentModel } from "../../../models/shipment.model";
export class AddVariantDTO {
// @Expose()
// @IsNotEmpty()
// @IsValidId(WarrantyModel)
// @ApiProperty({ type: "number", description: "product id", example: 100002 })
// productId: number;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsValidId(ColorModel)
@ApiProperty({ type: "number", description: "color id ==> one of color,size or meterage should send", example: 1 })
colorId?: number;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsValidId(SizeModel)
@ApiProperty({ type: "number", description: "size id ==> one of color,size or meterage should send", example: 5 })
sizeId?: number;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsValidId(MeterageModel)
@ApiProperty({ type: "number", description: "meterage id ==> one of color,size or meterage should send", example: 5 })
meterageId?: number;
@Expose()
@IsNotEmpty()
@IsValidId(WarrantyModel)
@ApiProperty({ type: "number", description: "warranty id of the product", example: 102 })
warrantyId: number;
@Expose()
@IsNotEmpty()
@IsNumber()
@ApiProperty({ type: "number", description: "maximum number of product can purchase in one order", example: 2 })
order_limit: number;
//
@Expose()
@IsOptional()
@IsNotEmpty()
@ApiProperty({ type: "string", description: "special code of product for seller only", example: "FPHK10" })
sellerSpecialCode?: string;
@Expose()
@IsNotEmpty()
@Min(1000, { message: "حداقل قیمت برای کالا ۱۰۰۰۰ تومان می باشد " })
@IsNumber()
@ApiProperty({ type: "number", description: "the price of product in toman", example: 5432510 })
retail_price: number;
//Dimensions
@Expose()
@IsNotEmpty()
@ApiProperty({ type: "number", description: "the weight of product package in gram", example: 250 })
package_weight: number;
@Expose()
@IsNotEmpty()
@ApiProperty({ type: "number", description: "the height of product package in cm", example: 25 })
package_height: number;
@Expose()
@IsNotEmpty()
@ApiProperty({ type: "number", description: "the length of product package in cm", example: 45 })
package_length: number;
@Expose()
@IsNotEmpty()
@ApiProperty({ type: "number", description: "the width of product package in cm", example: 10 })
package_width: number;
// @Expose()
// @IsNotEmpty()
// @IsArray()
// @IsNumber({}, { each: true })
// // @IsValidId(ShipmentModel)
// @ApiProperty({ type: "Array", description: "the array of shipment provider", example: [101, 102] })
// shipmentsId: number[];
//
@Expose()
@IsNotEmpty()
@ApiProperty({ type: "number", description: "the time take to ship product quantity of product in day", example: 10 })
postingTime: number;
//
@Expose()
@IsNotEmpty()
@IsNumber()
@ApiProperty({ type: "number", description: "the stock quantity of product", example: 10 })
stock: number;
}