|
| 1 | +import { ApiProperty } from '@nestjs/swagger'; |
| 2 | +import { |
| 3 | + IsArray, |
| 4 | + IsBoolean, |
| 5 | + IsOptional, |
| 6 | + IsString, |
| 7 | + IsNumber, |
| 8 | + ValidateNested, |
| 9 | + MaxLength, |
| 10 | +} from 'class-validator'; |
| 11 | +import { Type } from 'class-transformer'; |
| 12 | + |
| 13 | +export class UploadImageDto { |
| 14 | + @ApiProperty({ |
| 15 | + example: 'http://example.com/image.jpg', |
| 16 | + description: '업로드할 이미지의 URL입니다.', |
| 17 | + }) |
| 18 | + @IsString() |
| 19 | + imageurl: string; |
| 20 | + |
| 21 | + @ApiProperty({ example: 1, description: '이미지의 순서 번호입니다.' }) |
| 22 | + @IsNumber() |
| 23 | + orderNum: number; |
| 24 | +} |
| 25 | + |
| 26 | +export class UploadClothingDto { |
| 27 | + @ApiProperty({ |
| 28 | + example: 'http://example.com/clothing.jpg', |
| 29 | + description: '업로드할 옷 정보 URL입니다.', |
| 30 | + }) |
| 31 | + @IsString() |
| 32 | + imageUrl: string; |
| 33 | + |
| 34 | + @ApiProperty({ |
| 35 | + example: '브랜드명', |
| 36 | + description: '옷 브랜드명입니다.', |
| 37 | + }) |
| 38 | + @IsString() |
| 39 | + @MaxLength(100) |
| 40 | + brandName: string; |
| 41 | + |
| 42 | + @ApiProperty({ example: '모델명', description: '옷 상품명입니다.' }) |
| 43 | + @IsString() |
| 44 | + @MaxLength(100) |
| 45 | + modelName: string; |
| 46 | + |
| 47 | + @ApiProperty({ example: '모델 넘버', description: '옷 모델 넘버입니다.' }) |
| 48 | + @IsString() |
| 49 | + @MaxLength(100) |
| 50 | + modelNumber: string; |
| 51 | + |
| 52 | + @ApiProperty({ |
| 53 | + example: 'http://example.com/product', |
| 54 | + description: '옷 상품 링크입니다.', |
| 55 | + }) |
| 56 | + @IsString() |
| 57 | + url: string; |
| 58 | +} |
| 59 | + |
| 60 | +export class CreatePostDto { |
| 61 | + @ApiProperty({ |
| 62 | + example: '게시물 내용', |
| 63 | + description: '게시물 내용입니다. 최대 100자까지 입력할 수 있습니다.', |
| 64 | + }) |
| 65 | + @IsString() |
| 66 | + @MaxLength(100) |
| 67 | + content: string; |
| 68 | + |
| 69 | + @ApiProperty({ |
| 70 | + type: [UploadImageDto], |
| 71 | + description: '게시물에 포함될 이미지 목록입니다.', |
| 72 | + }) |
| 73 | + @IsOptional() |
| 74 | + @IsArray() |
| 75 | + @ValidateNested({ each: true }) |
| 76 | + @Type(() => UploadImageDto) |
| 77 | + postImages?: UploadImageDto[]; |
| 78 | + |
| 79 | + @ApiProperty({ |
| 80 | + required: false, |
| 81 | + type: [String], |
| 82 | + example: ['가을'], |
| 83 | + description: |
| 84 | + '게시글에 포함될 스타일 태그 목록입니다. 스타일 태그에 저장된 태그만 입력 가능합니다.', |
| 85 | + }) |
| 86 | + @IsOptional() |
| 87 | + @IsArray() |
| 88 | + @MaxLength(20, { each: true }) |
| 89 | + postStyletags?: string[]; |
| 90 | + |
| 91 | + @ApiProperty({ |
| 92 | + required: false, |
| 93 | + type: [UploadClothingDto], |
| 94 | + description: '게시물에 포함될 옷 정보 리스트입니다.', |
| 95 | + }) |
| 96 | + @IsOptional() |
| 97 | + @IsArray() |
| 98 | + @ValidateNested({ each: true }) |
| 99 | + @Type(() => UploadClothingDto) |
| 100 | + postClothings?: UploadClothingDto[]; |
| 101 | + |
| 102 | + @ApiProperty({ |
| 103 | + example: false, |
| 104 | + description: '대표 게시물 여부입니다.', |
| 105 | + }) |
| 106 | + @IsBoolean() |
| 107 | + isRepresentative: boolean; |
| 108 | +} |
0 commit comments