Skip to content

Commit

Permalink
✨ feat: 전체 가입 그룹 출처의 수신 메시지함 조회 기능 (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
loveysuby committed Sep 30, 2024
1 parent d508f19 commit 59bad16
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package slvtwn.khu.toyouserver.application;

import static java.lang.Long.MIN_VALUE;

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -67,10 +65,9 @@ public RollingPaperResponse findById(Long userId, Long rollingPaperId) {

public List<RollingPaperResponse> findReceivedRollingPapers(Long userId, Long groupId,
Long targetId, Integer limit) {
Long currentCursor = targetId != null ? targetId : MIN_VALUE;
List<Long> memberIds = getMemberIds(userId, groupId);
PageRequest pageRequest = PageRequest.ofSize(limit);
return rollingPaperRepository.findAllByMembersAfterCursor(memberIds, currentCursor, pageRequest).stream()
return rollingPaperRepository.findAllByMembersAfterCursor(memberIds, targetId, pageRequest).stream()
.map(RollingPaperResponse::from)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ToyouResponse<RollingPaperResponse> findById(@UserAuthentication Long use

@GetMapping("/rollingpapers")
public ToyouResponse<List<RollingPaperResponse>> findReceivedRollingPapers(@UserAuthentication Long userId,
@RequestParam Long groupId,
@RequestParam(required = false) Long groupId,
@RequestParam(defaultValue = "0") Long targetId,
@RequestParam(defaultValue = "10") int limit) {
return ToyouResponse.from(rollingPaperService.findReceivedRollingPapers(userId, groupId, targetId, limit));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class RollingPaperServiceTest {

// when
List<RollingPaperResponse> response = rollingPaperService.findReceivedRollingPapers(user.getId(), group.getId(),
null, 10);
0L, 10);

// then
assertThat(response).usingRecursiveComparison()
Expand Down Expand Up @@ -251,7 +251,7 @@ class RollingPaperServiceTest {
List<RollingPaperResponse> response = rollingPaperService.findReceivedRollingPapers(
user.getId(),
group.getId(),
null, 10);
0L, 10);

// then
List<RollingPaperResponse> expectedResponse = List.of(
Expand Down

0 comments on commit 59bad16

Please sign in to comment.