Update OwnerController.java

Add Log
This commit is contained in:
nubang 2024-11-28 14:50:21 +09:00 committed by GitHub
parent c8677501d0
commit 725170966c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -61,6 +61,17 @@ class OwnerController {
@ModelAttribute("owner") @ModelAttribute("owner")
public Owner findOwner(@PathVariable(name = "ownerId", required = false) Integer ownerId) { public Owner findOwner(@PathVariable(name = "ownerId", required = false) Integer ownerId) {
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
return ownerId == null ? new Owner() return ownerId == null ? new Owner()
: this.owners.findById(ownerId) : this.owners.findById(ownerId)
.orElseThrow(() -> new IllegalArgumentException("Owner not found with id: " + ownerId .orElseThrow(() -> new IllegalArgumentException("Owner not found with id: " + ownerId
@ -69,11 +80,33 @@ class OwnerController {
@GetMapping("/owners/new") @GetMapping("/owners/new")
public String initCreationForm() { public String initCreationForm() {
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
} }
@PostMapping("/owners/new") @PostMapping("/owners/new")
public String processCreationForm(@Valid Owner owner, BindingResult result, RedirectAttributes redirectAttributes) { public String processCreationForm(@Valid Owner owner, BindingResult result, RedirectAttributes redirectAttributes) {
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
if (result.hasErrors()) { if (result.hasErrors()) {
redirectAttributes.addFlashAttribute("error", "There was an error in creating the owner."); redirectAttributes.addFlashAttribute("error", "There was an error in creating the owner.");
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
@ -86,6 +119,17 @@ class OwnerController {
@GetMapping("/owners/find") @GetMapping("/owners/find")
public String initFindForm() { public String initFindForm() {
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
System.out.println("===============================================");
return "owners/findOwners"; return "owners/findOwners";
} }