Files
inkreach-official-website/apps/api/src/goods/dto/batch-create-good.dto.ts
T

68 lines
1.4 KiB
TypeScript

import { ApiProperty } from '@nestjs/swagger';
import {
ArrayMinSize,
IsArray,
IsInt,
IsOptional,
Min,
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
export class BatchCreateItemDto {
@ApiProperty()
@IsInt()
@Min(1)
originGoodId!: number;
@ApiProperty({ required: false, nullable: true, type: [Number], description: '副源原产品 ID,不含主源' })
@IsOptional()
@IsArray()
@IsInt({ each: true })
@Min(1, { each: true })
mergedOriginGoodIds?: number[];
@ApiProperty({ required: false })
@IsOptional()
@IsInt()
@Min(0)
priority?: number;
}
export class BatchCreateGoodDto {
@ApiProperty({ type: [BatchCreateItemDto] })
@IsArray()
@ArrayMinSize(1)
@ValidateNested({ each: true })
@Type(() => BatchCreateItemDto)
items!: BatchCreateItemDto[];
@ApiProperty()
@IsInt()
@Min(1)
countryId!: number;
@ApiProperty()
@IsInt()
@Min(1)
categoryId!: number;
@ApiProperty({ required: false, nullable: true, type: [Number] })
@IsOptional()
@IsArray()
@IsInt({ each: true })
@Min(1, { each: true })
tagIds?: number[];
@ApiProperty({ required: false, nullable: true })
@IsOptional()
@IsInt()
@Min(1)
positionId?: number;
@ApiProperty({ required: false, default: 0 })
@IsOptional()
@IsInt()
@Min(0)
defaultPriority?: number;
}