From 7d7e941955be00ba6ee8f26ae2568db8b19241f6 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Thu, 6 Jun 2024 11:08:48 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EC=82=AD=EC=A0=9C=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/member_group/entity/GroupInvite.java | 6 ++++++ .../service/MemberGroupCommandService.java | 11 +++++++++++ 2 files changed, 17 insertions(+) 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); + } + /** * 사용자는 사용자가 속한 그룹을 탈퇴한다. *
주의 - 그룹 탈퇴 시 아래 조건에 해당하면 예외가 발생한다.