Skip to content

7주차 미션 [루크]#14

Open
yujining3827 wants to merge 58 commits into
mainfrom
luke/week7
Open

7주차 미션 [루크]#14
yujining3827 wants to merge 58 commits into
mainfrom
luke/week7

Conversation

@yujining3827
Copy link
Copy Markdown
Collaborator

🚩 관련 이슈


📌 구현 결과

1. 내가 진행중인 미션 조회 API 구현

  • Offset 기반 페이지네이션(Page) 적용
  • Request Body를 통해 memberId를 전달받도록 구현
  • ParticipatedStatus.CHALLERGING 상태의 미션만 조회하도록 구현

    image
    image

2. 내가 생성한 리뷰 조회 API 구현

  • Cursor 기반 페이지네이션(Slice) 적용
  • 사진 데이터 제외 후 리뷰 정보만 반환
  • 정렬 기준을 query parameter로 분기 처리
  1. sort=id → 최신 리뷰(ID DESC)

  2. sort=stars → 별점 기준 정렬(STARS DESC)

    결과 상세 정리 page


3. Validation 및 예외 처리 구현

  • Request Body DTO에 Validation Annotation 적용

    1. @NotBlank
    2. @NotNull

    image
  • @Valid를 통한 요청값 검증 적용

    image

  • GeneralExceptionAdvice에서 MethodArgumentNotValidException 처리 구현

    image

테스트 예시 :

GET /api/v1/review/my?memberId=1&sort=id&size=3
GET /api/v1/review/my?memberId=1&sort=stars&cursor=4&size=3

❓ 리뷰 요청

  • 현재 별점 기준 cursor pagination은 stars < cursor 방식으로 구현했습니다.
    동일한 별점 데이터가 많은 경우 문제가 생길까봐 (stars, id) 복합 cursor를 사용해봤는데,
    현재 방식으로도 과제 요구사항 수준에서는 괜찮은지 궁금합니다.

🤔 질문


💬 기타 공유 사항

  • 리뷰 조회 API 테스트를 위해 다양한 별점 데이터(5점, 4점, 3점, 0점)를 직접 생성하여 cursor pagination 동작을 검증했습니다.
  • Validation 테스트를 위해 빈 문자열 및 null 요청값에 대한 예외 응답도 함께 확인했습니다.

@yujining3827 yujining3827 changed the title Luke/week7 7주차 미션 [루크] May 13, 2026
Copy link
Copy Markdown
Collaborator

@ywkim1m ywkim1m left a comment

Choose a reason for hiding this comment

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

미션 수고하셨습니다!

@ochyeon
Copy link
Copy Markdown
Collaborator

ochyeon commented May 14, 2026

미션 수고하셨습니다!

Copy link
Copy Markdown
Collaborator

@KateteDeveloper KateteDeveloper left a comment

Choose a reason for hiding this comment

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

복합 cursor를 사용해서 동일한 별점 데이터 처리한 아이디어 너무 좋은 것 같습니다!!

Copy link
Copy Markdown
Member

@yangjiae12 yangjiae12 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다

Comment on lines +40 to +41
@RequestParam(name = "page") Integer page,
@RequestParam(name = "size") Integer size
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

page와 size가 쿼리 파라미터로 들어오므로, 음수나 0을 막기 위해 @validated + @min 검증을 추가하면 좋을 것 같습니다.

Comment on lines +116 to +117
PageRequest pageRequest =
PageRequest.of(page, 3);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

페이지 크기 3이 하드코딩되어 있어, 상수로 분리하거나 요청값으로 받으면 추후 변경이 더 쉬울 것 같습니다.


Slice<Review> reviewSlice;

if(sort.equals("stars")){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sort 값을 문자열로 직접 비교하고 있어, 허용 가능한 정렬 기준을 enum으로 관리하면 더 안전할 것 같습니다.

Comment on lines +94 to +101
reviewSlice =
reviewRepository
.findByMemberIdAndIdLessThanOrderByIdDesc(
memberId,
idCursor,
pageable
);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

별점이 같은 리뷰가 여러 개 있을 수 있어, stars만 cursor로 사용하면 데이터가 누락될 수 있습니다. stars + id를 함께 cursor로 사용하는 방식이 더 안정적일 것 같습니다.

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.

5 participants