diff --git a/backend/src/course/course.controller.ts b/backend/src/course/course.controller.ts index 7c978d1d..f322c8ea 100644 --- a/backend/src/course/course.controller.ts +++ b/backend/src/course/course.controller.ts @@ -74,6 +74,10 @@ export class CourseController { @Param('id') id: number, @Body() updateCourseInfoRequest: UpdateCourseInfoRequest, ) { + if (updateCourseInfoRequest.isEmpty()) { + throw new BadRequestException('수정할 정보가 없습니다.'); + } + await this.courseService.updateCourseInfo(id, updateCourseInfoRequest); return { id, ...updateCourseInfoRequest }; } diff --git a/backend/src/course/dto/UpdateCourseInfoRequest.ts b/backend/src/course/dto/UpdateCourseInfoRequest.ts index 695d7472..575c0ec4 100644 --- a/backend/src/course/dto/UpdateCourseInfoRequest.ts +++ b/backend/src/course/dto/UpdateCourseInfoRequest.ts @@ -1,13 +1,19 @@ -import { IsNotEmpty, IsString } from 'class-validator'; +import { IsString, IsUrl, IsOptional } from 'class-validator'; export class UpdateCourseInfoRequest { + @IsOptional() @IsString() - @IsNotEmpty() - title: string; + title?: string; + @IsOptional() @IsString() description?: string; - @IsString() + @IsOptional() + @IsUrl() thumbnailUrl?: string; + + isEmpty(): boolean { + return !this.title && !this.description && !this.thumbnailUrl; + } } diff --git a/backend/src/map/dto/UpdateMapInfoRequest.ts b/backend/src/map/dto/UpdateMapInfoRequest.ts index 852264c8..7917554d 100644 --- a/backend/src/map/dto/UpdateMapInfoRequest.ts +++ b/backend/src/map/dto/UpdateMapInfoRequest.ts @@ -1,10 +1,19 @@ -import { IsString, IsNotEmpty } from 'class-validator'; +import { IsString, IsUrl, IsOptional } from 'class-validator'; export class UpdateMapInfoRequest { + @IsOptional() @IsString() - @IsNotEmpty() - title: string; + title?: string; + @IsOptional() @IsString() description?: string; + + @IsOptional() + @IsUrl() + thumbnailUrl?: string; + + isEmpty(): boolean { + return !this.title && !this.description && !this.thumbnailUrl; + } } diff --git a/backend/src/map/map.controller.ts b/backend/src/map/map.controller.ts index 1b0e7756..bba223ab 100644 --- a/backend/src/map/map.controller.ts +++ b/backend/src/map/map.controller.ts @@ -67,6 +67,10 @@ export class MapController { @Param('id') id: number, @Body() updateMapInfoRequest: UpdateMapInfoRequest, ) { + if (updateMapInfoRequest.isEmpty()) { + throw new BadRequestException('수정할 정보가 없습니다.'); + } + await this.mapService.updateMapInfo(id, updateMapInfoRequest); return { id, ...updateMapInfoRequest }; }