본문으로 건너뛰기

[도메인명] 도메인 모델


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: 대상 회원 ID
  • status: 콜 상태 (CallStatus)
  • createdAt: 생성 일시
  • completedAt: 완료 일시
  • completedBy: 완료 처리자 ID

CallMemo

  • id: 메모 고유 식별자
  • callPlanId: 소속 콜 계획 ID
  • content: 메모 내용 (최대 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:

  • CallPlanCreated
  • CallCompleted
  • CallCancelled
  • MemoAdded

CallMemo

Methods:

  • createMemo(callPlanId, content, createdBy)
  • updateContent(newContent)
  • delete()
  • getContent()
  • getCreatedBy()

Repository:

  • findById(id)
  • findByCallPlanId(callPlanId)
  • save(memo)
  • delete(memoId)

Events Published:

  • MemoCreated
  • MemoUpdated
  • MemoDeleted

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

  • 4001 CALL_ALREADY_COMPLETED (409): 이미 완료된 콜
  • 4002 INVALID_CALL_STATUS (400): 유효하지 않은 상태 전이
  • 4003 MEMO_CONTENT_TOO_LONG (400): 메모 내용 초과 (500자)
  • 4004 UNAUTHORIZED_ACTION (403): 권한 없음

5xx - Server Errors

  • 5001 INTERNAL_ERROR (500): 내부 서버 오류

(작성 가이드 참고)