Skip to content

[태태] Chapter 7. API 설계 심화 - 페이징#92

Merged
EH-OI merged 2 commits into
tata/mainfrom
tata/week7
May 19, 2026
Merged

[태태] Chapter 7. API 설계 심화 - 페이징#92
EH-OI merged 2 commits into
tata/mainfrom
tata/week7

Conversation

@EH-OI
Copy link
Copy Markdown

@EH-OI EH-OI commented May 17, 2026

✏️ 작업 내용

#️⃣ 연관된 이슈

closes #(issue_num)


💡 함께 공유하고 싶은 부분

해당 주차를 공부하면서 함께 이야기하고 싶은 주제를 남겨주세요.

(어려웠던 부분과 해결 과정, 핵심 코드, 참고한 자료 등)


🤔 질문

해당 주차 워크북을 공부하면서 궁금했던 질문들을 남겨주세요.


✅ 워크북 체크리스트

  • 모든 핵심 키워드 정리를 마쳤나요?
  • 핵심 키워드에 대해 완벽히 이해하셨나요?
  • 이론 학습 이후 직접 실습을 해보는 시간을 가졌나요?
  • 미션을 수행하셨나요?
  • 미션을 기록하셨나요?

✅ 컨벤션 체크리스트

  • 디렉토리 구조 컨벤션을 잘 지켰나요?
  • pr 제목을 컨벤션에 맞게 작성하였나요?
  • pr에 해당되는 이슈를 연결하였나요?
  • 적절한 라벨을 설정하였나요?
  • 스터디원들에게 code review를 요청하기 위해 reviewer를 등록하였나요?
  • 닉네임/main 브랜치의 최신 상태를 반영하고 있는지 확인했나요?

📌 주안점

@EH-OI EH-OI requested a review from a team May 17, 2026 07:14
@EH-OI EH-OI linked an issue May 17, 2026 that may be closed by this pull request
@EH-OI EH-OI changed the base branch from main to tata/main May 17, 2026 07:15
@Eugene-Shin
Copy link
Copy Markdown

페이징을 열심히 구현하신 것 같습니다!

Copy link
Copy Markdown

@DOHOON0127 DOHOON0127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

무한 스크롤 구현시 Slice활용이나 정석적인 복함합 키 쿼리 작성은 잘 해주신 것 같습니다. 고생하셧습니다~

Comment on lines +25 to +30
User user = userRepository.findById(userId)
.orElseThrow(() -> new RuntimeException("해당 유저를 찾을 수 없습니다."));

// 미션 찾기
Mission mission = missionRepository.findById(missionId)
.orElseThrow(() -> new RuntimeException("해당 미션을 찾을 수 없습니다."));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 유저나 미션을 찾지 못했을때 RuntimeException를 던지고 있는데 RuntimeException같은 공통 예외를 그대로 던지면 어떤 에러인지 추적하기 어렵습니다.

앞서 작성했던 프로젝트 공통 예외 클래스 ProjectException으로 변경하여 글로벌 예외 처리기에서 명확한 에러 코드와 메시지를 내려주도록 하는게 좋을 것 같습니다!

.missionSpec(um.getMission().getMissionSpec())
.deadline(um.getMission().getDeadline())
.build())
.collect(Collectors.toList());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 컨트롤러 메서드 내부를 보면 엔티티 -> DTO 매핑 로직이 직접 노출되어 있습니다. 컨트롤러가 너부 비대해 지는 것은 좋아보이지 않기 때문에 컨버터를 활용해서 별도 클래스로 빼는게 좋아보입니다!

Comment on lines +44 to +51
// 공통 페이징 응답 객체 포장
PageResponseDto<MissionResponseDto.MyMissionPreviewDto> response = PageResponseDto.<MissionResponseDto.MyMissionPreviewDto>builder()
.data(data)
.listSize(userMissionPage.getSize())
.totalPage(userMissionPage.getTotalPages())
.totalElements(userMissionPage.getTotalElements())
.isFirst(userMissionPage.isFirst())
.isLast(userMissionPage.isLast())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도 제 생각에는 매 컨트롤러마다 반복될 코드같은데 그냥 DTO자체에 정적 팩토리 메서드를 만들어 두는게 나을 것 같습니다!

그러면 컨트롤러에서는 PageResponseDto<...> response = PageResponseDto.of(userMissionPage, data); 이런식으로 한 줄로 쓸 수 있을 것 같아요!

Comment on lines +45 to 82
@GetMapping("/my")
public ApiResponse<CursorResponseDto<ReviewResponseDto.MyReviewDto>> getMyReviews(
@RequestHeader(name = "userId") Long userId,
@RequestParam(name = "cursor", defaultValue = "-1") String cursor,
@RequestParam(name = "query", defaultValue = "id") String query,
@RequestParam(name = "size", defaultValue = "10") Integer size
) {
Slice<Review> reviewSlice = reviewQueryService.getMyReviews(userId, cursor, query, size);

List<ReviewResponseDto.MyReviewDto> data = reviewSlice.stream()
.map(r -> ReviewResponseDto.MyReviewDto.builder()
.reviewId(r.getId())
.storeName(r.getStore().getName())
.star(r.getStar())
.content(r.getContent())
.createdAt(r.getCreatedAt())
.build())
.collect(Collectors.toList());

String nextCursor = null;
if (reviewSlice.hasNext() && !data.isEmpty()) {
Review lastReview = reviewSlice.getContent().get(reviewSlice.getContent().size() - 1);
if (query.equalsIgnoreCase("star")) {
nextCursor = lastReview.getStar() + ":" + lastReview.getId();
} else {
nextCursor = String.valueOf(lastReview.getId());
}
}

CursorResponseDto<ReviewResponseDto.MyReviewDto> response = CursorResponseDto.<ReviewResponseDto.MyReviewDto>builder()
.data(data)
.hasNext(reviewSlice.hasNext())
.nextCursor(nextCursor)
.pageSize(reviewSlice.getSize())
.build();
return ApiResponse.onSuccess(GeneralSuccessCode.OK, dummyResponse);

return ApiResponse.onSuccess(GeneralSuccessCode.OK, response);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰컨트롤러 부분도 앞선 리뷰 참고해주세요~

@EH-OI EH-OI merged commit 210cf64 into tata/main May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chapter 7. API 설계 심화 - 페이징

3 participants