From 2b47b446f6b66df967ec4af1cbefaced9d93df12 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Fri, 30 Aug 2024 14:12:22 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EC=B9=9C=EA=B5=AC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/friend/api/command/FriendCommandApi.java | 9 ++++++++- .../friend/service/command/FriendCommandService.java | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/command/FriendCommandApi.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/command/FriendCommandApi.java index ff56bce53..2c32773d1 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/command/FriendCommandApi.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/api/command/FriendCommandApi.java @@ -82,7 +82,14 @@ ResponseEntity> deleteSendingFriendInvite( @ApiResponse( responseCode = "400", description = """ - 잘못된 요청 파라미터 또는 존재하지 않는 사용자로 요청하거나 존재하지 않는 친구에게 친구 요청을 보낼 경우 발생 + 잘못된 요청 파라미터로 요청 + """, + content = @Content(schema = @Schema(implementation = ErrorResponse.class)) + ), + @ApiResponse( + responseCode = "404", + description = """ + 존재하지 않는 친구에게 친구 요청을 보낼 경우 발생 """, content = @Content(schema = @Schema(implementation = ErrorResponse.class)) ) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/command/FriendCommandService.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/command/FriendCommandService.java index aa8050626..bb9779161 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/command/FriendCommandService.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/friend/service/command/FriendCommandService.java @@ -14,6 +14,7 @@ import site.timecapsulearchive.core.domain.friend.entity.MemberFriend; import site.timecapsulearchive.core.domain.friend.exception.FriendInviteDuplicateException; import site.timecapsulearchive.core.domain.friend.exception.FriendInviteNotFoundException; +import site.timecapsulearchive.core.domain.friend.exception.FriendNotFoundException; import site.timecapsulearchive.core.domain.friend.exception.FriendTwoWayInviteException; import site.timecapsulearchive.core.domain.friend.exception.SelfFriendOperationException; import site.timecapsulearchive.core.domain.friend.repository.friend_invite.FriendInviteRepository; @@ -156,6 +157,10 @@ public void deleteFriend(final Long memberId, final Long friendId) { final List memberFriends = memberFriendRepository .findMemberFriendByOwnerIdAndFriendId(memberId, friendId); + if (memberFriends.isEmpty()) { + throw new FriendNotFoundException(); + } + memberFriends.forEach(memberFriendRepository::delete); }