私は、ある時点で会計外部Webサービスに送信できる請求書集約ルートを持っており、そのサービスから取得したID /番号を維持して送信したものとしてマークします。DDDドメインサービス
DDDで正しい方法はありますか?
まずapprroach:
が機能SendToAccounting
と請求書AggregateRootを持ち、会計への請求書をお送りしますドメインサービス/インターフェースを、注入、およびいくつかの「IDを取得/ここ
Invoice.SendToAccounting(IInvoiceDomain service)
{
var accountingSoftwareID = service.getAccountingSoftwareId(this);
this.AccountingSoftwareId = accountingSoftwareId;
}
///Implementation in the application service
var invoice = _invoiceRepository.GetInvoiceById(id);
invoice.SendToAccounting(someDomainService);
_invoiceRepository.Update(invoice);
_unitOfWork.Save();
AccountingSoftwareId
プロパティを設定する第二のアプローチ:最初のアプローチが、ドメインサービスと同様の
は次のように永続化のために責任を負わなければならない:
var invoice = _invoiceRepository.GetInvoiceById(id);
///unit of work save will be called inside this function
invoice.SendToAccounting(someDomainService);
サードapprocach:
ドメインサービスは、この動作
///Code inside domain service
public void SendInvoiceToAccounting(int invoiceId)
{
var invoice = _invoiceRepository.GetInvoiceById(invoiceId);
string invoiceAccountingId = _accountingService.GetAccountingSoftwareId(invoice);
invoice.SetAsSentToAccounting(invoiceAccountingId);
_invoiceRepository.Update(invoice);
_unitOfWork.Save();
}
にカプセル化するために、完全にrensponsibleになります
会計に送信するプロセスには何が含まれているのかは不明です。これは何ですか? – tomliversidge
外部サービスを呼び出す際に、どのように障害を処理しますか? – tomliversidge
請求書集計内で使用されているaccountingIdは何ですか? – tomliversidge