mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-28 18:05:49 +00:00
Sucessfull build, javax.validation correctly imported
This commit is contained in:
commit
43fe219714
6 changed files with 6 additions and 12 deletions
3
pom.xml
3
pom.xml
|
@ -25,10 +25,9 @@
|
|||
<webjars-bootstrap.version>5.0.1</webjars-bootstrap.version>
|
||||
<webjars-jquery-ui.version>1.12.1</webjars-jquery-ui.version>
|
||||
<webjars-jquery.version>3.6.0</webjars-jquery.version>
|
||||
<wro4j.version>1.10.0</wro4j.version>
|
||||
<webjars-validation-api.version>2.0.1.Final</webjars-validation-api.version>
|
||||
<wro4j.version>1.10.0</wro4j.version>
|
||||
<jacoco.version>0.8.7</jacoco.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -28,11 +28,9 @@ import javax.validation.constraints.NotEmpty;
|
|||
public class Person extends BaseEntity {
|
||||
|
||||
@Column(name = "first_name")
|
||||
@NotEmpty
|
||||
private String firstName;
|
||||
|
||||
@Column(name = "last_name")
|
||||
@NotEmpty
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
|
|
|
@ -47,16 +47,12 @@ import org.springframework.samples.petclinic.model.Person;
|
|||
public class Owner extends Person {
|
||||
|
||||
@Column(name = "address")
|
||||
@NotEmpty
|
||||
private String address;
|
||||
|
||||
@Column(name = "city")
|
||||
@NotEmpty
|
||||
private String city;
|
||||
|
||||
@Column(name = "telephone")
|
||||
@NotEmpty
|
||||
@Digits(fraction = 0, integer = 10)
|
||||
private String telephone;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
||||
|
|
|
@ -63,7 +63,7 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@PostMapping("/owners/new")
|
||||
public String processCreationForm(@Valid Owner owner, BindingResult result) {
|
||||
public String processCreationForm(Owner owner, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@PostMapping("/owners/{ownerId}/edit")
|
||||
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result,
|
||||
public String processUpdateOwnerForm(Owner owner, BindingResult result,
|
||||
@PathVariable("ownerId") int ownerId) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
|
|
|
@ -74,7 +74,7 @@ class PetController {
|
|||
}
|
||||
|
||||
@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) {
|
||||
result.rejectValue("name", "duplicate", "already exists");
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class PetController {
|
|||
}
|
||||
|
||||
@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()) {
|
||||
pet.setOwner(owner);
|
||||
model.put("pet", pet);
|
||||
|
|
|
@ -222,6 +222,7 @@ table td.action-column {
|
|||
.label-success {
|
||||
text-color: @spring-green;
|
||||
}
|
||||
|
||||
.deployment-status-deployed {
|
||||
.label-success;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue