Skip to content

Instantly share code, notes, and snippets.

@thomasmartin-whoz
Last active December 9, 2022 11:02
Show Gist options
  • Save thomasmartin-whoz/1e933534e9fc65ec7605e981365423f5 to your computer and use it in GitHub Desktop.
Save thomasmartin-whoz/1e933534e9fc65ec7605e981365423f5 to your computer and use it in GitHub Desktop.
List<Person> listPersons(PersonListCommand command) {
List<Person> persons
if (command.personIds && command.firstName && command.lastName) {
persons = personRepository.findByIdInAndFirstNameAndLastName(command.personIds, command.firstName, command.lastName)
} else if (command.personIds && command.firstName) {
persons = personRepository.findByIdInAndFirstName(command.personIds, command.firstName)
} else if (command.personIds && command.lastName) {
persons = personRepository.findByIdInAndLastName(command.personIds, command.lastName)
} else if (command.personIds) {
persons = personRepository.findByIdIn(command.personIds)
} else if (command.firstName && command.lastName) {
persons = personRepository.findByFirstNameAndLastName(command.firstName, command.lastName)
} else if (command.firstName) {
persons = personRepository.findByFirstName(command.firstName)
} else if (command.lastName) {
persons = personRepository.findByLastName(command.lastName)
} else {
persons = []
}
return persons
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment