feat: affiliation request list
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.titionfire.ffsaf.rest;
|
||||
import fr.titionfire.ffsaf.domain.service.AffiliationService;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleAffiliation;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleReqAffiliation;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleReqAffiliationResume;
|
||||
import fr.titionfire.ffsaf.rest.from.AffiliationRequestForm;
|
||||
import fr.titionfire.ffsaf.rest.from.AffiliationRequestSaveForm;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
@@ -44,6 +45,22 @@ public class AffiliationEndpoints {
|
||||
throw new ForbiddenException();
|
||||
});
|
||||
|
||||
@GET
|
||||
@Path("/request")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<List<SimpleReqAffiliationResume>> getAllAffRequest() {
|
||||
return service.getAllReq().map(o -> o.stream().map(SimpleReqAffiliationResume::fromModel).toList());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/request")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
public Uni<String> saveAffRequest(AffiliationRequestForm form) {
|
||||
return service.save(form);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/request/{id}")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@@ -78,20 +95,12 @@ public class AffiliationEndpoints {
|
||||
return service.accept(form);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/request")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
public Uni<String> saveAffRequest(AffiliationRequestForm form) {
|
||||
return service.save(form);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/current")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<List<SimpleAffiliation>> getCurrentSaisonLicenceAdmin() {
|
||||
public Uni<List<SimpleAffiliation>> getCurrentSaisonAffiliationAdmin() {
|
||||
return service.getCurrentSaisonAffiliation();
|
||||
}
|
||||
|
||||
@@ -99,7 +108,7 @@ public class AffiliationEndpoints {
|
||||
@Path("{id}")
|
||||
@RolesAllowed({"federation_admin", "club_president", "club_secretaire", "club_respo_intra"})
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<List<SimpleAffiliation>> getLicence(@PathParam("id") long id) {
|
||||
public Uni<List<SimpleAffiliation>> getAffiliation(@PathParam("id") long id) {
|
||||
return Uni.createFrom().item(id).invoke(checkPerm).chain(__ -> service.getAffiliation(id));
|
||||
}
|
||||
|
||||
@@ -107,7 +116,7 @@ public class AffiliationEndpoints {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("federation_admin")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<SimpleAffiliation> setLicence(@PathParam("id") long id, @QueryParam("saison") int saison) {
|
||||
public Uni<SimpleAffiliation> setAffiliation(@PathParam("id") long id, @QueryParam("saison") int saison) {
|
||||
return service.setAffiliation(id, saison);
|
||||
}
|
||||
|
||||
@@ -115,7 +124,7 @@ public class AffiliationEndpoints {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("federation_admin")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public Uni<?> deleteLicence(@PathParam("id") long id) {
|
||||
public Uni<?> deleteAffiliation(@PathParam("id") long id) {
|
||||
return service.deleteAffiliation(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package fr.titionfire.ffsaf.rest.data;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.AffiliationRequestModel;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@RegisterForReflection
|
||||
public class SimpleReqAffiliationResume {
|
||||
Long id;
|
||||
String name;
|
||||
long siret;
|
||||
int saison;
|
||||
|
||||
public static SimpleReqAffiliationResume fromModel(AffiliationRequestModel model) {
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
return new SimpleReqAffiliationResume.SimpleReqAffiliationResumeBuilder()
|
||||
.id(model.getId())
|
||||
.name(model.getName())
|
||||
.siret(model.getSiret())
|
||||
.saison(model.getSaison())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user