Skip to content

Commit

Permalink
feat: 지도 공개 범위 수정 API 구현 #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Miensoap committed Nov 6, 2024
1 parent b2adcdb commit fd47f15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 6 additions & 9 deletions backend/src/map/map.controller.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 };
}
}
7 changes: 7 additions & 0 deletions backend/src/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fd47f15

Please sign in to comment.