Skip to content

Commit

Permalink
feat : 그룹 초대 삭제 서비스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed Jun 6, 2024
1 parent 68cc672 commit 7d7e941
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import lombok.NoArgsConstructor;
import site.timecapsulearchive.core.domain.group.entity.Group;
import site.timecapsulearchive.core.domain.member.entity.Member;
import site.timecapsulearchive.core.domain.member_group.exception.NoGroupAuthorityException;
import site.timecapsulearchive.core.global.entity.BaseEntity;

@Entity
Expand Down Expand Up @@ -49,4 +50,9 @@ public static GroupInvite createOf(Group group, Member groupOwner, Member groupM
return new GroupInvite(group, groupOwner, groupMember);
}

public void validateOwner(Long memberId) {
if (!groupOwner.equals(memberId)) {
throw new NoGroupAuthorityException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupAcceptNotificationDto;
import site.timecapsulearchive.core.domain.member_group.data.dto.GroupOwnerSummaryDto;
import site.timecapsulearchive.core.domain.member_group.data.request.SendGroupRequest;
import site.timecapsulearchive.core.domain.member_group.entity.GroupInvite;
import site.timecapsulearchive.core.domain.member_group.entity.MemberGroup;
import site.timecapsulearchive.core.domain.member_group.exception.GroupInviteNotFoundException;
import site.timecapsulearchive.core.domain.member_group.exception.GroupMemberCountLimitException;
Expand Down Expand Up @@ -105,6 +106,16 @@ private void deleteGroupInvite(final Long memberId, final Long groupId,
}
}

@Transactional
public void deleteGroupInvite(final Long memberId, final Long groupInviteId) {
final GroupInvite groupInvite = groupInviteRepository.findGroupInviteById(groupInviteId)
.orElseThrow(GroupInviteNotFoundException::new);

groupInvite.validateOwner(memberId);

groupInviteRepository.delete(groupInvite);
}

/**
* 사용자는 사용자가 속한 그룹을 탈퇴한다.
* <br><u><b>주의</b></u> - 그룹 탈퇴 시 아래 조건에 해당하면 예외가 발생한다.
Expand Down

0 comments on commit 7d7e941

Please sign in to comment.