mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
⚗️ Add Sanitize Vet Name Method
replaces spaces to build a vet slug.
This commit is contained in:
parent
4148fc9eb3
commit
9bfd937804
1 changed files with 9 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.vet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
@ -75,4 +76,12 @@ class VetController {
|
|||
return vets;
|
||||
}
|
||||
|
||||
public void sanitizeVetNamesForWeb() {
|
||||
Collection<Vet> allVets = vetRepository.findAll();
|
||||
for (Vet vet : allVets) {
|
||||
String sanitized = vet.getFirstName().replaceAll(" ", "_") + "_" + vet.getLastName().replaceAll(" ", "_");
|
||||
vet.setFirstName(sanitized.split("_")[0]);
|
||||
vet.setLastName(sanitized.split("_")[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue