From fd47f159f14747af18c301da54a70498411c4581 Mon Sep 17 00:00:00 2001 From: miensoap Date: Wed, 6 Nov 2024 11:16:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A7=80=EB=8F=84=20=EA=B3=B5=EA=B0=9C?= =?UTF-8?q?=20=EB=B2=94=EC=9C=84=20=EC=88=98=EC=A0=95=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20#13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/map/map.controller.ts | 15 ++++++--------- backend/src/map/map.service.ts | 7 +++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/map/map.controller.ts b/backend/src/map/map.controller.ts index 37bec0e1..abb4ccdf 100644 --- a/backend/src/map/map.controller.ts +++ b/backend/src/map/map.controller.ts @@ -1,12 +1,3 @@ -import { - Controller, - Get, - Post, - Body, - Query, - Delete, - Param, -} from '@nestjs/common'; import { Controller, Get, Post, Body, Query, Delete, Param, Patch } from '@nestjs/common'; import { MapService } from './map.service'; import { CreateMapRequest } from './dto/CreateMapRequest'; @@ -48,4 +39,10 @@ export class MapController { await this.appService.updateMapInfo(id, updateMapForm); return { id, ...updateMapForm }; } + + @Patch('/:id/visibility') + async updateMapVisibility(@Param('id') id: number, @Body('isPublic') isPublic: boolean) { + await this.appService.updateMapVisibility(id, isPublic); + return { id, isPublic }; + } } diff --git a/backend/src/map/map.service.ts b/backend/src/map/map.service.ts index 31898f53..d7bb32fd 100644 --- a/backend/src/map/map.service.ts +++ b/backend/src/map/map.service.ts @@ -82,6 +82,13 @@ export class MapService { const { title, description } = updateMapForm; return this.mapRepository.update(id, { title, description }); } + + async updateMapVisibility(id: number, isPublic: boolean) { + await this.checkExists(id); + + return this.mapRepository.update(id, { isPublic }); + } + private async checkExists(id: number) { if (!(await this.mapRepository.existById(id))) throw new MapNotFoundException(id); }