import { ApiProperty, OmitType, PartialType } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsArray, IsBoolean, IsInt, IsNumberString, IsObject, IsOptional, IsString, Min, ValidateNested, } from 'class-validator'; import { CreateGoodDto } from './create-good.dto'; export class CustomGoodDetailDto { @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() productCode?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() englishName?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() blankDesignUrl?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() detailsPageVideoUrl?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() textureName?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsInt() @Min(0) productionCycleHours?: number | null; @ApiProperty({ required: false, nullable: true, example: '208.000' }) @IsOptional() @IsNumberString() minWeightG?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() productionProcess?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() materialDescription?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() reminder?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() productPerformance?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() applicableScenarios?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() washingInstructions?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() specialDescription?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() designExplanation?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() designArea?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() pictureRequest?: string | null; @ApiProperty({ required: false, nullable: true, type: Object }) @IsOptional() @IsObject() sizeChart?: Record | null; @ApiProperty({ required: false, nullable: true, type: Object }) @IsOptional() @IsObject() packageSpecs?: Record | null; @ApiProperty({ required: false, nullable: true, type: Object }) @IsOptional() @IsObject() options?: Record | null; @ApiProperty({ required: false, nullable: true, type: Object }) @IsOptional() @IsObject() media?: Record | null; } export class CustomGoodVariantDto { @ApiProperty() @IsString() sku!: string; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() sizeName?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() sizeId?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() colorName?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() colorHex?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() colorId?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsString() imageUrl?: string | null; @ApiProperty({ required: false, nullable: true, example: '28.00' }) @IsOptional() @IsNumberString() price?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsNumberString() originalPrice?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsNumberString() weightG?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsNumberString() boxLengthCm?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsNumberString() boxWidthCm?: string | null; @ApiProperty({ required: false, nullable: true }) @IsOptional() @IsNumberString() boxHeightCm?: string | null; @ApiProperty({ required: false, nullable: true, type: Object }) @IsOptional() @IsObject() designData?: Record | null; @ApiProperty({ required: false, default: true }) @IsOptional() @IsBoolean() enabled?: boolean; @ApiProperty({ required: false, default: 0 }) @IsOptional() @IsInt() @Min(0) sortOrder?: number; } export class CreateCustomGoodDto extends OmitType(CreateGoodDto, [ 'originGoodId', ] as const) { @ApiProperty({ required: false, nullable: true, example: '28.00' }) @IsOptional() @IsNumberString() goodPrice?: string | null; @ApiProperty({ required: false, description: '物流归因(入族后参与价格矩阵)', example: '包邮' }) @IsOptional() @IsString() logisticsLabel?: string; @ApiProperty({ required: false, description: '工艺/印花数量归因', example: '双面印花' }) @IsOptional() @IsString() craftLabel?: string; @ApiProperty({ required: false }) @IsOptional() @IsString() skuCode?: string; @ApiProperty({ required: false }) @IsOptional() @IsString() warehouseLabel?: string; @ApiProperty({ required: false, description: '挂入的产品族 id(缺省为独立商品)', example: '12' }) @IsOptional() @IsNumberString() familyId?: string; @ApiProperty({ required: false, type: CustomGoodDetailDto }) @IsOptional() @ValidateNested() @Type(() => CustomGoodDetailDto) detail?: CustomGoodDetailDto; @ApiProperty({ required: false, type: [CustomGoodVariantDto] }) @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => CustomGoodVariantDto) variants?: CustomGoodVariantDto[]; } export class UpdateCustomGoodContentDto extends PartialType( OmitType(CreateCustomGoodDto, [ 'countryId', 'categoryId', 'tagIds', 'positionId', 'goodPriority', ] as const), ) {}