feat: AffiliationCard
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package fr.titionfire.ffsaf.rest;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import fr.titionfire.ffsaf.domain.service.AffiliationService;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleAffiliation;
|
||||
import fr.titionfire.ffsaf.rest.from.AffiliationForm;
|
||||
import fr.titionfire.ffsaf.rest.from.AffiliationRequestForm;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
import io.quarkus.oidc.IdToken;
|
||||
@@ -32,8 +30,8 @@ public class AffiliationEndpoints {
|
||||
@Inject
|
||||
SecurityIdentity securityIdentity;
|
||||
|
||||
Consumer<ClubModel> checkPerm = Unchecked.consumer(clubModel -> {
|
||||
if (!securityIdentity.getRoles().contains("federation_admin") && !GroupeUtils.isInClubGroup(clubModel.getId(), idToken))
|
||||
Consumer<Long> checkPerm = Unchecked.consumer(id -> {
|
||||
if (!securityIdentity.getRoles().contains("federation_admin") && !GroupeUtils.isInClubGroup(id, idToken))
|
||||
throw new ForbiddenException();
|
||||
});
|
||||
|
||||
@@ -57,16 +55,15 @@ public class AffiliationEndpoints {
|
||||
@RolesAllowed({"federation_admin", "club_president", "club_secretaire", "club_respo_intra"})
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<List<SimpleAffiliation>> getLicence(@PathParam("id") long id) {
|
||||
return service.getAffiliation(id, checkPerm);
|
||||
return Uni.createFrom().item(id).invoke(checkPerm).chain(__ -> service.getAffiliation(id));
|
||||
}
|
||||
|
||||
@POST
|
||||
@PUT
|
||||
@Path("{id}")
|
||||
@RolesAllowed("federation_admin")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
public Uni<SimpleAffiliation> setLicence(@PathParam("id") long id, AffiliationForm form) {
|
||||
return service.setAffiliation(id, form);
|
||||
public Uni<SimpleAffiliation> setLicence(@PathParam("id") long id, @QueryParam("saison") int saison) {
|
||||
return service.setAffiliation(id, saison);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
|
||||
@@ -16,7 +16,7 @@ public class SimpleAffiliation {
|
||||
int saison;
|
||||
boolean validate;
|
||||
|
||||
public static SimpleAffiliation fromModel(AffiliationModel model, boolean validate) {
|
||||
public static SimpleAffiliation fromModel(AffiliationModel model) {
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SimpleAffiliation {
|
||||
.id(model.getId())
|
||||
.club(model.getClub().getId())
|
||||
.saison(model.getSaison())
|
||||
.validate(validate)
|
||||
.validate(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public class AffiliationRequestForm {
|
||||
@FormParam("name")
|
||||
private String name = null;
|
||||
|
||||
@FormParam("siren")
|
||||
private Long siren = null;
|
||||
@FormParam("siret")
|
||||
private Long siret = null;
|
||||
|
||||
@FormParam("rna")
|
||||
private String rna = null;
|
||||
@@ -67,7 +67,7 @@ public class AffiliationRequestForm {
|
||||
public AffiliationRequestModel toModel() {
|
||||
AffiliationRequestModel model = new AffiliationRequestModel();
|
||||
model.setName(this.getName());
|
||||
model.setSiren(this.getSiren());
|
||||
model.setSiret(this.getSiret());
|
||||
model.setRNA(this.getRna());
|
||||
model.setAddress(this.getAdresse());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user