feat: add licence import endpoint
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 9m50s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 9m50s
fix: pdf_gen
This commit is contained in:
@@ -373,7 +373,7 @@ public class ClubService {
|
||||
return uniBase
|
||||
.map(Unchecked.function(m -> {
|
||||
if (m.getAffiliations().stream()
|
||||
.noneMatch(licenceModel -> licenceModel.getSaison() == Utils.getSaison() - 1))
|
||||
.noneMatch(licenceModel -> licenceModel.getSaison() == Utils.getSaison()))
|
||||
throw new DNotFoundException("Pas d'affiliation pour la saison en cours");
|
||||
|
||||
try {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ public class LicenceEndpoints {
|
||||
@APIResponse(responseCode = "500", description = "Erreur interne du serveur")
|
||||
})
|
||||
public Uni<List<SimpleLicence>> getLicence(@PathParam("id") long id) {
|
||||
return licenceService.getLicence(id, checkPerm).map(licenceModels -> licenceModels.stream().map(SimpleLicence::fromModel).toList());
|
||||
return licenceService.getLicence(id, checkPerm)
|
||||
.map(licenceModels -> licenceModels.stream().map(SimpleLicence::fromModel).toList());
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -60,7 +61,8 @@ public class LicenceEndpoints {
|
||||
@APIResponse(responseCode = "500", description = "Erreur interne du serveur")
|
||||
})
|
||||
public Uni<List<SimpleLicence>> getCurrentSaisonLicenceAdmin() {
|
||||
return licenceService.getCurrentSaisonLicence(null).map(licenceModels -> licenceModels.stream().map(SimpleLicence::fromModel).toList());
|
||||
return licenceService.getCurrentSaisonLicence(null)
|
||||
.map(licenceModels -> licenceModels.stream().map(SimpleLicence::fromModel).toList());
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -74,7 +76,8 @@ public class LicenceEndpoints {
|
||||
@APIResponse(responseCode = "500", description = "Erreur interne du serveur")
|
||||
})
|
||||
public Uni<List<SimpleLicence>> getCurrentSaisonLicenceClub() {
|
||||
return licenceService.getCurrentSaisonLicence(securityCtx).map(licenceModels -> licenceModels.stream().map(SimpleLicence::fromModel).toList());
|
||||
return licenceService.getCurrentSaisonLicence(securityCtx)
|
||||
.map(licenceModels -> licenceModels.stream().map(SimpleLicence::fromModel).toList());
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -142,4 +145,14 @@ public class LicenceEndpoints {
|
||||
public Uni<?> deleteAskLicence(@PathParam("id") long id) {
|
||||
return licenceService.deleteAskLicence(id, checkPerm);
|
||||
}
|
||||
|
||||
// TODO remove after importe all data
|
||||
@GET
|
||||
@Path("import")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<?> setImport(@QueryParam("licence") int licence, @QueryParam("saison") int saison,
|
||||
@QueryParam("valid") int valid) {
|
||||
return licenceService.setImport(licence, saison, valid != 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user