feat: club membre export
This commit is contained in:
@@ -2,6 +2,7 @@ package fr.titionfire.ffsaf.rest;
|
||||
|
||||
import fr.titionfire.ffsaf.domain.service.MembreService;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleMembre;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleMembreInOutData;
|
||||
import fr.titionfire.ffsaf.rest.exception.DInternalError;
|
||||
import fr.titionfire.ffsaf.rest.from.ClubMemberForm;
|
||||
import fr.titionfire.ffsaf.rest.from.FullMemberForm;
|
||||
@@ -21,6 +22,8 @@ import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
|
||||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
|
||||
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "Membre club", description = "Gestion des membres (pour les clubs)")
|
||||
@RolesAllowed({"club_president", "club_secretaire", "club_respo_intra"})
|
||||
@Path("api/member")
|
||||
@@ -55,6 +58,19 @@ public class MembreClubEndpoints {
|
||||
return membreService.search(limit, page - 1, search, securityCtx.getSubject());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("club/export")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Operation(summary = "Exporte les membres du club", description = "Exporte les membres du club")
|
||||
@APIResponses(value = {
|
||||
@APIResponse(responseCode = "200", description = "Les membres du club ont été exportés avec succès"),
|
||||
@APIResponse(responseCode = "403", description = "Accès refusé"),
|
||||
@APIResponse(responseCode = "500", description = "Erreur interne du serveur")
|
||||
})
|
||||
public Uni<List<SimpleMembreInOutData>> exportMembre() {
|
||||
return membreService.getAllExport(securityCtx.getSubject());
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("club/{id}")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package fr.titionfire.ffsaf.rest.data;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.LicenceModel;
|
||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@RegisterForReflection
|
||||
@AllArgsConstructor
|
||||
public class SimpleMembreInOutData {
|
||||
Integer licence;
|
||||
String nom;
|
||||
String prenom;
|
||||
String email;
|
||||
String genre;
|
||||
Date birthdate;
|
||||
boolean licenceCurrent;
|
||||
String certif;
|
||||
|
||||
public static SimpleMembreInOutData fromModel(MembreModel membreModel, List<LicenceModel> lc) {
|
||||
LicenceModel currentLicence = lc.stream().filter(l -> l.getMembre().getId().equals(membreModel.getId()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
return new SimpleMembreInOutData(
|
||||
membreModel.getLicence(),
|
||||
membreModel.getLname(),
|
||||
membreModel.getFname(),
|
||||
membreModel.getEmail(),
|
||||
membreModel.getGenre().str,
|
||||
membreModel.getBirth_date(),
|
||||
currentLicence != null,
|
||||
currentLicence == null ? null : currentLicence.getCertificate()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user