Skip to content

Commit

Permalink
fix : 친구 삭제 예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed Aug 30, 2024
1 parent d11248a commit 2b47b44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ ResponseEntity<ApiSpec<String>> deleteSendingFriendInvite(
@ApiResponse(
responseCode = "400",
description = """
잘못된 요청 파라미터 또는 존재하지 않는 사용자로 요청하거나 존재하지 않는 친구에게 친구 요청을 보낼 경우 발생
잘못된 요청 파라미터로 요청
""",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
),
@ApiResponse(
responseCode = "404",
description = """
존재하지 않는 친구에게 친구 요청을 보낼 경우 발생
""",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,6 +157,10 @@ public void deleteFriend(final Long memberId, final Long friendId) {
final List<MemberFriend> memberFriends = memberFriendRepository
.findMemberFriendByOwnerIdAndFriendId(memberId, friendId);

if (memberFriends.isEmpty()) {
throw new FriendNotFoundException();
}

memberFriends.forEach(memberFriendRepository::delete);
}

Expand Down

0 comments on commit 2b47b44

Please sign in to comment.