Skip to content

refactor: 입고 및 재고 목록 조회 정렬 기준 수정#179

Merged
JoonKyoLee merged 2 commits intomainfrom
refactor/sort-condition
Dec 5, 2025
Merged

refactor: 입고 및 재고 목록 조회 정렬 기준 수정#179
JoonKyoLee merged 2 commits intomainfrom
refactor/sort-condition

Conversation

@JoonKyoLee
Copy link
Contributor

@JoonKyoLee JoonKyoLee commented Dec 5, 2025

✨ 작업 내용

  • 입고 및 재고 목록 조회 정렬 기준 수정

📝 적용 범위

  • /inventory
  • /receipt

📌 참고 사항

Summary by CodeRabbit

개선 사항

  • Refactor
    • 페이지네이션 처리가 개선되고 일관되게 적용되었습니다.
    • 영수증 목록이 최신 항목부터 내림차순으로 표시됩니다.

✏️ Tip: You can customize this high-level summary in your review settings.

@JoonKyoLee JoonKyoLee self-assigned this Dec 5, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

훑어보기

두 개의 서비스에서 페이징 요청 생성 방식을 리팩토링했습니다. PageRequest.of() 직접 호출을 PaginationUtil.createPageRequest()로 통합하고, ReceiptService에 내림차순 정렬 방향을 명시적으로 추가했습니다.

변경 사항

응집 / 파일 변경 요약
PaginationUtil 통합 리팩토링
src/main/java/com/almang/inventory/inventory/service/InventoryService.java
PaginationUtil 임포트 추가. PageRequest.of(page, size, direction, sortBy)PaginationUtil.createPageRequest(page, size, direction, sortBy)로 대체하여 페이지 요청 생성 로직을 통합.
정렬 방향 명시화
src/main/java/com/almang/inventory/receipt/service/ReceiptService.java
getReceiptList 메서드에서 createPageRequest 호출에 정렬 방향 파라미터 추가. Direction.DESCSort.Direction 임포트 추가하여 createdAt 기준 내림차순 정렬을 명시적으로 구성.

예상 코드 리뷰 노력

🎯 2 (간단함) | ⏱️ ~8분

  • 주목할 점:
    • 두 서비스에 걸친 일관된 패턴 적용 여부 확인 필요 (다른 서비스에서도 동일한 리팩토링이 필요한지 검토)
    • ReceiptService에 정렬 방향 파라미터가 추가된 이유와 기존 동작과의 호환성 검증

관련 가능성 있는 PR

🔄 정렬의 혼란을 한곳에 모아,
유틸로 갈무리한 페이징 순서,
쿼리마다 헤매던 방향도 이제 선명하네—
일관된 흐름, 깔끔한 코드의 손길. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경의 핵심을 명확하게 전달합니다. 입고 및 재고 목록 조회의 정렬 기준 수정이라는 주요 변경 사항을 정확히 반영하고 있습니다.
Description check ✅ Passed PR 설명이 제공된 템플릿을 따르고 있으며, 작업 내용, 적용 범위, 참고 사항이 모두 포함되어 있습니다.
Linked Issues check ✅ Passed 코드 변경 사항이 이슈 #178의 요구사항을 충족하고 있습니다. PaginationUtil을 활용한 정렬 기준 리팩토링이 입고(Receipt)와 재고(Inventory) 목록 조회에 적용되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경 사항이 이슈 #178의 정렬 기준 리팩토링 범위 내에 있습니다. InventoryService와 ReceiptService의 PaginationUtil 도입 외 불필요한 변경은 없습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/sort-condition

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 345e730 and 6105941.

📒 Files selected for processing (2)
  • src/main/java/com/almang/inventory/inventory/service/InventoryService.java (2 hunks)
  • src/main/java/com/almang/inventory/receipt/service/ReceiptService.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/com/almang/inventory/inventory/service/InventoryService.java (1)
src/main/java/com/almang/inventory/global/util/PaginationUtil.java (1)
  • PaginationUtil (7-24)
🔇 Additional comments (4)
src/main/java/com/almang/inventory/inventory/service/InventoryService.java (2)

8-8: 리팩토링 방향이 좋습니다! 👍

페이지네이션 로직을 PaginationUtil로 중앙화하는 것은 코드 일관성과 유지보수성을 높이는 좋은 접근입니다.


149-157: Sorting logic is correctly implemented.

The refactoring preserves the existing dynamic sorting behavior using PaginationUtil. The nested property path product.name is valid since Inventory has a @ManyToOne relationship with Product, and Product has a name field. The updatedAt field is inherited from BaseTimeEntity. Both sorting options will function correctly with JPA queries.

src/main/java/com/almang/inventory/receipt/service/ReceiptService.java (2)

36-36: 필요한 import가 정확히 추가되었습니다.

Direction.DESC를 사용하기 위한 적절한 import입니다.


109-109: Sorting by createdAt in descending order has been correctly implemented.

The createdAt field exists in the Receipt entity through inheritance from BaseTimeEntity, and using Direction.DESC ensures that the most recent receipts appear first—an appropriate user experience design. The implementation is sound.

Note: The variable name pageable is the standard Spring Data convention for Pageable/PageRequest types and should remain unchanged.


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 and usage tips.

@JoonKyoLee JoonKyoLee merged commit c44550e into main Dec 5, 2025
1 check passed
@Two-Silver Two-Silver deleted the refactor/sort-condition branch December 5, 2025 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 조회 시 정렬 기준 리팩토링

1 participant