feat: catalog-service 상품 상태 머신(Product Lifecycle) 도입#39
Open
Conversation
상품 상태를 ACTIVE/DELETED 2가지에서 DRAFT/ACTIVE/SUSPENDED/OUT_OF_STOCK/DELETED 5단계로
확장하고, 상태 전이 규칙 검증 로직을 추가하여 도메인 모델의 풍부함을 높인다.
- ProductStatus enum에 상태 전이 규칙(canTransitionTo) 추가
- Product.changeStatus()에 상태 전이 검증 및 활성화 조건 검증 로직 추가
- DRAFT→ACTIVE 전이 시 필수 필드 검증 (name, price, SKU 1개 이상)
- ProductStatusChangedEvent 정의 및 outbox 패턴으로 이벤트 발행
- CatalogIntegrationEvent 인터페이스 도입으로 상품 레벨 이벤트 지원
- PATCH /api/products/{productId}/status 상태 변경 API 추가
- UpdateProductCommand에서 status 필드 분리 (상태 변경은 전용 API로만 가능)
Closes #33
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
ACTIVE/DELETED2가지에서DRAFT/ACTIVE/SUSPENDED/OUT_OF_STOCK/DELETED5단계로 확장ProductStatus.canTransitionTo()로 상태 전이 규칙을 enum 내에 정의Product.changeStatus()에서 전이 검증 + DRAFT→ACTIVE 활성화 조건 검증 (name, price, SKU 1개 이상)ProductStatusChangedEvent이벤트를 outbox 패턴으로 발행하여 다른 서비스에서 반응 가능CatalogIntegrationEvent인터페이스 도입으로 SKU 레벨뿐 아니라 상품 레벨 이벤트도 지원PATCH /api/products/{productId}/status전용 상태 변경 API 추가UpdateProductCommand에서status필드 분리 — 상태 변경은 반드시 상태 머신을 거치도록 강제상태 전이 규칙
변경 파일 (16개)
ProductStatus.ktcanTransitionTo()Product.ktchangeStatus(),validateForActivation(),delete()수정CatalogIntegrationEvent.ktProductIntegrationEvent.ktCatalogIntegrationEvent확장으로 변경ProductStatusChangedEvent.ktChangeProductStatusUseCase.ktProductCommand.ktChangeProductStatusCommand추가,UpdateProductCommand에서 status 제거ProductController.ktPATCH /{productId}/status추가ProductRequests.ktChangeStatusRequest추가OutboxIntegrationEventProducer.ktCatalogIntegrationEvent지원Closes #33
Test plan
DRAFT상태로 상품 생성 후ACTIVE로 전이 — 필수 필드 검증 확인DRAFT → SUSPENDED)ACTIVE → SUSPENDED → ACTIVE왕복 전이 확인ProductStatusChangedEventoutbox 테이블 저장 확인PUT /api/products/{id}에서 status 필드가 무시되는지 확인GET /api/products)에서ACTIVE상태만 노출되는지 확인🤖 Generated with Claude Code