- class-transform 적용
This commit is contained in:
geonhee-min
2025-12-16 16:25:02 +09:00
parent 70ae2c3fad
commit 290d87ff1c
4 changed files with 47 additions and 32 deletions

View File

@@ -1,4 +1,5 @@
import { BaseRequestDTO } from '@BaseRequestDTO';
import { Type as TransformType } from 'class-transformer';
import { IsArray, IsDateString, IsIn, IsString } from 'class-validator';
import { TypeArray, type Type } from 'src/scheduler/type/schedule/ScheduleType';
@@ -9,11 +10,11 @@ export class ScheduleCreateRequestDTO extends BaseRequestDTO {
@IsString()
content!: string;
@IsDateString()
startDate!: string;
@TransformType(() => Date)
startDate!: Date;
@IsDateString()
endDate!: string;
@TransformType(() => Date)
endDate!: Date;
@IsIn(TypeArray)
type!: Type;

View File

@@ -1,23 +1,28 @@
import type { BaseResponseDTO } from '@BaseResponseDTO';
import type { Status } from 'src/scheduler/type/schedule/ScheduleStatus';
import type { Type } from 'src/scheduler/type/schedule/ScheduleType';
import { Type as TransformType } from 'class-transformer';
export type ScheduleDetail = {
id: string;
name: string;
startDate: Date;
endDate: Date;
status: Status;
export class ScheduleDetail {
id!: string;
name!: string;
status!: Status;
content?: string;
isDeleted: boolean;
type: Type;
createdAt: string;
owner: string;
style: string;
startTime: string;
endTime: string;
isDeleted!: boolean;
type!: Type;
createdAt!: string;
owner!: string;
style!: string;
startTime!: string;
endTime!: string;
dayList?: string;
participantList?: string;
@TransformType(() => Date)
startDate!: Date;
@TransformType(() => Date)
endDate!: Date;
}
export type ScheduleDetailResponseDTO = BaseResponseDTO<ScheduleDetail>;

View File

@@ -1,20 +1,24 @@
import { BaseRequestDTO } from '@BaseRequestDTO';
import { IsArray, IsDateString, IsIn, IsNumberString, IsString, ValidateIf } from 'class-validator';
import { Type } from 'class-transformer';
import { IsArray, IsDate, IsIn, IsNumberString, IsString, ValidateIf } from 'class-validator';
import { StatusArray } from 'src/scheduler/type/schedule/ScheduleStatus';
import { TypeArray } from 'src/scheduler/type/schedule/ScheduleType';
export class ScheduleListRequestDTO extends BaseRequestDTO {
@ValidateIf(o => o.date !== undefined)
@IsDateString()
date?: string;
@Type(() => Date)
@IsDate()
date?: Date;
@ValidateIf(o => o.startDate !== undefined)
@IsDateString()
startDate?: string;
@Type(() => Date)
@IsDate()
startDate?: Date;
@ValidateIf(o => o.endDate !== undefined)
@IsDateString()
endDate?: string;
@Type(() => Date)
@IsDate()
endDate?: Date;
@ValidateIf(o => o.styleList !== undefined)
@IsArray()

View File

@@ -1,15 +1,20 @@
import type { BaseResponseDTO } from '@BaseResponseDTO';
import type { Status } from "src/scheduler/type/schedule/ScheduleStatus";
import type { Type } from "src/scheduler/type/schedule/ScheduleType";
import { Type as TransformType } from 'class-transformer';
export type ScheduleList = {
name: string;
id: string;
startDate: Date;
endDate: Date;
type: Type;
style: string;
status: Status;
export class ScheduleList {
name!: string;
id!: string;
type!: Type;
style!: string;
status!: Status;
@TransformType(() => Date)
startDate!: Date;
@TransformType(() => Date)
endDate!: Date;
}
export type ScheduleListResponseDTO = BaseResponseDTO<ScheduleList[]>;