mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-16 12:45:48 +00:00
Updating using GitHub API 2025-06-19-15:31
This commit is contained in:
parent
8d02dd678e
commit
eee0247315
1 changed files with 3 additions and 6 deletions
|
@ -59,10 +59,8 @@ class PetController {
|
|||
|
||||
@ModelAttribute("owner")
|
||||
public Owner findOwner(@PathVariable("ownerId") int ownerId) {
|
||||
Optional<Owner> optionalOwner = this.owners.findById(ownerId);
|
||||
Owner owner = optionalOwner.orElseThrow(() -> new IllegalArgumentException(
|
||||
return this.owners.findById(ownerId).orElseThrow(() -> new IllegalArgumentException(
|
||||
"Owner not found with id: " + ownerId + ". Please ensure the ID is correct "));
|
||||
return owner;
|
||||
}
|
||||
|
||||
@ModelAttribute("pet")
|
||||
|
@ -73,8 +71,7 @@ class PetController {
|
|||
return new Pet();
|
||||
}
|
||||
|
||||
Optional<Owner> optionalOwner = this.owners.findById(ownerId);
|
||||
Owner owner = optionalOwner.orElseThrow(() -> new IllegalArgumentException(
|
||||
Owner owner = this.owners.findById(ownerId).orElseThrow(() -> new IllegalArgumentException(
|
||||
"Owner not found with id: " + ownerId + ". Please ensure the ID is correct "));
|
||||
return owner.getPet(petId);
|
||||
}
|
||||
|
@ -170,4 +167,4 @@ class PetController {
|
|||
this.owners.save(owner);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue