diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/entity/GroupInvite.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/entity/GroupInvite.java index dc67cce81..cc06587e7 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/entity/GroupInvite.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/entity/GroupInvite.java @@ -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 @@ -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(); + } + } } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupCommandService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupCommandService.java index 35dc7b94c..bb7ba23e9 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupCommandService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member_group/service/MemberGroupCommandService.java @@ -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; @@ -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); + } + /** * 사용자는 사용자가 속한 그룹을 탈퇴한다. *
주의 - 그룹 탈퇴 시 아래 조건에 해당하면 예외가 발생한다.