mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 11:22:48 +00:00
a
This commit is contained in:
parent
0bacd0367f
commit
efff33c609
5 changed files with 10836 additions and 7619 deletions
|
@ -0,0 +1,13 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringPetclinicApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringPetclinicApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -30,8 +30,8 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OrderBy;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing an owner.
|
||||
|
@ -94,7 +94,7 @@ public class Owner extends Person {
|
|||
}
|
||||
|
||||
public void addPet(Pet pet) {
|
||||
if (pet.isNew()) {
|
||||
if (pet != null && pet.isNew()) {
|
||||
getPets().add(pet);
|
||||
}
|
||||
}
|
||||
|
@ -117,11 +117,12 @@ public class Owner extends Person {
|
|||
for (Pet pet : getPets()) {
|
||||
if (!pet.isNew()) {
|
||||
Integer compId = pet.getId();
|
||||
if (compId.equals(id)) {
|
||||
if (compId != null && compId.equals(id)) {
|
||||
return pet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -132,6 +133,8 @@ public class Owner extends Person {
|
|||
* @return the Pet with the given name, or null if no such Pet exists for this Owner
|
||||
*/
|
||||
public Pet getPet(String name, boolean ignoreNew) {
|
||||
if (name == null) return null;
|
||||
|
||||
for (Pet pet : getPets()) {
|
||||
String compName = pet.getName();
|
||||
if (compName != null && compName.equalsIgnoreCase(name)) {
|
||||
|
|
|
@ -90,7 +90,7 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@GetMapping("/owners")
|
||||
public String processFindForm(@RequestParam(name="page", defaultValue = "1") int page, Owner owner, BindingResult result,
|
||||
public String processFindForm(@RequestParam(defaultValue = "1") int page, Owner owner, BindingResult result,
|
||||
Model model) {
|
||||
// allow parameterless GET request for /owners to return all records
|
||||
if (owner.getLastName() == null) {
|
||||
|
@ -170,4 +170,4 @@ class OwnerController {
|
|||
return mav;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,13 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringPetclinicApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue