diff --git a/src/group/dto/delete-member.dto.ts b/src/group/dto/delete-member.dto.ts new file mode 100644 index 0000000..c6c7f91 --- /dev/null +++ b/src/group/dto/delete-member.dto.ts @@ -0,0 +1,10 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class DeleteMemberDto { + @ApiProperty({ + required: true, + description: '멤버 아이디 목록', + example: ['663fb4d6c30e2acec791595c', '663fb4d6c30e2acec791595e'], + }) + readonly memberIds: string[]; +} diff --git a/src/group/group.controller.ts b/src/group/group.controller.ts index 5e2779c..73e7f85 100644 --- a/src/group/group.controller.ts +++ b/src/group/group.controller.ts @@ -22,6 +22,7 @@ import { GetTransactionsPeriodDto } from '../transaction/dto/get-transaction-per import { UploadTransactionDto } from '../transaction/dto/upload-transaction-dto'; import { Transaction } from '../transaction/transaction.decorators'; import { CreateGroupDto } from './dto/create-group.dto'; +import { DeleteMemberDto } from './dto/delete-member.dto'; import { UpdateGroupDto } from './dto/update-group.dto'; import { UploadGroupDto } from './dto/upload-group.dto'; import { Group } from './group.decorators'; @@ -280,15 +281,16 @@ export class GroupController { @Delete(':groupId/member') @Member() + @ApiBody({ type: DeleteMemberDto }) @ApiOperation({ summary: '모임 멤버 삭제', description: '특정 모임의 멤버를 삭제합니다.', }) deleteMembers( @Param('groupId') groupId: string, - @Body() memberIds: string[], + @Body() deleteMemberDto: DeleteMemberDto, ) { - return this.groupService.deleteMembers(groupId, memberIds); + return this.groupService.deleteMembers(groupId, deleteMemberDto); } @Delete(':groupId/event/:eventId') diff --git a/src/group/group.service.ts b/src/group/group.service.ts index 8b37fe5..c259e26 100644 --- a/src/group/group.service.ts +++ b/src/group/group.service.ts @@ -10,6 +10,7 @@ import { MemberService } from '../member/member.service'; import { GetTransactionsPeriodDto } from '../transaction/dto/get-transaction-period-dto'; import { TransactionService } from '../transaction/transaction.service'; import { CreateGroupDto } from './dto/create-group.dto'; +import { DeleteMemberDto } from './dto/delete-member.dto'; import { UpdateGroupDto } from './dto/update-group.dto'; import { Group } from './entities/group.entity'; import { GroupRepository } from './group.repository'; @@ -200,9 +201,13 @@ export class GroupService { return this.groupRepository.delete(groupId); } - async deleteMembers(groupId: string, memberIds: string[]): Promise { + async deleteMembers( + groupId: string, + deleteMemberDto: DeleteMemberDto, + ): Promise { const group = await this.groupRepository.findOne(groupId); const groupMembers = group.members; + const memberIds = deleteMemberDto.memberIds; group.members = groupMembers.filter( (member) => !memberIds.includes(member),