Open
Conversation
Spring Data의 Page 객체를 공통 응답 형식으로 변환하기 위한 PageResponse 모델을 추가한다. 이는 API 응답의 일관성을 위해 사용된다.
product 모듈에서 공통 모델과 유틸리티를 사용하기 위해 common 모듈 의존성을 추가한다.
중복 처리 방지 및 롤백 처리를 위한 ProductTransactionHistory 엔티티를 추가한다. requestId를 통해 멱등성을 보장하며, 구매/취소 트랜잭션 타입을 구분한다.
ProductTransactionHistory 조회를 위한 레포지토리를 추가한다. requestId와 트랜잭션 타입으로 이력을 조회하여 중복 처리를 방지한다.
상품 생성, 조회, 단일/일괄 구매 서비스와 DTO를 추가한다. - ProductCreateService: 상품 생성 - ProductListService: 상품 목록 조회 (페이징) - SingleProductBuyService: 단일 상품 구매 (분산 락 적용) - BunchProductBuyService: 일괄 상품 구매 (Saga 오케스트레이션, 멱등성 보장) 분산 락을 통해 동시성 제어를 하며, 트랜잭션 이력을 기록하여 중복 처리를 방지한다.
상품 관리 및 구매를 위한 REST API 컨트롤러와 DTO를 추가한다. - ProductManageController: 상품 생성 및 목록 조회 API - ProductController: 상품 일괄 구매 API - Request/Response DTO: API 요청/응답 변환 Swagger 문서화가 포함되어 있으며, PageResponse를 사용하여 페이징 응답을 제공한다.
분산 락 구현을 위한 Redis 연결 설정을 추가한다. Lettuce connection pool 설정을 포함하며, 로깅 레벨을 설정하여 디버깅을 지원한다.
상품 취소 기능을 지원하기 위해 Command, Result, Request, Response DTO를 추가한다. 단일 상품 취소와 묶음 상품 취소 모두 지원하도록 구성한다.
단일 상품 및 묶음 상품 취소 기능을 구현한다. - Product 도메인에 cancel 메서드를 추가하여 재고를 복구한다 - SingleProductBuyService에 cancel 메서드를 추가한다 - BunchProductBuyService에 cancel 메서드를 추가하여 트랜잭션 이력 기반 취소를 처리한다 - ProductTransactionHistoryRepository에 requestId로 이력 조회 메서드를 추가한다 - 이미 취소된 주문 건은 중복 처리하지 않도록 방어 로직을 추가한다
상품 취소 기능을 외부에 제공하기 위해 POST /cancel 엔드포인트를 추가한다. ProductController에서 취소 요청을 받아 BunchProductBuyService의 cancel 메서드를 호출한다.
불필요한 중괄호를 제거하여 간결한 data class 형태로 변경한다
도메인 레이어 구조 개선을 위해 Point 엔티티의 패키지 위치를 변경하고 관련 import 경로를 수정함
포인트 사용 및 취소 이력을 추적하기 위한 PointTransactionHistory 엔티티를 추가함
요청 ID와 트랜잭션 타입으로 포인트 트랜잭션 이력을 조회하는 Repository를 추가함
- 포인트 사용 비즈니스 로직을 담당하는 PointUseService 추가 - 포인트 생성, 조회, 사용을 위한 DTO 및 Command 객체 추가 - 분산 락을 활용한 동시성 제어 구현
포인트 생성, 조회, 사용을 위한 REST API 컨트롤러 및 Request/Response DTO를 추가함
분산 락 기능을 사용하기 위해 common 모듈 의존성을 추가함
분산 락 구현을 위한 Redis 연결 설정 및 Lettuce 커넥션 풀 설정을 추가함
포인트 사용 취소를 위한 Command와 Request DTO를 추가합니다. - PointUseCancelCommand: 포인트 취소 애플리케이션 계층 커맨드 - PointUseCancelRequest: 포인트 취소 API 요청 DTO
포인트 취소 시 금액을 복구하는 cancel 메서드를 추가합니다.
- cancel 메서드에 분산 락 적용 - 사용 이력 조회 및 취소 이력 중복 체크 - 포인트 복구 및 취소 이력 저장 - DTO import 추가 및 Kotlin named parameter 적용
- POST /cancel 엔드포인트 추가 - use 엔드포인트를 GET에서 POST로 변경 - PointUseCancelRequest import 추가
- DistributedLockWithTransaction을 DistributedLock으로 이름 변경 - withTransaction 파라미터 추가로 트랜잭션 사용 여부 선택 가능 - 트랜잭션 없이 분산 락만 사용할 수 있도록 로직 분기 처리 - 락 해제 로직을 공통 메서드로 추출하여 중복 제거
common 모듈의 어노테이션 이름 변경에 따른 import 경로 수정
- Order 엔티티에 userId 필드 추가 - 주문 상태 전이 메서드 추가 (request, complete, fail) - OrderStatus에 REQUESTED, FAILED 상태 추가 - 보상 트랜잭션 실패 시 추적을 위한 CompensationRegistry 엔티티 추가 - CompensationRegistry 저장소 인터페이스 추가
Point API DTO: - PointUseApiRequest: 포인트 사용 요청 - PointUseCancelRequest: 포인트 사용 취소 요청 Product API DTO: - ProductBuyApiRequest: 상품 구매 요청 - ProductBuyApiResponse: 상품 구매 응답 (총 가격) - ProductBuyCancelRequest: 상품 구매 취소 요청 - ProductBuyCancelResponse: 상품 구매 취소 응답
ProductApiClient: - 상품 구매(buy) 및 취소(cancel) API 호출 - 재시도 로직 적용 (최대 3회, 지수 백오프) - HttpClientErrorException 발생 시 재시도 제외 PointApiClient: - 포인트 사용(use) 및 취소(cancel) API 호출 - 재시도 로직 적용 (최대 3회, 지수 백오프) RestClient를 사용한 동기 HTTP 통신 구현
OrderService: - 주문 생성, 조회, 상태 변경 기본 기능 제공 OrderCoordinator: - Saga Orchestration 패턴의 중앙 조정자 역할 - Product 구매 → Point 사용 순서로 트랜잭션 조정 - 실패 시 자동 보상 트랜잭션 실행 (rollback) - 보상 실패 시 CompensationRegistry에 기록 - 분산 락을 통한 동시성 제어 (트랜잭션 없이) OrderController: - 주문 생성 및 주문 실행 API 엔드포인트 제공
- ProductApiClient Bean 등록 (localhost:9785) - PointApiClient Bean 등록 (localhost:9787) - RestClient 기반 HTTP 클라이언트 설정
build.gradle.kts: - spring-retry 의존성 추가 (API 재시도 로직) - common 모듈 의존성 추가 (분산 락 사용) application.yml: - Redis 연결 설정 추가 (분산 락 저장소) - Lettuce 커넥션 풀 설정 - 로깅 레벨 설정
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.
No description provided.