Skip to content

Commit

Permalink
♻️ Fix: 나에게서 출발/도착한 친구관계 조회 도메인 로직 분리
Browse files Browse the repository at this point in the history
<body>
출발/도착 친구관계 분리

- 관련 : #384
  • Loading branch information
hosung-222 committed Oct 23, 2024
1 parent d421d16 commit be04136
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void requestFriendShip(Member me, Member target) {
*/
public Page<Friendship> getReceivedFriendRequests(Long memberId, int page) {
Pageable pageable = PageRequest.of(page - 1, REQUEST_PAGE_SIZE);
return friendshipService.readAllFriendshipByStatus(memberId, FriendshipStatus.PENDING, pageable);
return friendshipService.readAllReceivedFriendshipByStatus(memberId, FriendshipStatus.PENDING, pageable);
}

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ public void checkMemberIsFriend(Long memberId, Long friendId) {
public Page<Friendship> getAcceptedFriendship(Long memberId, int page) {
Pageable pageable = PageRequest.of(page - 1, REQUEST_PAGE_SIZE,
Sort.by(Sort.Order.desc("isFavorite"), Sort.Order.desc("createdAt")));
return friendshipService.readAllFriendshipByStatus(memberId, FriendshipStatus.ACCEPTED, pageable);
return friendshipService.readAllRequestFriendshipByStatus(memberId, FriendshipStatus.ACCEPTED, pageable);
}

public Friendship getAcceptedFriendship(Long memberId, Long friendId){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ List<FriendBirthdayQuery> findBirthdayVisibleFriendIdsByPeriod(
LocalDate endDate);

Optional<Friendship> findByMemberIdAndFriendIdAndStatus(Long memberId, Long friendId, FriendshipStatus status);

Page<Friendship> findAllByMemberIdAndStatus(Long memberId, FriendshipStatus status, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,20 @@ public Friendship createFriendShip(Friendship friendship){
return friendshipRepository.save(friendship);
}

public Page<Friendship> readAllFriendshipByStatus(Long memberId, FriendshipStatus status, Pageable pageable) {
/**
* memberId(나)에게 도착한 친구 관계로 탐색
*/
public Page<Friendship> readAllReceivedFriendshipByStatus(Long memberId, FriendshipStatus status, Pageable pageable) {
return friendshipRepository.findAllByFriendIdAndStatus(memberId, status, pageable);
}

/**
* memberId(나)에서 시작한 친구 관계로 탐색
*/
public Page<Friendship> readAllRequestFriendshipByStatus(Long memberId, FriendshipStatus status, Pageable pageable) {
return friendshipRepository.findAllByMemberIdAndStatus(memberId, status, pageable);
}

public Optional<Friendship> readFriendshipByStatus(Long friendshipId, FriendshipStatus status){
return friendshipRepository.findByIdAndStatus(friendshipId, status);
}
Expand Down

0 comments on commit be04136

Please sign in to comment.