Skip to content

Commit

Permalink
refactor: deleteMembers 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
ssoxong committed Apr 19, 2024
1 parent 39831b4 commit 65acaee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/group/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export class GroupService {
return this.groupRepository.delete(groupId);
}

async deleteMember(groupId: string, memberId: string): Promise<void> {
const group = (await this.groupRepository.findOne(groupId)) as Group;
if (group.members.includes(memberId)) {
group.members = group.members.filter((member) => member !== memberId);
}
await this.groupRepository.update(groupId, group);
}

async deleteMembers(groupId: string, memberIds: string[]): Promise<void> {
const group = (await this.groupRepository.findOne(groupId)) as Group;
const groupMembers = group.members;
Expand Down
2 changes: 1 addition & 1 deletion src/member/member.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MemberService {
if (!this.validateMemberIds(memberIds)) throw new NotFoundException();

this.memberRepository.delete(memberIds);
await this.groupService.deleteMembers(groupId, memberIds);
await this.groupService.deleteMember(groupId, memberId);
}

async deleteGroupMembers(
Expand Down

0 comments on commit 65acaee

Please sign in to comment.