다음과 같은 시나리오를 생각해 봅시다 Order
집계를 만든 후에, 우리는 특정 라인 항목에 할인을 추가 할 시나리오에서DDD - Aggegrate 메서드 뒤에 집계, 호출 메서드 또는 엔터티 메서드 숨기기를 통해 엔터티 가져 오기?
class Order:
def __init__(self):
self.lines = []
def order(self, product_id, amount, price, discount=None):
item = OrderItem(product_id, amount, price)
self.lines.append(item)
class OrderItem:
def __init__(self, product_id, amount, price, discount=None):
self.product_id = product_id
self.amount = amount
self.price = price
self.discount = discount or decimal.Decimal(0)
def discount(self, amount):
self.discount = discount
을, 나는 집계에서 OrderItem
개체를 얻을 필요가 수행 또는 집계에 메소드를 공개 할 수 있습니까?
예.
class Order:
...
def discount_item(self, index, amount):
self.lines[index].discount(amount)
내가 호출 할 경우 OrderItem.discount()
직접 - 어떻게 그 결과로 발표 된 도메인 이벤트를 추적합니까?