feat: display and manage adherent clothing and shoe sizes

This commit is contained in:
2026-07-07 21:54:52 +02:00
parent a7c5b23198
commit 3fc239683e
3 changed files with 112 additions and 19 deletions
@@ -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;