[Volume 4] 쿠폰 추가, 동시성 제어 적용#170
Open
simoncho91 wants to merge 11 commits intoLoopers-dev-lab:ymchofrom
Open
Conversation
- 유효한 정보로 회원 생성 성공 테스트 - 각 필드 null/blank 검증 테스트 - loginId, password, name, birthDate, email 필수값 검증
- 필수 필드 5개 (loginId, encryptedPassword, name, birthDate, email) - 생성자에서 각 필드 null/blank 검증 - BaseEntity 상속으로 id, 생성/수정 시간 자동 관리 - 비밀번호 암호화는 추후 구현 예정
fix : 예제 테스트 코드 오류 해결을 위한 testcontainers 버전 업
Test코드 구현
- Coupon 도메인 신규 구현 (CouponTemplate, IssuedCoupon, 정액/정률 할인) - 쿠폰 사용자 API (발급, 내 쿠폰 조회) 및 Admin CRUD API 구현 - 주문 흐름에 쿠폰 할인 통합 (originalAmount, discountAmount, totalAmount 스냅샷) - Product 재고 차감에 비관적 락(PESSIMISTIC_WRITE) 적용 - IssuedCoupon 사용 처리에 비관적 락 적용으로 동시 사용 방지 - 데드락 방지를 위해 상품 락 획득 시 productId 오름차순 정렬 - 동시성 통합 테스트 (재고 동시 차감, 쿠폰 동시 사용, 좋아요 동시 요청) - 쿠폰 도메인 단위 테스트 및 주문-쿠폰 통합 서비스 테스트 - ErrorType 확장 (쿠폰 관련 에러 타입 추가) - analyze-query SKILL.md 개선 (Lock/동시성 분석 섹션 추가) - .cursor/rules/domain-coupon.mdc 규칙 추가 Made-with: Cursor
- OrderService: 트랜잭션 범위 설계 근거, 락 획득 순서, dirty checking 활용 주석 보강 - OrderDomainService: 비관적 락 선택 이유, 데드락 시나리오 및 정렬 전략 주석 추가 - ProductJpaRepository: 낙관적/비관적 락 trade-off 비교 주석 추가 - IssuedCouponJpaRepository: Lost Update 시나리오, 비관적 락 방지 흐름 주석 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Summary
🧭 Context & Decision
문제 정의
선택지와 결정
DB Unique(member_id, product_id)로 해결. 별도 락 불필요
트레이드오프: 멱등성 보장이 목적이므로 제약조건이 가장 효율적이라고 생각함
추후 개선 여지: 재고가 매우 빈번하게 변경되는 경우 Redis 기반 분산 락으로 전환 고려 가능
🏗️ Design Overview
변경 범위
주요 컴포넌트 책임