[Feature] (소비자) 장바구니 상품 옵션 수량 변경 API#719
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
Walkthrough장바구니 옵션 수량 변경을 위한 Changes장바구니 옵션 수량 변경 기능
Sequence Diagram(s)sequenceDiagram
participant Client as 클라이언트
participant Controller as CustomerCartController
participant Facade as CustomerCartFacade
participant Service as CustomerCartOptionService
participant Repo as CartOptionRepository
Client->>Controller: PATCH /carts/options/{cartOptionId} (quantity)
Controller->>Facade: updateQuantity(memberId, cartOptionId, request)
Facade->>Service: findByIdAndMemberId(memberId, cartOptionId)
Service->>Repo: findByIdAndMemberId(cartOptionId, memberId)
Repo-->>Service: Optional<CartOption>
Service-->>Facade: CartOption (없으면 NOT_FOUND_CART_OPTION 예외)
Facade->>Facade: option.validateStock(quantity) (초과 시 INVALID_REQUEST_STOCK 예외)
Facade->>Service: updateQuantity(cartOption, quantity)
Facade-->>Controller: UpdateCartOptionResponse
Controller-->>Client: SingleResult<UpdateCartOptionResponse>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
| ) {} | ||
| } | ||
|
|
||
| public record UpdateCartOptionRequest( |
There was a problem hiding this comment.
FE에서 +, - 버튼 누를 때 마다 API를 콜하도록 설계하셨을까요?
아니면 FE에서 주기적으로 배치성으로 option 수량을 보내도록 생각하시나요?
버튼마다 API 콜을 한다면, 행위를(increase / decrease) 받는 게 좋을 것 같습니다! (수량을 받으면 순서가 꼬이는 케이스가 있을 수 있을 것 같습니다.)
배치성이라면 장바구니 현행 상태를 전체로 받을 수 있도록 설계하는 게 좋을 것 같습니다.
개인적으로 배치성으로 가는 게 부하를 줄이는 데 좋을 방향인 것 같습니다.
There was a problem hiding this comment.
버튼에 따라서 +,- 1씩 증감하는 API를 따로 만드는 것보단
최종 수량을 FE에서 보내고 하나의 API로 처리하는게 간편할 것 같아서
직접 수량을 통해 변경되도록 구현했습니다.
There was a problem hiding this comment.
+, - 버튼마다 요청을 보내는 게 아니라 최종 상태일 때 한 번만 호출하는 것으로 이해하면 되는거죠?
There was a problem hiding this comment.
기획 상으로는 +, - 버튼으로도 변경이 가능하고 직접 수량을 입력하여 변경할 수 있기 때문에,
+, - 버튼을 누르면 FE에서 1씩 증감한 값을 request에 담아서 보내도록 생각하고 있습니다.
There was a problem hiding this comment.
fe 에서 연속 클릭은 못하도록 막아야겠네요
연타시 순서뒤바뀜 이슈가 있을 것 같네요
There was a problem hiding this comment.
그러면 1씩 증감하는 별도의 API를 만들까요?
There was a problem hiding this comment.
말씀하신 +1, -1 API 분리도 정합성 면에서는 안전하지만, 기획에 있는 '수량 직접 입력' 기능까지 고려하면 결국 두 가지 스타일의 API를 모두 관리해야 하는 부담이 생길 것 같습니다.
FE와 협의하여 특정 주기나 이벤트(예: 장바구니 화면 이탈 시, 혹은 수량 변경 후 n초간 입력이 없을 때)마다 현재 장바구니의 현행 상태를 배치(Batch) 형태로 일괄 요청하는 방식이 가장 좋지 않을까요?
그렇기 위해서는 optionId 별로 현재 수량을 모두 받는 API로 개발이 되면 좋을 것 같습니다!
다른 의견 있으시면 편하게 말씀해주세요!
There was a problem hiding this comment.
그럼 현재 API 1개로 유지하고 FE에서 너무 잦은 API 호출이 발생하지 않도록 조치하자는 말씀이신가요?
There was a problem hiding this comment.
optionId 목록과 optionId 별로 수량을 body로 받는 형태로 생각하긴 했습니다.
There was a problem hiding this comment.
그렇게 되면 사용자 입장에서 UI를 통해 수량 변경을 했지만 아직 API 호출을 하지 않았기 때문에
새로고침을 할 경우 이전 장바구니 상태로 되돌아가는 상황이 발생할 것 같습니다.
History
🚀 Major Changes & Explanations
📷 Test Image
💡 ETC
Summary by CodeRabbit
New Features
Bug Fixes
Tests