feat: display and manage adherent clothing and shoe sizes
This commit is contained in:
@@ -48,6 +48,8 @@ public class AdherentController {
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String licence,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String email,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String paiement,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "nom") String sortField,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "asc") String sortDirection,
|
||||
@org.springframework.web.bind.annotation.RequestParam(defaultValue = "0") int page,
|
||||
@org.springframework.web.bind.annotation.RequestParam(defaultValue = "20") int size,
|
||||
Model model) {
|
||||
@@ -113,7 +115,29 @@ public class AdherentController {
|
||||
model.addAttribute("paiementFilter", paiement.trim());
|
||||
}
|
||||
|
||||
// 3. Paginate
|
||||
// 3. Sort
|
||||
java.util.Comparator<Adherent> comparator = (a1, a2) -> 0;
|
||||
if ("nom".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> a.getNom() != null ? a.getNom() : "");
|
||||
} else if ("prenom".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> a.getPrenom() != null ? a.getPrenom() : "");
|
||||
} else if ("categorie".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> (a.getLicenceActuelle() != null && a.getLicenceActuelle().getCategorie() != null && a.getLicenceActuelle().getCategorie().getNom() != null) ? a.getLicenceActuelle().getCategorie().getNom() : "");
|
||||
} else if ("licence".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> (a.getLicenceActuelle() != null && a.getLicenceActuelle().getNumeroLicence() != null) ? a.getLicenceActuelle().getNumeroLicence() : "");
|
||||
} else if ("email".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> a.getEmail() != null ? a.getEmail() : "");
|
||||
}
|
||||
|
||||
if ("desc".equalsIgnoreCase(sortDirection)) {
|
||||
comparator = comparator.reversed();
|
||||
}
|
||||
adherents.sort(comparator);
|
||||
|
||||
model.addAttribute("sortField", sortField);
|
||||
model.addAttribute("sortDirection", sortDirection);
|
||||
|
||||
// 4. Paginate
|
||||
int totalElements = adherents.size();
|
||||
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||
if (page < 0) page = 0;
|
||||
|
||||
Reference in New Issue
Block a user