mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-29 18:25:49 +00:00
:Revert "Revert "Revert "Revert "Build successfull""""
This reverts commit ac49a57dd3
.
This commit is contained in:
parent
ac49a57dd3
commit
638e0c68d2
7 changed files with 13 additions and 12 deletions
8
pom.xml
8
pom.xml
|
@ -25,6 +25,7 @@
|
||||||
<webjars-bootstrap.version>5.0.1</webjars-bootstrap.version>
|
<webjars-bootstrap.version>5.0.1</webjars-bootstrap.version>
|
||||||
<webjars-jquery-ui.version>1.12.1</webjars-jquery-ui.version>
|
<webjars-jquery-ui.version>1.12.1</webjars-jquery-ui.version>
|
||||||
<webjars-jquery.version>3.6.0</webjars-jquery.version>
|
<webjars-jquery.version>3.6.0</webjars-jquery.version>
|
||||||
|
<webjars-validation-api.version>2.0.1.Final</webjars-validation-api.version>
|
||||||
<wro4j.version>1.10.0</wro4j.version>
|
<wro4j.version>1.10.0</wro4j.version>
|
||||||
|
|
||||||
<jacoco.version>0.8.7</jacoco.version>
|
<jacoco.version>0.8.7</jacoco.version>
|
||||||
|
@ -108,6 +109,13 @@
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>${webjars-validation-api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -28,11 +28,9 @@ import javax.validation.constraints.NotEmpty;
|
||||||
public class Person extends BaseEntity {
|
public class Person extends BaseEntity {
|
||||||
|
|
||||||
@Column(name = "first_name")
|
@Column(name = "first_name")
|
||||||
@NotEmpty
|
|
||||||
private String firstName;
|
private String firstName;
|
||||||
|
|
||||||
@Column(name = "last_name")
|
@Column(name = "last_name")
|
||||||
@NotEmpty
|
|
||||||
private String lastName;
|
private String lastName;
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getFirstName() {
|
||||||
|
|
|
@ -47,16 +47,12 @@ import org.springframework.samples.petclinic.model.Person;
|
||||||
public class Owner extends Person {
|
public class Owner extends Person {
|
||||||
|
|
||||||
@Column(name = "address")
|
@Column(name = "address")
|
||||||
@NotEmpty
|
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
@Column(name = "city")
|
@Column(name = "city")
|
||||||
@NotEmpty
|
|
||||||
private String city;
|
private String city;
|
||||||
|
|
||||||
@Column(name = "telephone")
|
@Column(name = "telephone")
|
||||||
@NotEmpty
|
|
||||||
@Digits(fraction = 0, integer = 10)
|
|
||||||
private String telephone;
|
private String telephone;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
||||||
|
|
|
@ -63,7 +63,7 @@ class OwnerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/owners/new")
|
@PostMapping("/owners/new")
|
||||||
public String processCreationForm(@Valid Owner owner, BindingResult result) {
|
public String processCreationForm(Owner owner, BindingResult result) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ class OwnerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/owners/{ownerId}/edit")
|
@PostMapping("/owners/{ownerId}/edit")
|
||||||
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result,
|
public String processUpdateOwnerForm(Owner owner, BindingResult result,
|
||||||
@PathVariable("ownerId") int ownerId) {
|
@PathVariable("ownerId") int ownerId) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
|
|
|
@ -74,7 +74,7 @@ class PetController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/pets/new")
|
@PostMapping("/pets/new")
|
||||||
public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model) {
|
public String processCreationForm(Owner owner, Pet pet, BindingResult result, ModelMap model) {
|
||||||
if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) {
|
if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) {
|
||||||
result.rejectValue("name", "duplicate", "already exists");
|
result.rejectValue("name", "duplicate", "already exists");
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ class PetController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/pets/{petId}/edit")
|
@PostMapping("/pets/{petId}/edit")
|
||||||
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) {
|
public String processUpdateForm(Pet pet, BindingResult result, Owner owner, ModelMap model) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
pet.setOwner(owner);
|
pet.setOwner(owner);
|
||||||
model.put("pet", pet);
|
model.put("pet", pet);
|
||||||
|
|
|
@ -79,7 +79,7 @@ class VisitController {
|
||||||
|
|
||||||
// Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called
|
// Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called
|
||||||
@PostMapping("/owners/{ownerId}/pets/{petId}/visits/new")
|
@PostMapping("/owners/{ownerId}/pets/{petId}/visits/new")
|
||||||
public String processNewVisitForm(@Valid Visit visit, BindingResult result) {
|
public String processNewVisitForm(Visit visit, BindingResult result) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
return "pets/createOrUpdateVisitForm";
|
return "pets/createOrUpdateVisitForm";
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ public class Visit extends BaseEntity {
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate date;
|
private LocalDate date;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
@Column(name = "description")
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue