wip: Affiliation request
This commit is contained in:
@@ -49,7 +49,7 @@ public class ClubModel {
|
||||
|
||||
Long SIRET;
|
||||
|
||||
String no_affiliation;
|
||||
Long no_affiliation;
|
||||
|
||||
boolean international;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ClubEntity {
|
||||
private String contact_intern;
|
||||
private String RNA;
|
||||
private Long SIRET;
|
||||
private String no_affiliation;
|
||||
private Long no_affiliation;
|
||||
private boolean international;
|
||||
|
||||
public static ClubEntity fromModel (ClubModel model) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import fr.titionfire.ffsaf.data.repository.AffiliationRequestRepository;
|
||||
import fr.titionfire.ffsaf.data.repository.ClubRepository;
|
||||
import fr.titionfire.ffsaf.data.repository.CombRepository;
|
||||
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.Utils;
|
||||
import io.quarkus.hibernate.reactive.panache.Panache;
|
||||
@@ -75,12 +76,24 @@ public class AffiliationService {
|
||||
.map(__ -> "Ok");
|
||||
}
|
||||
|
||||
public Uni<SimpleReqAffiliation> getRequest(long id) {
|
||||
return repositoryRequest.findById(id).map(SimpleReqAffiliation::fromModel)
|
||||
.call(out -> clubRepository.find("SIRET = ?1", out.getSiret()).firstResult().invoke(c -> {
|
||||
if (c != null){
|
||||
out.setClub(c.getId());
|
||||
out.setClub_name(c.getName());
|
||||
out.setClub_no_aff(c.getNo_affiliation());
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public Uni<List<SimpleAffiliation>> getCurrentSaisonAffiliation() {
|
||||
return repository.list("saison = ?1", Utils.getSaison())
|
||||
.map(models -> models.stream().map(SimpleAffiliation::fromModel).toList())
|
||||
.chain(aff -> repositoryRequest.list("saison = ?1", Utils.getSaison())
|
||||
.chain(models -> Uni.join().all(models.stream().map(model ->
|
||||
clubRepository.find("siret = ?1", model.getSiret()).firstResult()
|
||||
clubRepository.find("SIRET = ?1", model.getSiret()).firstResult()
|
||||
.map(c -> new SimpleAffiliation(model.getId() * -1, c.getId(),
|
||||
model.getSaison(), false)))
|
||||
.toList()).andFailFast()
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SimpleClubModel {
|
||||
String name;
|
||||
String country;
|
||||
String shieldURL;
|
||||
String no_affiliation;
|
||||
Long no_affiliation;
|
||||
|
||||
public static SimpleClubModel fromModel(ClubModel model) {
|
||||
if (model == null)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"})
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user