feat: 주문 현황 기간/상태/금액 필터링 추가#250
Hidden character warning
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 상점의 주문 현황 조회 기능에 강력한 필터링 기능을 도입하여 사용자가 특정 기간, 주문 상태 및 금액 범위에 따라 주문을 검색할 수 있도록 합니다. 이는 데이터 접근 계층부터 서비스, 컨트롤러 계층까지 전반적인 코드 변경을 포함하며, 사용자에게 더 유연하고 효율적인 주문 관리 경험을 제공하는 것을 목표로 합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
주문 현황 목록에 기간, 상태, 금액 필터링 기능을 추가하는 유용한 변경입니다. 전반적으로 QueryDSL과 요청 DTO를 사용하여 동적 쿼리를 깔끔하게 구현했습니다. 코드 품질을 더욱 높이기 위해 몇 가지 제안 사항이 있습니다.
- 불필요한 import 문을 제거합니다.
- 중복된 유효성 검사 로직을 공통 컴포넌트로 추출하여 DRY 원칙을 준수합니다.
- 테스트 코드에서 리플렉션 대신 public 메서드를 사용하도록 개선하여 테스트의 견고성을 높입니다.
| @@ -0,0 +1,15 @@ | |||
| package kr.inventory.domain.sales.controller.dto.request; | |||
|
|
|||
| import jakarta.validation.constraints.NotNull; | |||
There was a problem hiding this comment.
jakarta.validation.constraints.NotNull import가 사용되지 않고 있습니다. 레포지토리 스타일 가이드의 "import 정리 및 unused 제거" 규칙(66번 라인)에 따라 불필요한 import는 제거하는 것이 좋습니다.
References
- 프로젝트 컨벤션에 따라 사용하지 않는 import는 제거해야 합니다. (link)
| private void validateSearchPeriod(OffsetDateTime from, OffsetDateTime to) { | ||
| if (from != null && to != null && from.isAfter(to)) { | ||
| throw new SalesOrderException(SalesOrderErrorCode.INVALID_SEARCH_PERIOD); | ||
| } | ||
| } | ||
|
|
||
| return usageMap; | ||
| private void validateAmountRange(BigDecimal amountMin, BigDecimal amountMax) { | ||
| if (amountMin != null && amountMax != null && amountMin.compareTo(amountMax) > 0) { | ||
| throw new SalesOrderException(SalesOrderErrorCode.INVALID_AMOUNT_RANGE); | ||
| } | ||
| } |
There was a problem hiding this comment.
validateSearchPeriod와 validateAmountRange 메서드는 SalesLedgerService에도 동일하게 존재합니다. 이는 코드 중복으로, 레포지토리 스타일 가이드의 DRY 원칙(13, 34, 89번 라인)에 위배됩니다. 이 로직을 별도의 유효성 검사 컴포넌트(예: SearchRequestValidator)로 추출하여 공통으로 사용하면 유지보수성을 높일 수 있습니다.
References
- 중복된 로직은 공통화하여 코드의 재사용성을 높이고 유지보수 비용을 줄여야 합니다. (link)
|
|
||
| SalesOrder order = SalesOrder.create(store, table, session, "key1", SalesOrderType.DINE_IN); | ||
| ReflectionTestUtils.setField(order, "salesOrderId", 1L); | ||
| ReflectionTestUtils.setField(order, "totalAmount", new BigDecimal("23000")); |
There was a problem hiding this comment.
테스트 객체 생성 시 totalAmount 필드를 설정하기 위해 ReflectionTestUtils를 사용하고 있습니다. SalesOrder 엔티티에는 updateTotalAmount라는 public 메서드가 있으므로, 이를 사용하는 것이 좋습니다. public API를 사용하면 테스트가 구현 세부사항(필드명 등)과의 결합도를 낮추고, 클래스의 공개된 계약을 기반으로 동작하므로 더 견고해집니다. 이는 스타일 가이드의 "구현 디테일에 과도하게 결합된 테스트 금지"(111번 라인) 원칙과도 일치합니다.
| ReflectionTestUtils.setField(order, "totalAmount", new BigDecimal("23000")); | |
| order.updateTotalAmount(new BigDecimal("23000")); |
References
- 테스트는 구현의 세부 사항이 아닌 공개된 동작(public method)에 의존해야 리팩터링에 더 안전합니다. (link)
이슈 번호
작업 내용
SalesOrderSearchRequest.java신규 생성SalesOrderRepositoryCustom.javafindStoreOrders()시그니처 수정findStoreOrders(Long storeId, Pageable pageable)findStoreOrders(Long storeId, SalesOrderSearchRequest request, Pageable pageable)SalesOrderRepositoryImpl.javafindStoreOrders()구현 수정SalesOrderService.javagetStoreOrders()파라미터에SalesOrderSearchRequest추가SalesOrderController.java@Valid @ModelAttribute SalesOrderSearchRequest request추가