wip: affiliation
This commit is contained in:
@@ -4,7 +4,9 @@ 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.rest.from.AffiliationRequestSaveForm;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
import fr.titionfire.ffsaf.utils.Utils;
|
||||
import io.quarkus.oidc.IdToken;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
@@ -13,8 +15,11 @@ import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -31,6 +36,9 @@ public class AffiliationEndpoints {
|
||||
@Inject
|
||||
SecurityIdentity securityIdentity;
|
||||
|
||||
@ConfigProperty(name = "upload_dir")
|
||||
String media;
|
||||
|
||||
Consumer<Long> checkPerm = Unchecked.consumer(id -> {
|
||||
if (!securityIdentity.getRoles().contains("federation_admin") && !GroupeUtils.isInClubGroup(id, idToken))
|
||||
throw new ForbiddenException();
|
||||
@@ -44,6 +52,24 @@ public class AffiliationEndpoints {
|
||||
return service.getRequest(id);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/request/save")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
public Uni<?> saveAdminAffRequest(AffiliationRequestSaveForm form) {
|
||||
return service.saveAdmin(form);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/request/apply")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
public Uni<?> acceptAffRequest(AffiliationRequestSaveForm form) {
|
||||
return service.accept(form);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/request")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
@@ -52,6 +78,7 @@ public class AffiliationEndpoints {
|
||||
return service.save(form);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/current")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@@ -83,4 +110,19 @@ public class AffiliationEndpoints {
|
||||
public Uni<?> deleteLicence(@PathParam("id") long id) {
|
||||
return service.deleteAffiliation(id);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/request/{id}/logo")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
public Uni<Response> getLogo(@PathParam("id") long id) throws URISyntaxException {
|
||||
return Utils.getMediaFile(id, media, "aff_request/logo", Uni.createFrom().nullItem());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/request/{id}/status")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
public Uni<Response> getStatus(@PathParam("id") long id) throws URISyntaxException {
|
||||
return Utils.getMediaFile(id, media, "aff_request/status", "affiliation_request_" + id + ".pdf",
|
||||
Uni.createFrom().nullItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package fr.titionfire.ffsaf.rest.from;
|
||||
|
||||
import fr.titionfire.ffsaf.utils.RoleAsso;
|
||||
import jakarta.ws.rs.FormParam;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.jboss.resteasy.reactive.PartType;
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
public class AffiliationRequestSaveForm {
|
||||
@FormParam("id")
|
||||
private Long id = null;
|
||||
@FormParam("name")
|
||||
private String name = null;
|
||||
@FormParam("siret")
|
||||
private Long siret = null;
|
||||
@FormParam("rna")
|
||||
private String rna = null;
|
||||
@FormParam("address")
|
||||
private String address = null;
|
||||
|
||||
@FormParam("status")
|
||||
@PartType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
private byte[] status = new byte[0];
|
||||
@FormParam("logo")
|
||||
@PartType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
private byte[] logo = new byte[0];
|
||||
|
||||
@FormParam("m1_mode")
|
||||
private Integer m1_mode = null;
|
||||
@FormParam("m1_role")
|
||||
private RoleAsso m1_role = null;
|
||||
@FormParam("m1_licence")
|
||||
private String m1_lincence = null;
|
||||
@FormParam("m1_lname")
|
||||
private String m1_lname = null;
|
||||
@FormParam("m1_fname")
|
||||
private String m1_fname = null;
|
||||
@FormParam("m1_email")
|
||||
private String m1_email = null;
|
||||
@FormParam("m1_email_mode")
|
||||
private Integer m1_email_mode = null;
|
||||
|
||||
@FormParam("m2_mode")
|
||||
private Integer m2_mode = null;
|
||||
@FormParam("m2_role")
|
||||
private RoleAsso m2_role = null;
|
||||
@FormParam("m2_licence")
|
||||
private String m2_lincence = null;
|
||||
@FormParam("m2_lname")
|
||||
private String m2_lname = null;
|
||||
@FormParam("m2_fname")
|
||||
private String m2_fname = null;
|
||||
@FormParam("m2_email")
|
||||
private String m2_email = null;
|
||||
@FormParam("m2_email_mode")
|
||||
private Integer m2_email_mode = null;
|
||||
|
||||
@FormParam("m3_mode")
|
||||
private Integer m3_mode = null;
|
||||
@FormParam("m3_role")
|
||||
private RoleAsso m3_role = null;
|
||||
@FormParam("m3_licence")
|
||||
private String m3_lincence = null;
|
||||
@FormParam("m3_lname")
|
||||
private String m3_lname = null;
|
||||
@FormParam("m3_fname")
|
||||
private String m3_fname = null;
|
||||
@FormParam("m3_email")
|
||||
private String m3_email = null;
|
||||
@FormParam("m3_email_mode")
|
||||
private Integer m3_email_mode = null;
|
||||
|
||||
|
||||
@Getter
|
||||
public class Member {
|
||||
private Integer mode;
|
||||
private RoleAsso role;
|
||||
private String licence;
|
||||
private String lname;
|
||||
private String fname;
|
||||
private String email;
|
||||
private Integer email_mode;
|
||||
|
||||
public Member(int n){
|
||||
if (n == 1) {
|
||||
mode = m1_mode;
|
||||
role = m1_role;
|
||||
licence = m1_lincence;
|
||||
lname = m1_lname;
|
||||
fname = m1_fname;
|
||||
email = m1_email;
|
||||
email_mode = m1_email_mode;
|
||||
} else if (n == 2) {
|
||||
mode = m2_mode;
|
||||
role = m2_role;
|
||||
licence = m2_lincence;
|
||||
lname = m2_lname;
|
||||
fname = m2_fname;
|
||||
email = m2_email;
|
||||
email_mode = m2_email_mode;
|
||||
} else if (n == 3) {
|
||||
mode = m3_mode;
|
||||
role = m3_role;
|
||||
licence = m3_lincence;
|
||||
lname = m3_lname;
|
||||
fname = m3_fname;
|
||||
email = m3_email;
|
||||
email_mode = m3_email_mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user