mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-27 01:45:49 +00:00
updated
This commit is contained in:
parent
bac74f7a99
commit
4c36948e82
4 changed files with 20 additions and 1 deletions
2
pom.xml
2
pom.xml
|
@ -15,7 +15,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<!-- Generic properties -->
|
<!-- Generic properties -->
|
||||||
<java.version>17</java.version>
|
<java.version>11</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
|
|
|
@ -158,4 +158,12 @@ class OwnerController {
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/owners")
|
||||||
|
public ModelAndView showOwners(@PathVariable("ownerId") int ownerId) {
|
||||||
|
ModelAndView mav = new ModelAndView("owners/ownerDetails");
|
||||||
|
Owner owner = this.owners.findById(ownerId);
|
||||||
|
mav.addObject(owner);
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,12 @@ class PetController {
|
||||||
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/pets/{petId}/find")
|
||||||
|
public String initUpdateFormFind(Owner owner, @PathVariable("petId") int petId, ModelMap model) {
|
||||||
|
Pet pet = owner.getPet(petId);
|
||||||
|
model.put("pet", pet);
|
||||||
|
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
|
||||||
|
}
|
||||||
@PostMapping("/pets/{petId}/edit")
|
@PostMapping("/pets/{petId}/edit")
|
||||||
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) {
|
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
|
|
@ -77,6 +77,11 @@ class VisitController {
|
||||||
return "pets/createOrUpdateVisitForm";
|
return "pets/createOrUpdateVisitForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/owners/{ownerId}/pets/{petId}/visits")
|
||||||
|
public String initNewVisitFormVisit() {
|
||||||
|
return "pets/createOrUpdateVisitForm";
|
||||||
|
}
|
||||||
|
|
||||||
// Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is
|
// Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is
|
||||||
// called
|
// called
|
||||||
@PostMapping("/owners/{ownerId}/pets/{petId}/visits/new")
|
@PostMapping("/owners/{ownerId}/pets/{petId}/visits/new")
|
||||||
|
|
Loading…
Reference in a new issue