Skip to content

feat: 주문 현황 기간/상태/금액 필터링 추가#250

Merged
yerincho94 merged 2 commits into
mainfrom
조예린
Mar 19, 2026

Hidden character warning

The head ref may contain hidden characters: "\uc870\uc608\ub9b0"
Merged

feat: 주문 현황 기간/상태/금액 필터링 추가#250
yerincho94 merged 2 commits into
mainfrom
조예린

Conversation

@yerincho94

Copy link
Copy Markdown
Collaborator

이슈 번호

작업 내용

  • SalesOrderSearchRequest.java 신규 생성
    • from, to, status, amountMin, amountMax
  • SalesOrderRepositoryCustom.java
    • findStoreOrders() 시그니처 수정
      • 기존: findStoreOrders(Long storeId, Pageable pageable)
      • 수정: findStoreOrders(Long storeId, SalesOrderSearchRequest request, Pageable pageable)
  • SalesOrderRepositoryImpl.java
    • findStoreOrders() 구현 수정
      • 기간 필터 (from/to) 추가
      • 주문 상태 필터 (status) 추가
      • 금액 범위 필터 (amountMin/amountMax) 추가
      • 동적 조건 처리 (null이면 조건 제외)
  • SalesOrderService.java
    • getStoreOrders() 파라미터에 SalesOrderSearchRequest 추가
  • SalesOrderController.java
    • @Valid @ModelAttribute SalesOrderSearchRequest request 추가

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • 주문 검색 필터링 기능 추가: 주문 현황 조회 시 기간, 주문 상태, 금액 범위에 따른 필터링 기능을 추가했습니다. 이를 위해 새로운 SalesOrderSearchRequest DTO가 도입되었습니다.
  • Repository 및 Service 계층 업데이트: SalesOrderRepositoryCustomSalesOrderRepositoryImplfindStoreOrders 메서드 시그니처와 구현이 업데이트되어 새로운 검색 요청 DTO를 받아 동적으로 필터링 조건을 적용합니다.
  • Controller 계층 통합: SalesOrderControllergetStoreOrders 엔드포인트에 @Valid @ModelAttribute SalesOrderSearchRequest 파라미터가 추가되어 클라이언트로부터 필터링 조건을 받을 수 있도록 했습니다.
  • 유효성 검사 및 에러 코드 추가: 유효하지 않은 검색 기간 또는 금액 범위에 대한 새로운 에러 코드(INVALID_SEARCH_PERIOD, INVALID_AMOUNT_RANGE)가 추가되었으며, SalesOrderService에서 이 유효성 검사를 수행합니다.
  • 테스트 코드 보강: 새로운 필터링 기능과 유효성 검증 로직에 대한 서비스 및 컨트롤러 테스트 케이스가 추가되었습니다.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

주문 현황 목록에 기간, 상태, 금액 필터링 기능을 추가하는 유용한 변경입니다. 전반적으로 QueryDSL과 요청 DTO를 사용하여 동적 쿼리를 깔끔하게 구현했습니다. 코드 품질을 더욱 높이기 위해 몇 가지 제안 사항이 있습니다.

  • 불필요한 import 문을 제거합니다.
  • 중복된 유효성 검사 로직을 공통 컴포넌트로 추출하여 DRY 원칙을 준수합니다.
  • 테스트 코드에서 리플렉션 대신 public 메서드를 사용하도록 개선하여 테스트의 견고성을 높입니다.

@@ -0,0 +1,15 @@
package kr.inventory.domain.sales.controller.dto.request;

import jakarta.validation.constraints.NotNull;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

jakarta.validation.constraints.NotNull import가 사용되지 않고 있습니다. 레포지토리 스타일 가이드의 "import 정리 및 unused 제거" 규칙(66번 라인)에 따라 불필요한 import는 제거하는 것이 좋습니다.

References
  1. 프로젝트 컨벤션에 따라 사용하지 않는 import는 제거해야 합니다. (link)

Comment on lines +221 to 231
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);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

validateSearchPeriodvalidateAmountRange 메서드는 SalesLedgerService에도 동일하게 존재합니다. 이는 코드 중복으로, 레포지토리 스타일 가이드의 DRY 원칙(13, 34, 89번 라인)에 위배됩니다. 이 로직을 별도의 유효성 검사 컴포넌트(예: SearchRequestValidator)로 추출하여 공통으로 사용하면 유지보수성을 높일 수 있습니다.

References
  1. 중복된 로직은 공통화하여 코드의 재사용성을 높이고 유지보수 비용을 줄여야 합니다. (link)


SalesOrder order = SalesOrder.create(store, table, session, "key1", SalesOrderType.DINE_IN);
ReflectionTestUtils.setField(order, "salesOrderId", 1L);
ReflectionTestUtils.setField(order, "totalAmount", new BigDecimal("23000"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

테스트 객체 생성 시 totalAmount 필드를 설정하기 위해 ReflectionTestUtils를 사용하고 있습니다. SalesOrder 엔티티에는 updateTotalAmount라는 public 메서드가 있으므로, 이를 사용하는 것이 좋습니다. public API를 사용하면 테스트가 구현 세부사항(필드명 등)과의 결합도를 낮추고, 클래스의 공개된 계약을 기반으로 동작하므로 더 견고해집니다. 이는 스타일 가이드의 "구현 디테일에 과도하게 결합된 테스트 금지"(111번 라인) 원칙과도 일치합니다.

Suggested change
ReflectionTestUtils.setField(order, "totalAmount", new BigDecimal("23000"));
order.updateTotalAmount(new BigDecimal("23000"));
References
  1. 테스트는 구현의 세부 사항이 아닌 공개된 동작(public method)에 의존해야 리팩터링에 더 안전합니다. (link)

@yerincho94 yerincho94 merged commit a1f90a2 into main Mar 19, 2026
1 check failed
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.

feat: 주문 현황 기간/상태/금액 필터링 추가

1 participant