Skip to content

Commit

Permalink
✨ Feat: 친구 목록 조회 API 구현
Browse files Browse the repository at this point in the history
<body>
20명씩 조건에 의해 페이징되는 친구 목록 조회 API 구현 완료

- 관련 : #382
  • Loading branch information
hosung-222 committed Oct 23, 2024
1 parent 2b8e961 commit a7051ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import static com.namo.spring.core.common.code.status.ErrorStatus.*;

import java.awt.print.Pageable;
import java.util.List;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -52,7 +49,7 @@ public ResponseDto<String> requestFriend(

@Operation(summary = "나에게 온 친구 요청 목록을 조회합니다.", description = "친구 요청 목록 조회 API 입니다. 수락 또는 거절한 친구 요청은 표시되지 않습니다.")
@GetMapping("/requests")
public ResponseDto<FriendshipResponse.GetFriendRequestDto> getFriendRequestList(
public ResponseDto<FriendshipResponse.FriendRequestListDto> getFriendRequestList(
@AuthenticationPrincipal SecurityUserDetails member,
@Parameter(description = "1 부터 시작하는 페이지 번호입니다 (기본값 1)", example = "1")
@RequestParam(value = "page", defaultValue = "1") int page
Expand Down Expand Up @@ -91,13 +88,16 @@ public ResponseDto<String> rejectFriendRequest(
return ResponseDto.onSuccess("친구 요청을 거절했습니다.");
}

@Operation(summary = "내 친구 목록을 조회합니다. [20명씩 조회]", description = "내 친구 리스트를 보는 API 입니다.")
@Operation(summary = "내 친구 목록을 조회합니다. [20명씩 조회]", description = "내 친구 리스트를 보는 API 입니다. "
+ "즐겨찾기에 등록된 친구가 가장 먼저 나오고, 그 후에 최근 추가된 친구들이 조회됩니다. ")
@GetMapping("")
public ResponseDto<FriendshipResponse.GetFriendListDto> getFriendList(
public ResponseDto<FriendshipResponse.FriendListDto> getFriendList(
@AuthenticationPrincipal SecurityUserDetails member,
@Parameter(description = "1부터 시작하는 페이지 번호입니다. 20명씩 조회됩니다.", example = "3")
@RequestParam(defaultValue = "1") int page
){
return ResponseDto.onSuccess(null);
return ResponseDto.onSuccess(friendUseCase
.getFriendList(member.getUserId(), page));
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.namo.spring.application.external.api.user.usecase;

import java.awt.print.Pageable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -31,9 +28,9 @@ public void requestFriendship(Long myMemberId, String nicknameTag) {
}

@Transactional(readOnly = true)
public FriendshipResponse.GetFriendRequestDto getFriendshipRequest(Long memberId, int page) {
public FriendshipResponse.FriendRequestListDto getFriendshipRequest(Long memberId, int page) {
Page<Friendship> receivedRequests = friendManageService.getReceivedFriendRequests(memberId, page);
return FriendshipConverter.toGetFriendRequestDto(receivedRequests);
return FriendshipConverter.toFriendRequestDto(receivedRequests);
}

@Transactional
Expand All @@ -47,4 +44,10 @@ public void rejectFriendRequest(Long memberId, Long friendshipId) {
Friendship friendship = friendManageService.getPendingFriendship(friendshipId);
friendManageService.rejectRequest(memberId, friendship);
}

@Transactional(readOnly = true)
public FriendshipResponse.FriendListDto getFriendList(Long userId, int page) {
Page<Friendship> friendships = friendManageService.getAcceptedFriendship(userId, page);
return FriendshipConverter.toFriendListDto(friendships);
}
}

0 comments on commit a7051ea

Please sign in to comment.