Skip to content

Commit

Permalink
feat: 지도에 썸네일 수정 기능 추가, 수정 정보가 없을 때 에러 응답 #177
Browse files Browse the repository at this point in the history
  • Loading branch information
Miensoap committed Nov 25, 2024
1 parent 642f657 commit 2ebfeca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
4 changes: 4 additions & 0 deletions backend/src/course/course.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down
14 changes: 10 additions & 4 deletions backend/src/course/dto/UpdateCourseInfoRequest.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
15 changes: 12 additions & 3 deletions backend/src/map/dto/UpdateMapInfoRequest.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 4 additions & 0 deletions backend/src/map/map.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down

0 comments on commit 2ebfeca

Please sign in to comment.