wip: Affiliation request

This commit is contained in:
2024-07-14 23:04:22 +02:00
parent b2438ec3d8
commit 682894f326
20 changed files with 322 additions and 53 deletions

View File

@@ -2,6 +2,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.from.AffiliationRequestForm;
import fr.titionfire.ffsaf.utils.GroupeUtils;
import io.quarkus.oidc.IdToken;
@@ -35,7 +36,16 @@ public class AffiliationEndpoints {
throw new ForbiddenException();
});
@GET
@Path("/request/{id}")
@RolesAllowed({"federation_admin"})
@Produces(MediaType.APPLICATION_JSON)
public Uni<SimpleReqAffiliation> getAffRequest(@PathParam("id") long id) {
return service.getRequest(id);
}
@POST
@Path("/request")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Uni<String> saveAffRequest(AffiliationRequestForm form) {

View File

@@ -26,6 +26,7 @@ import java.io.*;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.nio.file.Files;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.function.Consumer;
@@ -68,6 +69,14 @@ public class CombEndpoints {
return membreService.searchAdmin(limit, page - 1, search, club);
}
@GET
@Path("/find/similar")
@RolesAllowed({"federation_admin"})
@Produces(MediaType.APPLICATION_JSON)
public Uni<List<SimpleMembre>> getSimilar(@QueryParam("fname") String fname, @QueryParam("lname") String lname) {
return membreService.getSimilar(fname, lname);
}
@GET
@Path("/find/club")
@RolesAllowed({"club_president", "club_secretaire", "club_respo_intra"})
@@ -90,6 +99,14 @@ public class CombEndpoints {
return membreService.getById(id).onItem().invoke(checkPerm).map(SimpleMembre::fromModel);
}
@GET
@Path("/find/licence")
@RolesAllowed({"federation_admin", "club_president", "club_secretaire", "club_respo_intra"})
@Produces(MediaType.APPLICATION_JSON)
public Uni<SimpleMembre> getByLicence(@QueryParam("id") long id) {
return membreService.getByLicence(id).onItem().invoke(checkPerm).map(SimpleMembre::fromModel);
}
@PUT
@Path("{id}")
@RolesAllowed({"federation_admin"})

View File

@@ -27,7 +27,7 @@ public class SimpleClub {
private String contact_intern;
private String RNA;
private Long SIRET;
private String no_affiliation;
private Long no_affiliation;
private boolean international;
private HashMap<String, String> contactMap = null;

View File

@@ -0,0 +1,60 @@
package fr.titionfire.ffsaf.rest.data;
import fr.titionfire.ffsaf.data.model.AffiliationRequestModel;
import fr.titionfire.ffsaf.utils.RoleAsso;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@RegisterForReflection
public class SimpleReqAffiliation {
Long id;
Long club;
String club_name;
Long club_no_aff;
String name;
long siret;
String RNA;
String address;
List<AffiliationMember> members;
int saison;
public static SimpleReqAffiliation fromModel(AffiliationRequestModel model) {
if (model == null)
return null;
return new SimpleReqAffiliation.SimpleReqAffiliationBuilder()
.id(model.getId())
.name(model.getName())
.siret(model.getSiret())
.RNA(model.getRNA())
.address(model.getAddress())
.saison(model.getSaison())
.members(List.of(
new AffiliationMember(model.getM1_lname(), model.getM1_fname(), model.getM1_email(),
model.getM1_lincence(), model.getM1_role()),
new AffiliationMember(model.getM2_lname(), model.getM2_fname(), model.getM2_email(),
model.getM2_lincence(), model.getM2_role()),
new AffiliationMember(model.getM3_lname(), model.getM3_fname(), model.getM3_email(),
model.getM3_lincence(), model.getM3_role())
))
.build();
}
@Data
@AllArgsConstructor
@RegisterForReflection
public static class AffiliationMember {
String lname;
String fname;
String email;
int licence;
RoleAsso role;
}
}

View File

@@ -75,21 +75,21 @@ public class AffiliationRequestForm {
model.setM1_fname(this.getM1_fname());
model.setM1_email(this.getM1_email());
model.setM1_lincence((this.getM1_lincence() == null || this.getM1_lincence().isBlank())
? 0 : Integer.parseInt(this.getM1_lincence()));
? -1 : Integer.parseInt(this.getM1_lincence()));
model.setM1_role(this.getM1_role());
model.setM2_lname(this.getM2_lname());
model.setM2_fname(this.getM2_fname());
model.setM2_email(this.getM2_email());
model.setM2_lincence((this.getM1_lincence() == null || this.getM1_lincence().isBlank())
? 0 : Integer.parseInt(this.getM2_lincence()));
? -1 : Integer.parseInt(this.getM2_lincence()));
model.setM2_role(this.getM2_role());
model.setM3_lname(this.getM3_lname());
model.setM3_fname(this.getM3_fname());
model.setM3_email(this.getM3_email());
model.setM3_lincence((this.getM1_lincence() == null || this.getM1_lincence().isBlank())
? 0 : Integer.parseInt(this.getM3_lincence()));
? -1 : Integer.parseInt(this.getM3_lincence()));
model.setM3_role(this.getM3_role());
return model;