[도메인명] Use Cases
본 문서는 [도메인명] 도메인의 Use Cases (Commands, Queries)와 통합 이벤트를 정의합니다.
1. Use Cases Overview
시스템이 제공하는 주요 기능 목록
Call Management
- 콜 계획 생성
- 콜 완료 처리
- 콜 취소 처리
- 콜 조회
Memo Management
- 메모 작성
- 메모 수정
- 메모 삭제
2. Commands
2.1 CreateCallPlan
Input (DTO):
{
userId: string
scheduledAt: DateTime
priority: string
}
Output:
{
callPlanId: string
}
Flow:
- 사용자 존재 확인 (UserContext 조회)
- CallPlan Aggregate 생성
- CallPlanCreated 이벤트 발행
- ID 반환
Business Rules:
- 사용자가 활성 상태여야 함
- 중복 콜 계획 방지
Error Cases:
4001USER_NOT_FOUND: 사용자가 존재하지 않음4002USER_INACTIVE: 비활성 사용자4003DUPLICATE_CALL_PLAN: 이미 콜 계획 존재
2.2 CompleteCall
Input (DTO):
{
callPlanId: string
completedBy: string
completionReason: string
memo?: string
}
Output:
{
success: boolean
}
Flow:
- CallPlan Aggregate 조회
- 완료 가능 여부 확인
- completeCall() 메서드 호출
- CallCompleted 이벤트 발행
- Notification Context로 이벤트 전달
Business Rules:
- 활성 상태의 콜만 완료 가능
- 운영자 권한 필요
- 완료 사유 필수
Error Cases:
4001CALL_NOT_FOUND: 콜이 존재하지 않음4002CALL_ALREADY_COMPLETED: 이미 완료됨4003UNAUTHORIZED: 권한 없음
2.3 [다음 Command명]
위 구조 반복
3. Queries
3.1 GetCallPlanDetails
Input (DTO):
{
callPlanId: string
}
Output:
{
id: string
userId: string
status: string
createdAt: DateTime
completedAt?: DateTime
memos: Memo[]
}
Data Source:
- CallPlan Aggregate (Read Model)
Authorization:
- 본인 콜 또는 운영자만 조회 가능
3.2 ListActiveCallsByUser
Input (DTO):
{
userId: string
page: number
size: number
}
Output:
{
items: CallPlan[]
total: number
page: number
}
Data Source:
- CallPlan Repository (findActiveCallsByUser)
Filter:
- status = 'Active'
- userId 일치
3.3 [다음 Query명]
위 구조 반복
4. Application Services (선택)
복잡한 Use Case나 여러 Aggregate를 조율해야 할 때만 추가
4.1 CallOrchestrationService
Methods:
assignAndNotify(callPlanId, operatorId): 콜 할당 및 알림 발송bulkComplete(callPlanIds[], reason): 여러 콜 일괄 완료
Dependencies:
- CallPlanRepository
- NotificationService (External)
- UserService (External)
Transaction Management:
- 트랜잭션 범위 정의
- 보상 트랜잭션 (Saga 패턴)
5. Integration Events
외부 Context로 발행하거나 구독하는 이벤트
Published (Outbound):
CallCompletedNotification→ Notification ContextCallStatisticsUpdated→ Analytics Context
Subscribed (Inbound):
UserStatusChanged← User Context- Handler: UpdateCallPlanStatus
- Action: 비활성 사용자의 콜 자동 취소
6. External Dependencies
User Context:
- API:
GET /users/{userId} - Purpose: 사용자 정보 조회
Notification Context:
- Event:
CallCompletedNotification - Purpose: 완료 알림 발송
Analytics Context:
- Event:
CallStatisticsUpdated - Purpose: 통계 집계