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); }