feat(v3.0): implémentation Phases 0-8 — RBAC, lifecycle, multi-org, plans, dashboards
Phase 0 : @RolesAllowed SUPER_ADMIN sur POST/DELETE organisations ; AuthenticationFilter pages super-admin Phase 2 : OrganisationModuleService, @RequiresModule, ModuleAccessFilter, RoleService, PermissionChecker Phase 3 : multi-org context switching (OrganisationContextFilter, headers X-Active-Organisation-Id / X-Active-Role) Phase 4 : feature-gating navigation par typeOrganisation (web MenuBean + mobile MorePage) Phase 5 : MemberLifecycleService — 8 transitions (activer/suspendre/radier/archiver/inviter/accepter/expirer/rappels) Phase 6 : FormuleAbonnement Option C (planCommercial, apiAccess, federationAccess, quotas) + SouscriptionOrganisation méthodes quota Phase 7 : DashboardResource SUPER_ADMIN ajouté ; DashboardBean.checkAccessAndRedirect() ; dashboards distincts par rôle Phase 8 : MembreResourceLifecycleRbacTest, SouscriptionQuotaOptionCTest, OrganisationContextHolderTest, OrganisationContextFilterMultiOrgTest, MemberLifecycleServiceTest
This commit is contained in:
@@ -27,7 +27,7 @@ import org.eclipse.microprofile.openapi.annotations.tags.Tag;
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Tag(name = "Audit", description = "Gestion des logs d'audit")
|
||||
@Slf4j
|
||||
@RolesAllowed({ "ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
public class AuditResource {
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.Map;
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Tag(name = "Dashboard", description = "APIs pour la gestion du dashboard")
|
||||
@RolesAllowed({"ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER"})
|
||||
@RolesAllowed({"ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER", "SUPER_ADMIN"})
|
||||
public class DashboardResource {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(DashboardResource.class);
|
||||
|
||||
@@ -9,6 +9,9 @@ import dev.lions.unionflow.server.api.dto.membre.MembreSearchCriteria;
|
||||
import dev.lions.unionflow.server.api.dto.membre.MembreSearchResultDTO;
|
||||
import dev.lions.unionflow.server.entity.Membre;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.entity.MembreOrganisation;
|
||||
import dev.lions.unionflow.server.repository.MembreOrganisationRepository;
|
||||
import dev.lions.unionflow.server.service.MemberLifecycleService;
|
||||
import dev.lions.unionflow.server.service.MembreKeycloakSyncService;
|
||||
import dev.lions.unionflow.server.service.MembreService;
|
||||
import dev.lions.unionflow.server.service.MembreSuiviService;
|
||||
@@ -68,6 +71,12 @@ public class MembreResource {
|
||||
@Inject
|
||||
OrganisationService organisationService;
|
||||
|
||||
@Inject
|
||||
MemberLifecycleService memberLifecycleService;
|
||||
|
||||
@Inject
|
||||
MembreOrganisationRepository membreOrgRepository;
|
||||
|
||||
@Inject
|
||||
io.quarkus.security.identity.SecurityIdentity securityIdentity;
|
||||
|
||||
@@ -75,6 +84,7 @@ public class MembreResource {
|
||||
JsonWebToken jwt;
|
||||
|
||||
@GET
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MODERATEUR" })
|
||||
@Operation(summary = "Lister les membres")
|
||||
@APIResponse(responseCode = "200", description = "Liste des membres avec pagination")
|
||||
public PagedResponse<MembreSummaryResponse> listerMembres(
|
||||
@@ -130,6 +140,7 @@ public class MembreResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MODERATEUR", "MEMBRE", "USER" })
|
||||
@Operation(summary = "Récupérer un membre par son ID")
|
||||
@APIResponse(responseCode = "200", description = "Membre trouvé")
|
||||
@APIResponse(responseCode = "404", description = "Membre non trouvé")
|
||||
@@ -190,6 +201,34 @@ public class MembreResource {
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste des organisations du membre connecté (pour le sélecteur multi-org).
|
||||
* Inclut le type, la catégorie et les modules actifs de chaque organisation.
|
||||
*/
|
||||
@GET
|
||||
@Path("/mes-organisations")
|
||||
@RolesAllowed({ "USER", "MEMBRE", "ADMIN", "ADMIN_ORGANISATION", "SUPER_ADMIN", "MODERATEUR" })
|
||||
@Operation(summary = "Organisations du membre connecté",
|
||||
description = "Retourne la liste des organisations auxquelles le membre connecté appartient (multi-org)")
|
||||
@APIResponse(responseCode = "200", description = "Liste des organisations")
|
||||
public Response getMesOrganisations() {
|
||||
String email = securityIdentity.getPrincipal().getName();
|
||||
try {
|
||||
var membre = membreService.trouverParEmail(email);
|
||||
if (membre.isEmpty()) {
|
||||
return Response.ok(java.util.List.of()).build();
|
||||
}
|
||||
// Charger les liens membre-organisation avec les infos d'org
|
||||
var liens = organisationService.listerOrganisationsParMembre(membre.get().getId());
|
||||
return Response.ok(liens).build();
|
||||
} catch (Exception e) {
|
||||
LOG.errorf(e, "Erreur lors de la récupération des organisations du membre %s", email);
|
||||
return Response.serverError()
|
||||
.entity(java.util.Map.of("error", "Erreur serveur"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/** Crée et active une fiche membre depuis les claims JWT lors du premier accès. */
|
||||
private Membre autoProvisionnerMembre(String email) {
|
||||
String prenom = "Utilisateur";
|
||||
@@ -307,6 +346,7 @@ public class MembreResource {
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
@Operation(summary = "Mettre à jour un membre existant")
|
||||
@APIResponse(responseCode = "200", description = "Membre mis à jour avec succès")
|
||||
@APIResponse(responseCode = "404", description = "Membre non trouvé")
|
||||
@@ -334,6 +374,7 @@ public class MembreResource {
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN" })
|
||||
@Operation(summary = "Désactiver un membre")
|
||||
@APIResponse(responseCode = "204", description = "Membre désactivé avec succès")
|
||||
@APIResponse(responseCode = "404", description = "Membre non trouvé")
|
||||
@@ -583,6 +624,7 @@ public class MembreResource {
|
||||
|
||||
@POST
|
||||
@Path("/export/selection")
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
@Operation(summary = "Exporter une sélection de membres en Excel")
|
||||
@@ -692,6 +734,7 @@ public class MembreResource {
|
||||
|
||||
@GET
|
||||
@Path("/export")
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
@Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
@Operation(summary = "Exporter des membres en Excel, CSV ou PDF")
|
||||
@APIResponse(responseCode = "200", description = "Fichier exporté")
|
||||
@@ -873,4 +916,345 @@ public class MembreResource {
|
||||
|
||||
return Response.ok(Map.of("count", membres.size())).build();
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Endpoints cycle de vie des adhésions (MemberLifecycleService)
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* Invite un membre existant à rejoindre une organisation.
|
||||
* Crée un lien MembreOrganisation au statut INVITE avec token + expiration 7j.
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreId}/inviter-organisation")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Inviter un membre dans une organisation",
|
||||
description = "Crée une invitation (statut INVITE) pour un membre existant. Token valable 7 jours.")
|
||||
@APIResponse(responseCode = "200", description = "Invitation créée")
|
||||
@APIResponse(responseCode = "404", description = "Membre ou organisation introuvable")
|
||||
@APIResponse(responseCode = "409", description = "Membre déjà lié à cette organisation")
|
||||
public Response inviterMembre(
|
||||
@Parameter(description = "UUID du membre à inviter") @PathParam("membreId") UUID membreId,
|
||||
@Parameter(description = "UUID de l'organisation") @QueryParam("organisationId") UUID organisationId,
|
||||
@Parameter(description = "Rôle proposé (optionnel)") @QueryParam("roleOrg") String roleOrg) {
|
||||
|
||||
if (organisationId == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(Map.of("error", "organisationId est obligatoire")).build();
|
||||
}
|
||||
|
||||
Membre membre = membreService.trouverParId(membreId)
|
||||
.orElseThrow(() -> new NotFoundException("Membre introuvable : " + membreId));
|
||||
Organisation organisation = organisationService.trouverParId(organisationId)
|
||||
.orElseThrow(() -> new NotFoundException("Organisation introuvable : " + organisationId));
|
||||
|
||||
UUID adminId = resolveCurrentAdminId();
|
||||
try {
|
||||
var lien = memberLifecycleService.inviterMembre(membre, organisation, adminId, roleOrg);
|
||||
return Response.ok(Map.of(
|
||||
"membreOrgId", lien.getId(),
|
||||
"statut", lien.getStatutMembre(),
|
||||
"tokenInvitation", lien.getTokenInvitation(),
|
||||
"expiresAt", lien.getDateExpirationInvitation()
|
||||
)).build();
|
||||
} catch (IllegalStateException e) {
|
||||
return Response.status(Response.Status.CONFLICT)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepte une invitation via son token (INVITE → EN_ATTENTE_VALIDATION).
|
||||
* Endpoint public — le membre clique sur le lien reçu par email.
|
||||
*/
|
||||
@POST
|
||||
@Path("/accepter-invitation/{token}")
|
||||
@PermitAll
|
||||
@Operation(summary = "Accepter une invitation",
|
||||
description = "Valide le token d'invitation et passe l'adhésion en EN_ATTENTE_VALIDATION.")
|
||||
@APIResponse(responseCode = "200", description = "Invitation acceptée")
|
||||
@APIResponse(responseCode = "400", description = "Token invalide ou expiré")
|
||||
public Response accepterInvitation(
|
||||
@Parameter(description = "Token d'invitation") @PathParam("token") String token) {
|
||||
try {
|
||||
var lien = memberLifecycleService.accepterInvitation(token);
|
||||
return Response.ok(Map.of(
|
||||
"membreOrgId", lien.getId(),
|
||||
"statut", lien.getStatutMembre(),
|
||||
"organisation", lien.getOrganisation().getNom()
|
||||
)).build();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
} catch (IllegalStateException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Active une adhésion (EN_ATTENTE_VALIDATION / INVITE / SUSPENDU → ACTIF).
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreOrgId}/activer-adhesion")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Activer une adhésion",
|
||||
description = "Transitions autorisées : EN_ATTENTE_VALIDATION, INVITE, SUSPENDU → ACTIF.")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion activée")
|
||||
@APIResponse(responseCode = "404", description = "Lien membre-organisation introuvable")
|
||||
@APIResponse(responseCode = "409", description = "Transition non autorisée depuis le statut actuel")
|
||||
public Response activerAdhesion(
|
||||
@Parameter(description = "UUID du lien membre-organisation") @PathParam("membreOrgId") UUID membreOrgId,
|
||||
Map<String, String> body) {
|
||||
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
UUID adminId = resolveCurrentAdminId();
|
||||
try {
|
||||
var lien = memberLifecycleService.activerMembre(membreOrgId, adminId, motif);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("membreOrgId", lien.getId());
|
||||
result.put("statut", lien.getStatutMembre());
|
||||
result.put("dateChangementStatut", lien.getDateChangementStatut());
|
||||
return Response.ok(result).build();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
} catch (IllegalStateException e) {
|
||||
return Response.status(Response.Status.CONFLICT)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend une adhésion (ACTIF → SUSPENDU).
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreOrgId}/suspendre-adhesion")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Suspendre une adhésion", description = "Transition autorisée : ACTIF → SUSPENDU.")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion suspendue")
|
||||
@APIResponse(responseCode = "404", description = "Lien membre-organisation introuvable")
|
||||
@APIResponse(responseCode = "409", description = "Transition non autorisée")
|
||||
public Response suspendrAdhesion(
|
||||
@Parameter(description = "UUID du lien membre-organisation") @PathParam("membreOrgId") UUID membreOrgId,
|
||||
Map<String, String> body) {
|
||||
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
UUID adminId = resolveCurrentAdminId();
|
||||
try {
|
||||
var lien = memberLifecycleService.suspendreMembre(membreOrgId, adminId, motif);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("membreOrgId", lien.getId());
|
||||
result.put("statut", lien.getStatutMembre());
|
||||
result.put("dateChangementStatut", lien.getDateChangementStatut());
|
||||
return Response.ok(result).build();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
} catch (IllegalStateException e) {
|
||||
return Response.status(Response.Status.CONFLICT)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Radie un membre d'une organisation (→ RADIE).
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreOrgId}/radier-adhesion")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Radier un membre d'une organisation")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion radiée")
|
||||
@APIResponse(responseCode = "404", description = "Lien membre-organisation introuvable")
|
||||
public Response radierAdhesion(
|
||||
@Parameter(description = "UUID du lien membre-organisation") @PathParam("membreOrgId") UUID membreOrgId,
|
||||
Map<String, String> body) {
|
||||
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
UUID adminId = resolveCurrentAdminId();
|
||||
try {
|
||||
var lien = memberLifecycleService.radierMembre(membreOrgId, adminId, motif);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("membreOrgId", lien.getId());
|
||||
result.put("statut", lien.getStatutMembre());
|
||||
result.put("dateChangementStatut", lien.getDateChangementStatut());
|
||||
return Response.ok(result).build();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Archive une adhésion (→ ARCHIVE) sans supprimer l'historique.
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreOrgId}/archiver-adhesion")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Archiver une adhésion",
|
||||
description = "Conserve l'historique sans supprimer le lien membre-organisation.")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion archivée")
|
||||
@APIResponse(responseCode = "404", description = "Lien membre-organisation introuvable")
|
||||
public Response archiverAdhesion(
|
||||
@Parameter(description = "UUID du lien membre-organisation") @PathParam("membreOrgId") UUID membreOrgId,
|
||||
Map<String, String> body) {
|
||||
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
try {
|
||||
var lien = memberLifecycleService.archiverMembre(membreOrgId, motif);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("membreOrgId", lien.getId());
|
||||
result.put("statut", lien.getStatutMembre());
|
||||
result.put("dateChangementStatut", lien.getDateChangementStatut());
|
||||
return Response.ok(result).build();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Endpoints lifecycle par membreId + organisationId (sans membreOrgId)
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* Retourne le statut d'adhésion d'un membre dans une organisation.
|
||||
* Utilisé par le profil membre pour afficher les boutons d'action contextuels.
|
||||
*/
|
||||
@GET
|
||||
@Path("/{membreId}/adhesion")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER"})
|
||||
@Operation(summary = "Statut d'adhésion d'un membre dans une organisation")
|
||||
@APIResponse(responseCode = "200", description = "Statut d'adhésion")
|
||||
@APIResponse(responseCode = "404", description = "Aucun lien membre-organisation trouvé")
|
||||
public Response getAdhesionStatut(
|
||||
@Parameter(description = "UUID du membre") @PathParam("membreId") UUID membreId,
|
||||
@Parameter(description = "UUID de l'organisation") @QueryParam("organisationId") UUID organisationId) {
|
||||
|
||||
if (organisationId == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(Map.of("error", "organisationId requis")).build();
|
||||
}
|
||||
return membreOrgRepository.findByMembreIdAndOrganisationId(membreId, organisationId)
|
||||
.map(lien -> Response.ok(Map.of(
|
||||
"membreOrgId", lien.getId(),
|
||||
"statut", lien.getStatutMembre(),
|
||||
"dateInvitation", lien.getDateInvitation() != null ? lien.getDateInvitation().toString() : "",
|
||||
"dateExpiration", lien.getDateExpirationInvitation() != null ? lien.getDateExpirationInvitation().toString() : "",
|
||||
"roleOrg", lien.getRoleOrg() != null ? lien.getRoleOrg() : "",
|
||||
"motifStatut", lien.getMotifStatut() != null ? lien.getMotifStatut() : ""
|
||||
)).build())
|
||||
.orElse(Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Aucune adhésion trouvée")).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Active l'adhésion d'un membre (EN_ATTENTE/INVITE/SUSPENDU → ACTIF)
|
||||
* en passant par membreId + organisationId plutôt que membreOrgId.
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreId}/adhesion/activer")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Activer l'adhésion par membreId + organisationId")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion activée")
|
||||
@APIResponse(responseCode = "404", description = "Lien membre-organisation introuvable")
|
||||
public Response activerAdhesionParMembre(
|
||||
@Parameter(description = "UUID du membre") @PathParam("membreId") UUID membreId,
|
||||
@Parameter(description = "UUID de l'organisation") @QueryParam("organisationId") UUID organisationId,
|
||||
Map<String, String> body) {
|
||||
|
||||
if (organisationId == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(Map.of("error", "organisationId requis")).build();
|
||||
}
|
||||
MembreOrganisation lien = membreOrgRepository
|
||||
.findByMembreIdAndOrganisationId(membreId, organisationId)
|
||||
.orElse(null);
|
||||
if (lien == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Aucune adhésion trouvée")).build();
|
||||
}
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
UUID adminId = resolveCurrentAdminId();
|
||||
try {
|
||||
var updated = memberLifecycleService.activerMembre(lien.getId(), adminId, motif);
|
||||
return Response.ok(Map.of("statut", updated.getStatutMembre())).build();
|
||||
} catch (IllegalStateException e) {
|
||||
return Response.status(Response.Status.CONFLICT).entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend l'adhésion d'un membre (ACTIF → SUSPENDU) par membreId + organisationId.
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreId}/adhesion/suspendre")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Suspendre l'adhésion par membreId + organisationId")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion suspendue")
|
||||
@APIResponse(responseCode = "404", description = "Lien membre-organisation introuvable")
|
||||
public Response suspendrAdhesionParMembre(
|
||||
@Parameter(description = "UUID du membre") @PathParam("membreId") UUID membreId,
|
||||
@Parameter(description = "UUID de l'organisation") @QueryParam("organisationId") UUID organisationId,
|
||||
Map<String, String> body) {
|
||||
|
||||
if (organisationId == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(Map.of("error", "organisationId requis")).build();
|
||||
}
|
||||
MembreOrganisation lien = membreOrgRepository
|
||||
.findByMembreIdAndOrganisationId(membreId, organisationId)
|
||||
.orElse(null);
|
||||
if (lien == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Aucune adhésion trouvée")).build();
|
||||
}
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
UUID adminId = resolveCurrentAdminId();
|
||||
try {
|
||||
var updated = memberLifecycleService.suspendreMembre(lien.getId(), adminId, motif);
|
||||
return Response.ok(Map.of("statut", updated.getStatutMembre())).build();
|
||||
} catch (IllegalStateException e) {
|
||||
return Response.status(Response.Status.CONFLICT).entity(Map.of("error", e.getMessage())).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Radie un membre d'une organisation par membreId + organisationId.
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{membreId}/adhesion/radier")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Operation(summary = "Radier par membreId + organisationId")
|
||||
@APIResponse(responseCode = "200", description = "Adhésion radiée")
|
||||
public Response radierAdhesionParMembre(
|
||||
@Parameter(description = "UUID du membre") @PathParam("membreId") UUID membreId,
|
||||
@Parameter(description = "UUID de l'organisation") @QueryParam("organisationId") UUID organisationId,
|
||||
Map<String, String> body) {
|
||||
|
||||
if (organisationId == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(Map.of("error", "organisationId requis")).build();
|
||||
}
|
||||
MembreOrganisation lien = membreOrgRepository
|
||||
.findByMembreIdAndOrganisationId(membreId, organisationId)
|
||||
.orElse(null);
|
||||
if (lien == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Aucune adhésion trouvée")).build();
|
||||
}
|
||||
String motif = body != null ? body.get("motif") : null;
|
||||
var updated = memberLifecycleService.radierMembre(lien.getId(), resolveCurrentAdminId(), motif);
|
||||
return Response.ok(Map.of("statut", updated.getStatutMembre())).build();
|
||||
}
|
||||
|
||||
/** Résout l'UUID de l'admin connecté depuis le JWT subject. */
|
||||
private UUID resolveCurrentAdminId() {
|
||||
try {
|
||||
String sub = jwt != null ? jwt.getSubject() : null;
|
||||
return sub != null ? UUID.fromString(sub) : null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import dev.lions.unionflow.server.repository.MembreRepository;
|
||||
@Path("/api/notifications")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RolesAllowed({ "ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MODERATEUR", "MEMBRE", "USER" })
|
||||
@Tag(name = "Notifications", description = "Gestion des notifications : envoi, templates et notifications groupées")
|
||||
public class NotificationResource {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class NotificationResource {
|
||||
* @return Template créé
|
||||
*/
|
||||
@POST
|
||||
@RolesAllowed({ "ADMIN", "ADMIN_ORGANISATION", "MEMBRE" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
@Path("/templates")
|
||||
public Response creerTemplate(@Valid CreateTemplateNotificationRequest request) {
|
||||
try {
|
||||
@@ -128,7 +128,7 @@ public class NotificationResource {
|
||||
* @return Notification créée
|
||||
*/
|
||||
@POST
|
||||
@RolesAllowed({ "ADMIN", "ADMIN_ORGANISATION", "MEMBRE" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
public Response creerNotification(@Valid CreateNotificationRequest request) {
|
||||
try {
|
||||
NotificationResponse result = notificationService.creerNotification(request);
|
||||
@@ -148,7 +148,7 @@ public class NotificationResource {
|
||||
* @return Notification mise à jour
|
||||
*/
|
||||
@POST
|
||||
@RolesAllowed({ "ADMIN", "ADMIN_ORGANISATION", "MEMBRE" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MODERATEUR", "MEMBRE", "USER" })
|
||||
@Path("/{id}/marquer-lue")
|
||||
public Response marquerCommeLue(@PathParam("id") UUID id) {
|
||||
try {
|
||||
@@ -260,7 +260,7 @@ public class NotificationResource {
|
||||
* @return Nombre de notifications créées
|
||||
*/
|
||||
@POST
|
||||
@RolesAllowed({ "ADMIN", "ADMIN_ORGANISATION", "MEMBRE" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
@Path("/groupees")
|
||||
public Response envoyerNotificationsGroupees(NotificationGroupeeRequest request) {
|
||||
try {
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.lions.unionflow.server.api.dto.organisation.response.OrganisationResp
|
||||
import dev.lions.unionflow.server.api.dto.organisation.response.OrganisationSummaryResponse;
|
||||
import dev.lions.unionflow.server.entity.Organisation;
|
||||
import dev.lions.unionflow.server.service.KeycloakService;
|
||||
import dev.lions.unionflow.server.service.OrganisationModuleService;
|
||||
import dev.lions.unionflow.server.service.OrganisationService;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
@@ -53,6 +54,8 @@ public class OrganisationResource {
|
||||
|
||||
@Inject SecurityIdentity securityIdentity;
|
||||
|
||||
@Inject OrganisationModuleService organisationModuleService;
|
||||
|
||||
@Inject
|
||||
dev.lions.unionflow.server.repository.MembreOrganisationRepository membreOrganisationRepository;
|
||||
|
||||
@@ -245,7 +248,7 @@ public class OrganisationResource {
|
||||
|
||||
/** Met à jour une organisation */
|
||||
@PUT
|
||||
@RolesAllowed({"ADMIN", "ADMIN_ORGANISATION", "MEMBRE"})
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
@Path("/{id}")
|
||||
|
||||
@Operation(
|
||||
@@ -493,4 +496,25 @@ public class OrganisationResource {
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/** Retourne les modules actifs pour une organisation (déterminés par son type) */
|
||||
@GET
|
||||
@Path("/{id}/modules-actifs")
|
||||
@Operation(
|
||||
summary = "Modules actifs de l'organisation",
|
||||
description = "Retourne la liste des modules disponibles selon le type de l'organisation (Option C)")
|
||||
@APIResponse(responseCode = "200", description = "Liste des modules actifs")
|
||||
@APIResponse(responseCode = "404", description = "Organisation non trouvée")
|
||||
public Response getModulesActifs(
|
||||
@Parameter(description = "UUID de l'organisation", required = true) @PathParam("id") UUID id) {
|
||||
try {
|
||||
OrganisationModuleService.ModulesActifsResponse result = organisationModuleService.getModulesActifsResponse(id);
|
||||
return Response.ok(result).build();
|
||||
} catch (Exception e) {
|
||||
LOG.errorf(e, "Erreur lors de la récupération des modules actifs pour l'organisation %s", id);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
||||
.entity(Map.of("error", "Erreur interne du serveur"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.lions.unionflow.server.resource.agricole;
|
||||
import dev.lions.unionflow.server.api.dto.agricole.CampagneAgricoleDTO;
|
||||
import dev.lions.unionflow.server.service.agricole.CampagneAgricoleService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -16,13 +17,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/agricole/campagnes")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("AGRICULTURE")
|
||||
public class CampagneAgricoleResource {
|
||||
|
||||
@Inject
|
||||
CampagneAgricoleService campagneAgricoleService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "coop_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "COOP_RESP" })
|
||||
public Response creerCampagne(@Valid CampagneAgricoleDTO dto) {
|
||||
CampagneAgricoleDTO response = campagneAgricoleService.creerCampagne(dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -30,7 +32,7 @@ public class CampagneAgricoleResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "coop_resp", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "COOP_RESP", "MEMBRE", "USER" })
|
||||
public Response getCampagneById(@PathParam("id") UUID id) {
|
||||
CampagneAgricoleDTO response = campagneAgricoleService.getCampagneById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -38,7 +40,7 @@ public class CampagneAgricoleResource {
|
||||
|
||||
@GET
|
||||
@Path("/cooperative/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "coop_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "COOP_RESP" })
|
||||
public Response getCampagnesByCooperative(@PathParam("organisationId") UUID organisationId) {
|
||||
List<CampagneAgricoleDTO> response = campagneAgricoleService.getCampagnesByCooperative(organisationId);
|
||||
return Response.ok(response).build();
|
||||
|
||||
@@ -4,6 +4,7 @@ import dev.lions.unionflow.server.api.dto.collectefonds.CampagneCollecteResponse
|
||||
import dev.lions.unionflow.server.api.dto.collectefonds.ContributionCollecteDTO;
|
||||
import dev.lions.unionflow.server.service.collectefonds.CampagneCollecteService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -17,6 +18,7 @@ import java.util.UUID;
|
||||
@Path("/api/v1/collectefonds/campagnes")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("COLLECTE_FONDS")
|
||||
public class CampagneCollecteResource {
|
||||
|
||||
@Inject
|
||||
@@ -24,7 +26,7 @@ public class CampagneCollecteResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response getCampagneById(@PathParam("id") UUID id) {
|
||||
CampagneCollecteResponse response = campagneCollecteService.getCampagneById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -32,7 +34,7 @@ public class CampagneCollecteResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
public Response getCampagnesByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<CampagneCollecteResponse> response = campagneCollecteService.getCampagnesByOrganisation(organisationId);
|
||||
return Response.ok(response).build();
|
||||
@@ -40,7 +42,7 @@ public class CampagneCollecteResource {
|
||||
|
||||
@POST
|
||||
@Path("/{id}/contribuer")
|
||||
@RolesAllowed({ "membre_actif" })
|
||||
@RolesAllowed({ "MEMBRE", "USER" })
|
||||
public Response contribuer(@PathParam("id") UUID id, @Valid ContributionCollecteDTO dto) {
|
||||
ContributionCollecteDTO response = campagneCollecteService.contribuer(id, dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.lions.unionflow.server.resource.culte;
|
||||
import dev.lions.unionflow.server.api.dto.culte.DonReligieuxDTO;
|
||||
import dev.lions.unionflow.server.service.culte.DonReligieuxService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -16,13 +17,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/culte/dons")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("CULTE_DONS")
|
||||
public class DonReligieuxResource {
|
||||
|
||||
@Inject
|
||||
DonReligieuxService donReligieuxService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "membre_actif", "admin", "admin_organisation" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response enregistrerDon(@Valid DonReligieuxDTO dto) {
|
||||
DonReligieuxDTO response = donReligieuxService.enregistrerDon(dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -30,7 +32,7 @@ public class DonReligieuxResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "culte_resp", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "CULTE_RESP", "MEMBRE", "USER" })
|
||||
public Response getDonById(@PathParam("id") UUID id) {
|
||||
DonReligieuxDTO response = donReligieuxService.getDonById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -38,7 +40,7 @@ public class DonReligieuxResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "culte_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "CULTE_RESP" })
|
||||
public Response getDonsByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<DonReligieuxDTO> response = donReligieuxService.getDonsByOrganisation(organisationId);
|
||||
return Response.ok(response).build();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EchelonOrganigrammeResource {
|
||||
EchelonOrganigrammeService echelonOrganigrammeService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION" })
|
||||
public Response creerEchelon(@Valid EchelonOrganigrammeDTO dto) {
|
||||
EchelonOrganigrammeDTO response = echelonOrganigrammeService.creerEchelon(dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -30,7 +30,7 @@ public class EchelonOrganigrammeResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response getEchelonById(@PathParam("id") UUID id) {
|
||||
EchelonOrganigrammeDTO response = echelonOrganigrammeService.getEchelonById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -38,7 +38,7 @@ public class EchelonOrganigrammeResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response getOrganigrammeByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<EchelonOrganigrammeDTO> response = echelonOrganigrammeService
|
||||
.getOrganigrammeByOrganisation(organisationId);
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.lions.unionflow.server.api.dto.mutuelle.credit.DemandeCreditResponse;
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutDemandeCredit;
|
||||
import dev.lions.unionflow.server.service.mutuelle.credit.DemandeCreditService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -20,13 +21,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/mutuelle/credits")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("CREDIT")
|
||||
public class DemandeCreditResource {
|
||||
|
||||
@Inject
|
||||
DemandeCreditService demandeCreditService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "membre_actif" })
|
||||
@RolesAllowed({ "MEMBRE", "USER" })
|
||||
public Response soumettreDemande(@Valid DemandeCreditRequest request) {
|
||||
DemandeCreditResponse response = demandeCreditService.soumettreDemande(request);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -34,7 +36,7 @@ public class DemandeCreditResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "mutuelle_resp", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response getDemandeById(@PathParam("id") UUID id) {
|
||||
DemandeCreditResponse response = demandeCreditService.getDemandeById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -42,7 +44,7 @@ public class DemandeCreditResource {
|
||||
|
||||
@GET
|
||||
@Path("/membre/{membreId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "mutuelle_resp", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response getDemandesByMembre(@PathParam("membreId") UUID membreId) {
|
||||
List<DemandeCreditResponse> response = demandeCreditService.getDemandesByMembre(membreId);
|
||||
return Response.ok(response).build();
|
||||
@@ -50,7 +52,7 @@ public class DemandeCreditResource {
|
||||
|
||||
@PATCH
|
||||
@Path("/{id}/statut")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "mutuelle_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP" })
|
||||
public Response changerStatut(
|
||||
@PathParam("id") UUID id,
|
||||
@QueryParam("statut") StatutDemandeCredit statut,
|
||||
@@ -64,7 +66,7 @@ public class DemandeCreditResource {
|
||||
|
||||
@POST
|
||||
@Path("/{id}/approbation")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "mutuelle_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP" })
|
||||
public Response approuver(
|
||||
@PathParam("id") UUID id,
|
||||
@QueryParam("montant") BigDecimal montant,
|
||||
@@ -77,7 +79,7 @@ public class DemandeCreditResource {
|
||||
|
||||
@POST
|
||||
@Path("/{id}/decaissement")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "mutuelle_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP" })
|
||||
public Response decaisser(
|
||||
@PathParam("id") UUID id,
|
||||
@QueryParam("datePremiereEcheance") String datePremiereEcheance) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.lions.unionflow.server.api.dto.mutuelle.epargne.CompteEpargneResponse
|
||||
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.StatutCompteEpargne;
|
||||
import dev.lions.unionflow.server.service.mutuelle.epargne.CompteEpargneService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -18,13 +19,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/epargne/comptes")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("EPARGNE")
|
||||
public class CompteEpargneResource {
|
||||
|
||||
@Inject
|
||||
CompteEpargneService compteEpargneService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP" })
|
||||
public Response creerCompte(@Valid CompteEpargneRequest request) {
|
||||
CompteEpargneResponse compte = compteEpargneService.creerCompte(request);
|
||||
return Response.status(Response.Status.CREATED).entity(compte).build();
|
||||
@@ -32,7 +34,7 @@ public class CompteEpargneResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp", "membre_actif", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response getCompteById(@PathParam("id") UUID id) {
|
||||
CompteEpargneResponse compte = compteEpargneService.getCompteById(id);
|
||||
return Response.ok(compte).build();
|
||||
@@ -40,7 +42,7 @@ public class CompteEpargneResource {
|
||||
|
||||
@GET
|
||||
@Path("/mes-comptes")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp", "membre_actif", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response getMesComptes() {
|
||||
List<CompteEpargneResponse> comptes = compteEpargneService.getMesComptes();
|
||||
return Response.ok(comptes).build();
|
||||
@@ -48,7 +50,7 @@ public class CompteEpargneResource {
|
||||
|
||||
@GET
|
||||
@Path("/membre/{membreId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp", "membre_actif", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response getComptesByMembre(@PathParam("membreId") UUID membreId) {
|
||||
List<CompteEpargneResponse> comptes = compteEpargneService.getComptesByMembre(membreId);
|
||||
return Response.ok(comptes).build();
|
||||
@@ -56,7 +58,7 @@ public class CompteEpargneResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP" })
|
||||
public Response getComptesByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<CompteEpargneResponse> comptes = compteEpargneService.getComptesByOrganisation(organisationId);
|
||||
return Response.ok(comptes).build();
|
||||
@@ -64,7 +66,7 @@ public class CompteEpargneResource {
|
||||
|
||||
@PATCH
|
||||
@Path("/{id}/statut")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP" })
|
||||
public Response changerStatut(@PathParam("id") UUID id, @QueryParam("statut") StatutCompteEpargne statut) {
|
||||
if (statut == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("Le statut est requis").build();
|
||||
|
||||
@@ -4,6 +4,7 @@ import dev.lions.unionflow.server.api.dto.mutuelle.epargne.TransactionEpargneReq
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.epargne.TransactionEpargneResponse;
|
||||
import dev.lions.unionflow.server.service.mutuelle.epargne.TransactionEpargneService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -17,13 +18,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/epargne/transactions")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("EPARGNE")
|
||||
public class TransactionEpargneResource {
|
||||
|
||||
@Inject
|
||||
TransactionEpargneService transactionEpargneService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp", "MEMBRE", "MEMBRE_ACTIF", "membre_actif", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response executerTransaction(@Valid TransactionEpargneRequest request) {
|
||||
TransactionEpargneResponse transaction = transactionEpargneService.executerTransaction(request);
|
||||
return Response.status(Response.Status.CREATED).entity(transaction).build();
|
||||
@@ -31,7 +33,7 @@ public class TransactionEpargneResource {
|
||||
|
||||
@POST
|
||||
@Path("/transfert")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp", "membre_actif", "MEMBRE_ACTIF", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response transferer(@Valid TransactionEpargneRequest request) {
|
||||
TransactionEpargneResponse transaction = transactionEpargneService.transferer(request);
|
||||
return Response.status(Response.Status.CREATED).entity(transaction).build();
|
||||
@@ -39,7 +41,7 @@ public class TransactionEpargneResource {
|
||||
|
||||
@GET
|
||||
@Path("/compte/{compteId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ADMIN", "ADMIN_ORGANISATION", "mutuelle_resp", "membre_actif", "MEMBRE_ACTIF", "MEMBRE", "USER" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER" })
|
||||
public Response getTransactionsByCompte(@PathParam("compteId") UUID compteId) {
|
||||
List<TransactionEpargneResponse> transactions = transactionEpargneService.getTransactionsByCompte(compteId);
|
||||
return Response.ok(transactions).build();
|
||||
|
||||
@@ -4,6 +4,7 @@ import dev.lions.unionflow.server.api.dto.ong.ProjetOngDTO;
|
||||
import dev.lions.unionflow.server.api.enums.ong.StatutProjetOng;
|
||||
import dev.lions.unionflow.server.service.ong.ProjetOngService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -17,13 +18,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/ong/projets")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("PROJETS_ONG")
|
||||
public class ProjetOngResource {
|
||||
|
||||
@Inject
|
||||
ProjetOngService projetOngService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ong_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "ONG_RESP" })
|
||||
public Response creerProjet(@Valid ProjetOngDTO dto) {
|
||||
ProjetOngDTO response = projetOngService.creerProjet(dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -31,7 +33,7 @@ public class ProjetOngResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response getProjetById(@PathParam("id") UUID id) {
|
||||
ProjetOngDTO response = projetOngService.getProjetById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -39,7 +41,7 @@ public class ProjetOngResource {
|
||||
|
||||
@GET
|
||||
@Path("/ong/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ong_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "ONG_RESP" })
|
||||
public Response getProjetsByOng(@PathParam("organisationId") UUID organisationId) {
|
||||
List<ProjetOngDTO> response = projetOngService.getProjetsByOng(organisationId);
|
||||
return Response.ok(response).build();
|
||||
@@ -47,7 +49,7 @@ public class ProjetOngResource {
|
||||
|
||||
@PATCH
|
||||
@Path("/{id}/statut")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "ong_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "ONG_RESP" })
|
||||
public Response changerStatut(@PathParam("id") UUID id, @QueryParam("statut") StatutProjetOng statut) {
|
||||
if (statut == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("Le statut est requis").build();
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.lions.unionflow.server.resource.registre;
|
||||
import dev.lions.unionflow.server.api.dto.registre.AgrementProfessionnelDTO;
|
||||
import dev.lions.unionflow.server.service.registre.AgrementProfessionnelService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -16,13 +17,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/registre/agrements")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("REGISTRE_AGREMENT")
|
||||
public class AgrementProfessionnelResource {
|
||||
|
||||
@Inject
|
||||
AgrementProfessionnelService agrementProfessionnelService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "registre_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "REGISTRE_RESP" })
|
||||
public Response enregistrerAgrement(@Valid AgrementProfessionnelDTO dto) {
|
||||
AgrementProfessionnelDTO response = agrementProfessionnelService.enregistrerAgrement(dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -30,7 +32,7 @@ public class AgrementProfessionnelResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response getAgrementById(@PathParam("id") UUID id) {
|
||||
AgrementProfessionnelDTO response = agrementProfessionnelService.getAgrementById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -38,7 +40,7 @@ public class AgrementProfessionnelResource {
|
||||
|
||||
@GET
|
||||
@Path("/membre/{membreId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MEMBRE", "USER" })
|
||||
public Response getAgrementsByMembre(@PathParam("membreId") UUID membreId) {
|
||||
List<AgrementProfessionnelDTO> response = agrementProfessionnelService.getAgrementsByMembre(membreId);
|
||||
return Response.ok(response).build();
|
||||
@@ -46,7 +48,7 @@ public class AgrementProfessionnelResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "registre_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "REGISTRE_RESP" })
|
||||
public Response getAgrementsByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<AgrementProfessionnelDTO> response = agrementProfessionnelService
|
||||
.getAgrementsByOrganisation(organisationId);
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.lions.unionflow.server.api.dto.tontine.TontineResponse;
|
||||
import dev.lions.unionflow.server.api.enums.tontine.StatutTontine;
|
||||
import dev.lions.unionflow.server.service.tontine.TontineService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -18,13 +19,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/tontines")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("TONTINE")
|
||||
public class TontineResource {
|
||||
|
||||
@Inject
|
||||
TontineService tontineService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "tontine_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "TONTINE_RESP" })
|
||||
public Response creerTontine(@Valid TontineRequest request) {
|
||||
TontineResponse response = tontineService.creerTontine(request);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -32,7 +34,7 @@ public class TontineResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "tontine_resp", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "TONTINE_RESP", "MEMBRE", "USER" })
|
||||
public Response getTontineById(@PathParam("id") UUID id) {
|
||||
TontineResponse response = tontineService.getTontineById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -40,7 +42,7 @@ public class TontineResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "tontine_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "TONTINE_RESP" })
|
||||
public Response getTontinesByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<TontineResponse> response = tontineService.getTontinesByOrganisation(organisationId);
|
||||
return Response.ok(response).build();
|
||||
@@ -48,7 +50,7 @@ public class TontineResource {
|
||||
|
||||
@PATCH
|
||||
@Path("/{id}/statut")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "tontine_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "TONTINE_RESP" })
|
||||
public Response changerStatut(@PathParam("id") UUID id, @QueryParam("statut") StatutTontine statut) {
|
||||
if (statut == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("Le statut est requis").build();
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.lions.unionflow.server.api.dto.vote.CandidatDTO;
|
||||
import dev.lions.unionflow.server.api.enums.vote.StatutVote;
|
||||
import dev.lions.unionflow.server.service.vote.CampagneVoteService;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -19,13 +20,14 @@ import java.util.UUID;
|
||||
@Path("/api/v1/vote/campagnes")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("VOTES")
|
||||
public class CampagneVoteResource {
|
||||
|
||||
@Inject
|
||||
CampagneVoteService campagneVoteService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({ "admin", "admin_organisation", "vote_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "VOTE_RESP" })
|
||||
public Response creerCampagne(@Valid CampagneVoteRequest request) {
|
||||
CampagneVoteResponse response = campagneVoteService.creerCampagne(request);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@@ -33,7 +35,7 @@ public class CampagneVoteResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "vote_resp", "membre_actif" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "VOTE_RESP", "MEMBRE", "USER" })
|
||||
public Response getCampagneById(@PathParam("id") UUID id) {
|
||||
CampagneVoteResponse response = campagneVoteService.getCampagneById(id);
|
||||
return Response.ok(response).build();
|
||||
@@ -41,7 +43,7 @@ public class CampagneVoteResource {
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{organisationId}")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "vote_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "VOTE_RESP" })
|
||||
public Response getCampagnesByOrganisation(@PathParam("organisationId") UUID organisationId) {
|
||||
List<CampagneVoteResponse> response = campagneVoteService.getCampagnesByOrganisation(organisationId);
|
||||
return Response.ok(response).build();
|
||||
@@ -49,7 +51,7 @@ public class CampagneVoteResource {
|
||||
|
||||
@PATCH
|
||||
@Path("/{id}/statut")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "vote_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "VOTE_RESP" })
|
||||
public Response changerStatut(@PathParam("id") UUID id, @QueryParam("statut") StatutVote statut) {
|
||||
if (statut == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("Le statut est requis").build();
|
||||
@@ -60,7 +62,7 @@ public class CampagneVoteResource {
|
||||
|
||||
@POST
|
||||
@Path("/{id}/candidats")
|
||||
@RolesAllowed({ "admin", "admin_organisation", "vote_resp" })
|
||||
@RolesAllowed({ "ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "VOTE_RESP" })
|
||||
public Response ajouterCandidat(@PathParam("id") UUID id, @Valid CandidatDTO dto) {
|
||||
CandidatDTO response = campagneVoteService.ajouterCandidat(id, dto);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
|
||||
Reference in New Issue
Block a user