commit
6b86a4f30d
6
pom.xml
6
pom.xml
@ -139,6 +139,12 @@
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-mailer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.jmimemagic</groupId>
|
||||
<artifactId>jmimemagic</artifactId>
|
||||
<version>0.1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@ -48,7 +48,7 @@ public class MembreModel {
|
||||
Genre genre;
|
||||
|
||||
@Schema(description = "Le numéro de licence du membre.", example = "12345")
|
||||
int licence;
|
||||
Integer licence;
|
||||
|
||||
@Schema(description = "Le pays du membre.", example = "FR")
|
||||
String country;
|
||||
|
||||
@ -21,6 +21,7 @@ import jakarta.inject.Inject;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.hibernate.reactive.mutiny.Mutiny;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -211,6 +212,7 @@ public class AffiliationService {
|
||||
membreModel.setClub(club);
|
||||
membreModel.setRole(member.getRole());
|
||||
membreModel.setEmail(member.getEmail());
|
||||
membreModel.setCountry("FR");
|
||||
return Panache.withTransaction(() ->
|
||||
combRepository.persist(membreModel)
|
||||
.chain(m -> sequenceRepository.getNextValueInTransaction(SequenceType.Licence)
|
||||
@ -235,10 +237,13 @@ public class AffiliationService {
|
||||
}).call(m -> Panache.withTransaction(() -> combRepository.persist(m)));
|
||||
}
|
||||
})
|
||||
.call(m -> (m.getUserId() == null) ? keycloakService.initCompte(m.getId()) :
|
||||
keycloakService.setClubGroupMembre(m, club))
|
||||
.call(m -> Panache.withTransaction(() -> licenceRepository.persist(
|
||||
new LicenceModel(null, m, saison, null, true))));
|
||||
.call(m -> ((m.getUserId() == null) ? keycloakService.initCompte(m.getId()) :
|
||||
keycloakService.setClubGroupMembre(m, club).map(__ -> m.getUserId()))
|
||||
.call(userId -> keycloakService.setAutoRoleMembre(userId, m.getRole(), m.getGrade_arbitrage())))
|
||||
.call(m -> m.getLicences().stream().anyMatch(l -> l.getSaison() == saison) ?
|
||||
Uni.createFrom().nullItem() :
|
||||
Panache.withTransaction(() -> licenceRepository.persist(
|
||||
new LicenceModel(null, m, saison, null, true))));
|
||||
}
|
||||
|
||||
public Uni<?> accept(AffiliationRequestSaveForm form) {
|
||||
@ -271,11 +276,11 @@ public class AffiliationService {
|
||||
.chain(() -> {
|
||||
ClubModel club = new ClubModel();
|
||||
club.setName(form.getName());
|
||||
club.setCountry("fr");
|
||||
club.setCountry("FR");
|
||||
club.setSIRET(form.getSiret());
|
||||
club.setRNA(form.getRna());
|
||||
club.setAddress(form.getAddress());
|
||||
club.setAffiliations(List.of(new AffiliationModel(null, club, model.getSaison())));
|
||||
club.setAffiliations(new ArrayList<>());
|
||||
return Panache.withTransaction(() -> clubRepository.persist(club)
|
||||
.chain(c -> sequenceRepository.getNextValueInTransaction(SequenceType.Affiliation)
|
||||
.invoke(c::setNo_affiliation)
|
||||
@ -306,7 +311,7 @@ public class AffiliationService {
|
||||
return Uni.createFrom().nullItem()
|
||||
.chain(() -> {
|
||||
club.setName(form.getName());
|
||||
club.setCountry("fr");
|
||||
club.setCountry("FR");
|
||||
club.setSIRET(form.getSiret());
|
||||
club.setRNA(form.getRna());
|
||||
club.setAddress(form.getAddress());
|
||||
|
||||
@ -207,9 +207,8 @@ public class KeycloakService {
|
||||
throw new KeycloakException("User name is null");
|
||||
})).chain(membreModel -> creatUser(membreModel).chain(user -> {
|
||||
LOGGER.infof("Set user id %s to membre %s", user.getId(), membreModel.getId());
|
||||
return membreService.setUserId(membreModel.getId(), user.getId());
|
||||
}))
|
||||
.map(__ -> "OK");
|
||||
return membreService.setUserId(membreModel.getId(), user.getId()).map(__ -> user.getId());
|
||||
}));
|
||||
}
|
||||
|
||||
private Uni<UserRepresentation> creatUser(MembreModel membreModel) {
|
||||
|
||||
@ -270,6 +270,7 @@ public class MembreService {
|
||||
model.setFname(input.getFname());
|
||||
model.setLname(input.getLname());
|
||||
model.setEmail(input.getEmail());
|
||||
model.setLicence(null);
|
||||
model.setGenre(input.getGenre());
|
||||
model.setCountry(input.getCountry());
|
||||
model.setBirth_date(input.getBirth_date());
|
||||
|
||||
@ -23,6 +23,7 @@ import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
|
||||
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Tag(name = "Membre", description = "Gestion des membres")
|
||||
@ -119,7 +120,9 @@ public class MembreEndpoints {
|
||||
@APIResponse(responseCode = "500", description = "Erreur interne du serveur")
|
||||
})
|
||||
public Uni<Response> getPhoto(@PathParam("id") long id) throws URISyntaxException {
|
||||
return Utils.getMediaFile(id, media, "ppMembre", membreService.getById(id).onItem().invoke(checkPerm));
|
||||
return Utils.getMediaFile(id, media, "ppMembre", membreService.getById(id).onItem()
|
||||
.call(m -> Objects.equals(m.getUserId(), securityCtx.getSubject()) ?
|
||||
Uni.createFrom().nullItem() : Uni.createFrom().item(m).invoke(checkPerm)));
|
||||
}
|
||||
|
||||
@GET
|
||||
|
||||
@ -5,6 +5,10 @@ import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jodd.net.MimeTypes;
|
||||
import net.sf.jmimemagic.Magic;
|
||||
import net.sf.jmimemagic.MagicException;
|
||||
import net.sf.jmimemagic.MagicMatchNotFoundException;
|
||||
import net.sf.jmimemagic.MagicParseException;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.io.*;
|
||||
@ -76,7 +80,12 @@ public class Utils {
|
||||
return "OK";
|
||||
|
||||
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
|
||||
String mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
String mimeType;
|
||||
try {
|
||||
mimeType = Magic.getMagicMatch(input, false).getMimeType();
|
||||
} catch (MagicParseException | MagicMatchNotFoundException | MagicException e) {
|
||||
mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
}
|
||||
String[] detectedExtensions = MimeTypes.findExtensionsByMimeTypes(mimeType, false);
|
||||
if (detectedExtensions.length == 0)
|
||||
throw new IOException("Fail to detect file extension for MIME type " + mimeType);
|
||||
|
||||
@ -77,7 +77,7 @@ export function MemberPage() {
|
||||
|
||||
function PhotoCard({data}) {
|
||||
return <div className="card mb-4">
|
||||
<div className="card-header">Licence n°{data.licence}</div>
|
||||
<div className="card-header">{data.licence ? "Licence n°"+data.licence : "Pas de licence"}</div>
|
||||
<div className="card-body text-center">
|
||||
<div className="input-group mb-3">
|
||||
<img
|
||||
|
||||
@ -75,7 +75,7 @@ export function MemberPage() {
|
||||
|
||||
function PhotoCard({data}) {
|
||||
return <div className="card mb-4">
|
||||
<div className="card-header">Licence n°{data.licence}</div>
|
||||
<div className="card-header">{data.licence ? "Licence n°"+data.licence : "Pas de licence"}</div>
|
||||
<div className="card-body text-center">
|
||||
<div className="input-group mb-3">
|
||||
<img
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user