0

I need to know if an entity (User) matches given some criteria. I have defined the criterions in the domain and they implements an interface:

match(User)bool

Now the problem is one criterion needs the data of the other entity (Company), and User only has the company id.

How should I handle it? Could I create an interface in the domain (CompanyResolver) and use it in the criterion? this interface will be implemented by the repository.

Thanks

xmartinez
  • 43
  • 6

1 Answers1

0

Ok. Given the use case, you can implement the business logic in User domain entity method like this, depending on your aggregate (User or Company):

class User {
    match(Company company) {
        // your logic
    }
}

Or

class Company {
    match(User user) {
        // your logic
    }
}

Before calling this method, you must prepare all the data from repository.

If you want more details, try to document more your problem.

In any case, the domain must be agnostic from all the others modules.

slim
  • 447
  • 2
  • 10
  • 27