Feat/9/wallet ledger 원장 기록 및 지갑/원장 조회 API 구현#11
Conversation
- LedgerType enum 정의 (ORDER_LOCK, ORDER_CANCEL_RELEASE, TRADE_BUY_QUOTE_SETTLE 등 7종) - WalletLedger 엔티티 추가: delta, balance_after, order_id, trade_id 포함 - WalletLedgerRepository 추가: 사용자/자산별 최신순 조회
- 주문 생성 시 자산 lock 후 ORDER_LOCK 원장 기록 - 주문 취소 시 lock 해제 후 ORDER_CANCEL_RELEASE 원장 기록 - 체결 정산 시 TRADE_BUY_QUOTE_SETTLE, TRADE_BUY_BASE_CREDIT, TRADE_SELL_BASE_SETTLE, TRADE_SELL_QUOTE_CREDIT 4종 원장 기록
- GET /api/v1/wallets: 사용자 전체 지갑 잔액 조회 - GET /api/v1/wallets/ledgers: 원장 내역 조회 (asset 쿼리 파라미터로 필터)
주문 저장 후 원장을 기록하도록 순서 변경하여 order.getId()를 orderId로 전달
- GET /api/v1/wallets, GET /api/v1/wallets/ledgers API 응답 검증 - 주문 생성 시 ORDER_LOCK 원장 기록 검증 - 주문 취소 시 ORDER_CANCEL_RELEASE 원장 기록 검증 - 체결 시 TRADE_BUY/SELL 4종 원장 기록 검증
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements a complete wallet ledger auditing system that records all wallet state changes triggered by order operations. New domain layer defines ledger event types and persistence; ChangesWallet Ledger Tracking System
Sequence DiagramsequenceDiagram
participant Client
participant WalletController
participant WalletService
participant OrderService
participant WalletLedgerRepository
Client->>WalletController: GET /api/v1/wallets (with JWT)
WalletController->>WalletService: getWallets(userId)
WalletService->>WalletService: map Wallet to WalletResponse
WalletService-->>WalletController: List<WalletResponse>
WalletController-->>Client: 200 wallets
Client->>WalletController: GET /api/v1/wallets/ledgers?asset=BTC
WalletController->>WalletService: getLedgers(userId, "BTC")
WalletService->>WalletLedgerRepository: filtered query by userId+asset
WalletService->>WalletService: map WalletLedger to WalletLedgerResponse
WalletService-->>WalletController: List<WalletLedgerResponse>
WalletController-->>Client: 200 ledger entries
Client->>OrderService: create order (lock funds)
OrderService->>WalletLedgerRepository: save ORDER_LOCK entry
OrderService-->>Client: order created
Client->>OrderService: cancel order (release funds)
OrderService->>WalletLedgerRepository: save ORDER_CANCEL_RELEASE entry
OrderService-->>Client: order canceled
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
LGTM? |
Summary
Changes
LedgerTypeenum: ORDER_LOCK, ORDER_CANCEL_RELEASE, TRADE_BUY_QUOTE_SETTLE, TRADE_BUY_BASE_CREDIT, TRADE_SELL_BASE_SETTLE, TRADE_SELL_QUOTE_CREDITOrderService: 주문 저장 후 ORDER_LOCK 기록, 취소 시 ORDER_CANCEL_RELEASE, 체결 정산 시 4종 ledger 기록WalletController/WalletService/ 응답 DTO 추가## 테스트 완료 사항Test plan
관련 이슈
closes #10
Summary by CodeRabbit