[도메인명] 도메인 모델
1. Domain Events
1.1 Internal Events
CallPlanCreated
- Payload:
callPlanId,userId,createdAt,createdBy - 발행 시점: CreateCallPlan 커맨드 성공 시
- 발행: AppUserOutboundCallPlan
- 구독: CallBannerService
CallCompleted
- Payload:
callId,userId,completedAt,completedBy,completionReason - 발행 시점: CompleteCall 커맨드 성공 시
- 발행: AppUserOutboundCallPlan
- 구독: CallHistoryService, CallBannerService
1.2 External Events
Outbound: CallCompletedNotification
- Payload:
userId,callId,completedAt - Target: Notification Context
Inbound: UserStatusChanged
- Payload:
userId,status,changedAt - Source: User Context
2. Entities
AppUserOutboundCallPlan (Aggregate Root)
id: 콜 계획 고유 식별자userId: 대상 회원 IDstatus: 콜 상태 (CallStatus)createdAt: 생성 일시completedAt: 완료 일시completedBy: 완료 처리자 ID
CallMemo
id: 메모 고유 식별자callPlanId: 소속 콜 계획 IDcontent: 메모 내용 (최대 500자)createdAt: 생성 일시createdBy: 작성자 ID
3. Enums
CallStatus - 콜의 상태
Draft: 초안 (생성 직후)Active: 활성 (처리 중)Completed: 완료Cancelled: 취소
CompletionReason - 콜 완료 사유
Success: 정상 완료NoAnswer: 부재중Refused: 거부Unreachable: 연결 불가
4. Value Objects
CallMemoContent
content: 메모 내용 (String, 최대 500자)length: 메모 길이 (Integer)- 동등성: content 값이 동일하면 같은 객체
PhoneNumber
number: 전화번호 (String, 숫자만)countryCode: 국가 코드 (String)- 동등성: number와 countryCode가 모두 동일하면 같은 객체
5. Aggregates
AppUserOutboundCallPlan
Methods:
createCallPlan(userId, ...)completeCall(completedBy, reason)cancelCall(cancelledBy, reason)addMemo(content, createdBy)deleteMemo(memoId)getCallStatus()getMemos()isCompletable()
Repository:
findById(id)findByUserId(userId)findActiveCallsByUser(userId)save(callPlan)
Events Published:
CallPlanCreatedCallCompletedCallCancelledMemoAdded
CallMemo
Methods:
createMemo(callPlanId, content, createdBy)updateContent(newContent)delete()getContent()getCreatedBy()
Repository:
findById(id)findByCallPlanId(callPlanId)save(memo)delete(memoId)
Events Published:
MemoCreatedMemoUpdatedMemoDeleted
6. Domain Services (선택)
여러 Aggregate에 걸친 로직이나 외부 시스템 연동이 필요한 경우에만 추가
CallAssignmentService
assignCallToOperator(callId, operatorId): 콜을 운영자에게 할당 [CallPlan, Operator]findAvailableOperator(): 사용 가능한 운영자 찾기 [Operator]validateOperatorCapacity(operatorId): 운영자 처리 용량 확인 [Operator, CallPlan]
PriceCalculationService
calculateDiscount(userId, amount): 사용자별 할인율 계산 [User, Order]applyPromotionRules(orderId): 프로모션 규칙 적용 [Order, Promotion]
7. Error Codes
4xx - Client Errors
4001CALL_ALREADY_COMPLETED (409): 이미 완료된 콜4002INVALID_CALL_STATUS (400): 유효하지 않은 상태 전이4003MEMO_CONTENT_TOO_LONG (400): 메모 내용 초과 (500자)4004UNAUTHORIZED_ACTION (403): 권한 없음
5xx - Server Errors
5001INTERNAL_ERROR (500): 내부 서버 오류