Skip to content

[#25] 경매 목록 조회 - #29

Merged
JIWON27 merged 8 commits into
mainfrom
feature/25
Sep 9, 2026
Merged

JIWON27 merged 8 commits into
mainfrom
feature/25

Conversation

@JIWON27

@JIWON27 JIWON27 commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

개요

  • 경매 목록 조회 API(GET /auctions)를 구현
  • 필터: category, grade(등급) — 각각 선택적 파라미터
  • 키워드 검색: keyword 파라미터로 브랜드/모델명/설명에 대해 대소문자 무관 부분일치 검색
  • 정렬: sort 파라미터로 입찰많은순(인기순) / 마감임박순 / 최신순 지원
  • 페이지네이션: Spring Data Pageable 기반 0-base(page/size)
  • 목록에는 항상 진행중(IN_PROGRESS) 경매만 노출되도록 repository 레벨에서 상태 고정.
  • 동적 조건 조합(선택적 필터 + 키워드 OR + 입찰수 집계 정렬) QueryDSL을 사용하여 기능 구현
  • 응답 DTO(AuctionSummaryResponse)는 기존 AuctionDetailResponse와 동일하게 CameraInfo/SellerInfo 중첩 구조로 통일
    • 썸네일은 카메라 이미지 중 id 기준 첫 번째 이미지를 사용합니다.
  • 리포지토리(QueryDSL 쿼리 검증), 서비스, 컨트롤러 각 계층에 테스트 추가.

메인 리뷰어 지정 및 Due Date

  • 메인 리뷰어 : blue , Due Date : 2026-09-08

리뷰 시 참고 사항

  • 현재는 1차 MVP여서 N+1 관련은 고려하지않았습니다.
  • 썸네일 이미지 구분하는게 현재는 없어서 가장 첫번째 이미지를 썸네일 이미지로 결정했습니다.

TODO

  • 성능 테스트 단계에서 N+1 조회 개선
  • 데이터가 늘었을 때 입찰많은순 정렬 성능 확인 및 필요시 bid_count 비정규화 컬럼 검토

References

[1] x

체크리스트

  • PR 제목을 명령형으로 작성했습니다.
  • PR을 연관되는 github issue에 연결했습니다.
  • 리뷰 리퀘스트 전에 셀프 리뷰를 진행했습니다
  • 변경사항에 대한 테스트코드를 추가했습니다. 또는, 테스트 코드가 필요없는 이유가 있습니다.

@JIWON27 JIWON27 self-assigned this Sep 6, 2026
@JIWON27 JIWON27 linked an issue Sep 6, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 85beab33-b347-47a9-8d21-0f2ca1ba4769


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JIWON27
JIWON27 requested a review from blue000927 September 6, 2026 01:53
Comment on lines +50 to +53
@RequestParam(required = false) CameraCategory category,
@RequestParam(required = false) CameraConditionGrade grade,
@RequestParam(required = false) String keyword,
@RequestParam(required = false) AuctionSortType sort,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

잘못된 파라미터 값에 500이 나갑니다.

?category=NOT_EXIST로 호출하면 Spring이 enum 변환에 실패하면서 MethodArgumentTypeMismatchException을 던집니다. GlobalExceptionHandler에 이 예외 핸들러가 없어서 handleException()이 받고, 클라이언트는 {"code":"COMMON-002","message":"서버 내부 오류가 발생했습니다."} 500을 받습니다. sort=PRICE_ASC도 같습니다.

GlobalExceptionHandler에 MethodArgumentTypeMismatchException 핸들러를 추가해서 CommonErrorCode.INVALID_INPUT_VALUE로 400을 내려주면 어떨까요?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

아 넵 !! 요거 제가 놓쳤습니다 적용하도록 하겠습니다!!

Comment on lines +83 to +87
return switch (sort) {
case BID_COUNT -> getBidCount().desc();
case CLOSING_SOON -> auction.extendedClosesAt.asc();
case LATEST -> auction.createdAt.desc();
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

정렬 기준이 같은 경매들 사이에서 페이지네이션이 어긋납니다.

extendedClosesAt이 동일한 경매 6건을 넣고 sort=CLOSING_SOON&size=2로 0, 1, 2페이지를 이어서 조회했더니 id가 11,17,12,15,15,14로 나왔습니다. 15가 1페이지와 2페이지에 두 번 내려오고, 13과 16은 세 페이지 어디에도 없습니다. 정렬 값이 같은 행들의 순서는 DB가 쿼리마다 다르게 반환할 수 있어서요. BID_COUNT도 입찰 수가 같은 구간에서 재현됩니다.

각 정렬 뒤에 auction.id.desc()처럼 값이 겹치지 않는 기준을 하나 더 붙여주세요.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

"정렬 값이 같은 행들의 순서는 DB가 쿼리마다 다르게 반환할 수 있어서요" -> 이 부분을 놓쳤습니다.. 감사합니다 ! 보조 정렬 조건을 추가하도록 하겠습니다

Comment on lines +41 to +42
.where(
QueryUtils.equalsIfNotNull(auction.status, AuctionStatus.IN_PROGRESS),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

마감 시각이 지난 경매가 목록에 노출됩니다.

extendedClosesAt을 1시간 전으로 설정한 경매를 조회했더니 목록에 그대로 내려왔습니다. status가 IN_PROGRESS로 남아 있어서인데, 마감 시각이 지난 경매의 상태를 바꿔주는 스케줄러가 코드베이스에 없습니다. Auction.validateAcceptingBids()는 status와 extendedClosesAt을 함께 검사하는데 이 쿼리는 status만 봅니다. 사용자가 목록에서 진행중으로 보고 입찰을 누르면 마감됐다는 응답을 받습니다.

이 조건에 auction.extendedClosesAt.gt(TimeUtils.now())를 같이 걸어서 엔티티와 같은 기준으로 맞춰주면 어떨까요?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

요거는 방어 조건도 추가하고 추후에 STATUS 변경하는 스케줄러도 추가하도록 하겠습니다 !

@RequestParam(required = false) CameraConditionGrade grade,
@RequestParam(required = false) String keyword,
@RequestParam(required = false) AuctionSortType sort,
Pageable pageable

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

page size 상한이 없습니다.

?size=100000으로 요청하면 Spring 기본 상한인 2000건을 한 번에 조회합니다. Hibernate Statistics로 세어보니 10건 조회에 쿼리가 22개 나가는데, 경매마다 카메라를 지연 로딩하고 썸네일을 한 번 더 조회해서요. 2000건이면 4000개 규모가 됩니다.

@PageableDefault(size = 20)로 기본값을 두고 spring.data.web.pageable.max-page-size로 상한을 걸면 어떨까요? N+1은 TODO에 적어두신 대로 나중에 보셔도, 상한은 이번에 막아두면 좋겠습니다.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

앗 넵 !! 감사합니다 요것도... 바로 적용하겠습니다

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@JIWON27
JIWON27 merged commit 423f033 into main Sep 9, 2026
3 checks passed
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.

[Task] 경매 목록 조회 기능

2 participants