feat: add licence state to membre find result

This commit is contained in:
2026-08-05 16:45:18 +02:00
parent d3805ea0e7
commit a328e71035
4 changed files with 26 additions and 40 deletions

View File

@@ -107,7 +107,7 @@ public class LicenceService {
return Panache.withTransaction(() -> repository.persist(model));
}
public Uni<LicenceModel> setLicence(long id, LicenceForm form) {
public Uni<LicenceModel> setLicence(long id, LicenceForm form) { // TODO add log
if (form.getId() == -1) {
return combRepository.findById(id).chain(membreModel -> {
LicenceModel model = new LicenceModel();

View File

@@ -184,11 +184,17 @@ public class MembreService {
String finalSearch = search;
return getLicenceListe(licenceRequest, payState)
.map(l -> l.stream().map(l2 -> l2.getMembre().getId()).toList())
.chain(ids -> {
.chain(l -> {
PanacheQuery<MembreModel> query;
query = repository.find(queryStr, sort, finalSearch, ids, club).page(Page.ofSize(limit));
return getPageResult(query, limit, page);
query = repository.find(queryStr, sort, finalSearch,
l.stream().map(l2 -> l2.getMembre().getId()).toList(), club).page(Page.ofSize(limit));
return getPageResult(query, limit, page)
.call(r -> (r.getResult().isEmpty() || !l.isEmpty() ?
Uni.createFrom().item(l) :
licenceRepository.list("saison = ?1 AND membre.id IN ?2", Utils.getSaison(),
r.getResult().stream().map(SimpleMembre::getId).toList()))
.invoke(l2 -> r.setAdditionalData(l2.stream().map(SimpleLicence::fromModel)))
);
});
}

View File

@@ -10,13 +10,14 @@ import java.util.List;
@Data
@RegisterForReflection
public class PageResult<T> {
@Schema(description = "Le numéro de la page courante.", example = "1")
@Schema(description = "Le numéro de la page courante.", examples = "1")
private int page;
@Schema(description = "Le nombre d'éléments par page.", example = "10")
@Schema(description = "Le nombre d'éléments par page.", examples = "10")
private int page_size;
@Schema(description = "Le nombre total de pages.", example = "5")
@Schema(description = "Le nombre total de pages.", examples = "5")
private int page_count;
@Schema(description = "Le nombre total d'éléments.", example = "47")
@Schema(description = "Le nombre total d'éléments.", examples = "47")
private long result_count;
private List<T> result = new ArrayList<>();
private Object additionalData;
}