I am developing an application according to DDD. So I have my repositories' interfaces in the Domain layer.
My requirement is to make a searchByParams method. My question is : is it correct that this method will take a DTO as a param ? (because I read in this thread that DTO should be in the application layer)
This is an example to better illustrate my question :
I have a model object let say Person :
public class Person {
private String firstName;
private String lastName;
private Date birthDate;
private Date inscriptionDate;
// Getters and setters ...
}
I want to get a list of persons by firstName, lastName, birthDateBefore, birthDateAfter, inscriptionDateBefore, inscriptionDateAfter.
What I thought to do is to make some sort of DTO containing theses fields
public class PersonDTO { // I can also name it PersonResearchFilters
private String firstName;
private String lastName;
private Date birthDateBefore;
private Date birthDateAfter;
private Date inscriptionDateBefore;
private Date inscriptionDateAfter;
// Getters and setters ...
}
and pass it to : List<Person> searchByParams(PersonDTO filters)
But this implies that my DTO will be in the domain layer.
- Is it OK ?
- Is there a better way to design that requirement ?
- Am I misunderstanding something ?