From fbb35bc570298b0eb0edd8787076bd059c88d5ff Mon Sep 17 00:00:00 2001 From: w8385 Date: Thu, 18 Apr 2024 01:35:02 +0900 Subject: [PATCH] refactor: id > groupId, eventId --- src/event/event.controller.ts | 48 +++++++++++++++++++++++++++-------- src/event/event.service.ts | 15 ++++++----- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/event/event.controller.ts b/src/event/event.controller.ts index 35cfa8f..309eca1 100644 --- a/src/event/event.controller.ts +++ b/src/event/event.controller.ts @@ -10,10 +10,15 @@ import { import { EventService } from './event.service'; import { CreateEventDto } from './dto/create-event.dto'; import { UpdateEventDto } from './dto/update-event.dto'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiParam, ApiTags } from '@nestjs/swagger'; @ApiTags('Event') -@Controller('event') +@Controller('group/:groupId/event') +@ApiParam({ + name: 'groupId', + required: true, + description: '모임 ID', +}) export class EventController { constructor(private readonly eventService: EventService) {} @@ -27,18 +32,39 @@ export class EventController { return this.eventService.findAll(); } - @Get(':id') - findOne(@Param('id') id: string) { - return this.eventService.findOne(+id); + @Get(':eventId') + @ApiParam({ + name: 'memberId', + required: true, + description: '모임 회원 ID', + }) + findOne( + @Param('groupId') groupId: string, + @Param('eventId') eventId: string, + ) { + return this.eventService.findOne(groupId, eventId); } - @Patch(':id') - update(@Param('id') id: string, @Body() updateEventDto: UpdateEventDto) { - return this.eventService.update(+id, updateEventDto); + @Patch(':eventId') + @ApiParam({ + name: 'memberId', + required: true, + description: '모임 회원 ID', + }) + update( + @Param('eventId') eventId: string, + @Body() updateEventDto: UpdateEventDto, + ) { + return this.eventService.update(+eventId, updateEventDto); } - @Delete(':id') - remove(@Param('id') id: string) { - return this.eventService.remove(+id); + @Delete(':eventId') + @ApiParam({ + name: 'memberId', + required: true, + description: '모임 회원 ID', + }) + remove(@Param('eventId') eventId: string) { + return this.eventService.remove(+eventId); } } diff --git a/src/event/event.service.ts b/src/event/event.service.ts index a806e91..75652ca 100644 --- a/src/event/event.service.ts +++ b/src/event/event.service.ts @@ -12,15 +12,18 @@ export class EventService { return `This action returns all event`; } - findOne(id: number) { - return `This action returns a #${id} event`; + findOne(groupId: string, eventId: string) { + return { + groupId, + eventId, + }; } - update(id: number, updateEventDto: UpdateEventDto) { - return `This action updates a #${id} event` + updateEventDto; + update(eventId: number, updateEventDto: UpdateEventDto) { + return `This action updates a #${eventId} event` + updateEventDto; } - remove(id: number) { - return `This action removes a #${id} event`; + remove(eventId: number) { + return `This action removes a #${eventId} event`; } }