Answer the question
In order to leave comments, you need to log in
How to design an aggregator?
Good afternoon. It is necessary to assign a rating to the organization.
public function __construct(
OrganizationID $id,
Name $name,
array $phones,
array $addresses,
Specialization $specialization
) { }
public function create(OrganizationRepositoryInterface $repository, OrganizationRatingService $rating): void
{
$organization = new Organization(
...
$this->repository = add($organization)
$rating (Вот что сюда передать, только специализации? а как потом сохранить?
)
}
public function __construct(
OrganizationID $id,
Name $name,
array $phones,
array $addresses,
Specialization $specialization,
OrganizationRatingService $rating
) {
$rating->setRating($specialization);
}
Answer the question
In order to leave comments, you need to log in
1. Make a separate entity - Organization Rating, and have a common ID with the organization. There is already a static constructor that initializes the rating by the number of specializations.
Judging by the description, neither the name, nor the phone numbers, nor the addresses are needed to calculate the rating, which means that it makes no sense to put it in the same entity.
I think the best option.
2. The entity can, if desired, be put in the field at the root of the aggregate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question