feat: add licence import endpoint
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 9m50s

fix: pdf_gen
This commit is contained in:
2025-07-07 14:04:02 +02:00
parent bd59a17212
commit 824bedb99f
4 changed files with 45 additions and 7 deletions

View File

@@ -120,4 +120,29 @@ public class LicenceService {
}))
.chain(__ -> Panache.withTransaction(() -> repository.deleteById(id)));
}
public Uni<?> setImport(int licence, int saison, boolean valid) {
return combRepository.find("licence = ?1", licence).firstResult()
.chain(membreModel ->
repository.find("saison = ?1 AND membre = ?2", saison, membreModel).firstResult()
.chain(licenceModel -> {
if (licenceModel != null) {
if (licenceModel.getClub_id() == null)
licenceModel.setClub_id(
(membreModel.getClub() == null) ? null : membreModel.getClub()
.getId());
licenceModel.setValidate(valid);
return Panache.withTransaction(() -> repository.persist(licenceModel));
} else {
LicenceModel model = new LicenceModel();
model.setClub_id(
(membreModel.getClub() == null) ? null : membreModel.getClub().getId());
model.setMembre(membreModel);
model.setSaison(saison);
model.setCertificate("¤");
model.setValidate(valid);
return Panache.withTransaction(() -> repository.persist(model));
}
}));
}
}