[VOLUME-3] 도메인 & 객체 설계 및 아키텍처, 패키지 구성 #130
[VOLUME-3] 도메인 & 객체 설계 및 아키텍처, 패키지 구성 #130simoncho91 wants to merge 8 commits intoLoopers-dev-lab:ymchofrom
Conversation
- 유효한 정보로 회원 생성 성공 테스트 - 각 필드 null/blank 검증 테스트 - loginId, password, name, birthDate, email 필수값 검증
- 필수 필드 5개 (loginId, encryptedPassword, name, birthDate, email) - 생성자에서 각 필드 null/blank 검증 - BaseEntity 상속으로 id, 생성/수정 시간 자동 관리 - 비밀번호 암호화는 추후 구현 예정
fix : 예제 테스트 코드 오류 해결을 위한 testcontainers 버전 업
Test코드 구현
|
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)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
Summary
배경: 부트캠프 과제로 상품·브랜드·좋아요·주문 기능을 구현하면서, DDD와 레이어드 아키텍처를 적용했습니다.
목표: 단순 CRUD가 아니라 도메인 모델링과 계층 분리를 고려하여, Product, Brand, Like, Order 도메인과 API를 설계·구현했습니다.
결과: 재고 차감·좋아요 집계·주문 흐름을 도메인과 서비스에 나누어 구현했습니다.
Context & Decision
고려한 대안:
A: Product에 likeCount 필드를 두고, 좋아요할 때마다 Product를 업데이트하는 방식
B: Like를 별도 도메인으로 두고, 조회 시점에 집계하여 붙이는 방식
최종 결정: B를 선택했습니다. Product는 상품 정보에만 집중하고, Like는 좋아요 관계만 담당하도록 했습니다.
트레이드오프: 조회 시 Like 집계 쿼리가 추가되지만, Product의 단일 책임과 확장성을 우선했습니다.
추후 개선 여지: 할인·재고 예약 등이 생기면 Stock, Discount 도메인 분리를 생각해 보았습니다..
Design Overview
🔁 Flow Diagram
-> 이미지가 안올라가서 머메이드 코드로 대체합니다.
sequenceDiagram
autonumber
participant Client
participant OrderController
participant OrderService
participant OrderDomainService
participant ProductRepo
participant OrderRepo
Client->>OrderController: POST /api/v1/orders
OrderController->>OrderService: placeOrder(memberId, items)
OrderService->>OrderDomainService: placeOrder(memberId, items)
loop 각 주문 항목
OrderDomainService->>ProductRepo: findById(productId)
ProductRepo-->>OrderDomainService: Product
OrderDomainService->>OrderDomainService: product.decreaseStock(quantity)
Note over OrderDomainService: 재고 부족 시 예외 → 롤백
end
OrderDomainService->>OrderDomainService: Order.create(memberId, orderLines)
OrderDomainService->>OrderRepo: save(order)
OrderRepo-->>OrderDomainService: Order
OrderDomainService-->>OrderService: Order
OrderService-->>OrderController: OrderResult
OrderController-->>Client: OrderCreateResponse