Merge pull request 'feat: add aff req log detail' (#55) from dev into master
Reviewed-on: #55
This commit is contained in:
commit
d3a62e980d
@ -20,6 +20,7 @@ import java.util.List;
|
|||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@ToString
|
||||||
@Table(name = "membre")
|
@Table(name = "membre")
|
||||||
public class MembreModel implements LoggableModel {
|
public class MembreModel implements LoggableModel {
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import jakarta.enterprise.context.ApplicationScoped;
|
|||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||||
import org.hibernate.reactive.mutiny.Mutiny;
|
import org.hibernate.reactive.mutiny.Mutiny;
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,6 +31,7 @@ import java.util.stream.Stream;
|
|||||||
@WithSession
|
@WithSession
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class AffiliationService {
|
public class AffiliationService {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(AffiliationService.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CombRepository combRepository;
|
CombRepository combRepository;
|
||||||
@ -146,6 +148,9 @@ public class AffiliationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Uni<String> save(AffiliationRequestForm form) {
|
public Uni<String> save(AffiliationRequestForm form) {
|
||||||
|
LOGGER.debug("Affiliation Request Created");
|
||||||
|
LOGGER.debug(form.toString());
|
||||||
|
|
||||||
// noinspection ResultOfMethodCallIgnored,ReactiveStreamsUnusedPublisher
|
// noinspection ResultOfMethodCallIgnored,ReactiveStreamsUnusedPublisher
|
||||||
return pre_save(form, true)
|
return pre_save(form, true)
|
||||||
.chain(model -> Panache.withTransaction(() -> repositoryRequest.persist(model)))
|
.chain(model -> Panache.withTransaction(() -> repositoryRequest.persist(model)))
|
||||||
@ -169,6 +174,9 @@ public class AffiliationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Uni<?> saveAdmin(AffiliationRequestSaveForm form) {
|
public Uni<?> saveAdmin(AffiliationRequestSaveForm form) {
|
||||||
|
LOGGER.debug("Affiliation Request Saved");
|
||||||
|
LOGGER.debug(form.toString());
|
||||||
|
|
||||||
return repositoryRequest.findById(form.getId())
|
return repositoryRequest.findById(form.getId())
|
||||||
.onItem().ifNull().failWith(new DNotFoundException("Demande d'affiliation non trouvé"))
|
.onItem().ifNull().failWith(new DNotFoundException("Demande d'affiliation non trouvé"))
|
||||||
.map(model -> {
|
.map(model -> {
|
||||||
@ -273,6 +281,9 @@ public class AffiliationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Uni<?> accept(AffiliationRequestSaveForm form) {
|
public Uni<?> accept(AffiliationRequestSaveForm form) {
|
||||||
|
LOGGER.debug("Affiliation Request Accepted");
|
||||||
|
LOGGER.debug(form.toString());
|
||||||
|
|
||||||
return repositoryRequest.findById(form.getId())
|
return repositoryRequest.findById(form.getId())
|
||||||
.onItem().ifNull().failWith(new DNotFoundException("Demande d'affiliation non trouvé"))
|
.onItem().ifNull().failWith(new DNotFoundException("Demande d'affiliation non trouvé"))
|
||||||
.chain(req ->
|
.chain(req ->
|
||||||
@ -298,6 +309,7 @@ public class AffiliationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Uni<ClubModel> acceptNew(AffiliationRequestSaveForm form, AffiliationRequestModel model) {
|
private Uni<ClubModel> acceptNew(AffiliationRequestSaveForm form, AffiliationRequestModel model) {
|
||||||
|
LOGGER.debug("New Club Accepted");
|
||||||
return Uni.createFrom().nullItem()
|
return Uni.createFrom().nullItem()
|
||||||
.chain(() -> {
|
.chain(() -> {
|
||||||
ClubModel club = new ClubModel();
|
ClubModel club = new ClubModel();
|
||||||
@ -336,6 +348,7 @@ public class AffiliationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Uni<ClubModel> acceptOld(AffiliationRequestSaveForm form, AffiliationRequestModel model, ClubModel club) {
|
private Uni<ClubModel> acceptOld(AffiliationRequestSaveForm form, AffiliationRequestModel model, ClubModel club) {
|
||||||
|
LOGGER.debug("Old Club Accepted");
|
||||||
return Uni.createFrom().nullItem()
|
return Uni.createFrom().nullItem()
|
||||||
.chain(() -> {
|
.chain(() -> {
|
||||||
club.setName(form.getName());
|
club.setName(form.getName());
|
||||||
|
|||||||
@ -197,6 +197,11 @@ public class MembreService {
|
|||||||
return Uni.createFrom().nullItem();
|
return Uni.createFrom().nullItem();
|
||||||
AtomicReference<ClubModel> clubModel = new AtomicReference<>();
|
AtomicReference<ClubModel> clubModel = new AtomicReference<>();
|
||||||
|
|
||||||
|
LOGGER.debugf("Membre import (size=%d)", data2.size());
|
||||||
|
for (SimpleMembreInOutData simpleMembreInOutData : data2) {
|
||||||
|
LOGGER.debugf("-> %s", simpleMembreInOutData.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return repository.find("userId = ?1", subject).firstResult()
|
return repository.find("userId = ?1", subject).firstResult()
|
||||||
.chain(membreModel -> {
|
.chain(membreModel -> {
|
||||||
clubModel.set(membreModel.getClub());
|
clubModel.set(membreModel.getClub());
|
||||||
@ -205,13 +210,15 @@ public class MembreService {
|
|||||||
return repository.list("licence IN ?1 OR LOWER(lname || ' ' || fname) IN ?2 OR email IN ?3",
|
return repository.list("licence IN ?1 OR LOWER(lname || ' ' || fname) IN ?2 OR email IN ?3",
|
||||||
data2.stream().map(SimpleMembreInOutData::getLicence).filter(Objects::nonNull).toList(),
|
data2.stream().map(SimpleMembreInOutData::getLicence).filter(Objects::nonNull).toList(),
|
||||||
data2.stream().map(o -> (o.getNom() + " " + o.getPrenom()).toLowerCase()).toList(),
|
data2.stream().map(o -> (o.getNom() + " " + o.getPrenom()).toLowerCase()).toList(),
|
||||||
data2.stream().map(SimpleMembreInOutData::getEmail).filter(Objects::nonNull).toList());
|
data2.stream().map(SimpleMembreInOutData::getEmail).filter(o -> o != null && !o.isBlank()).toList());
|
||||||
})
|
})
|
||||||
.call(Unchecked.function(membres -> {
|
.call(Unchecked.function(membres -> {
|
||||||
for (MembreModel membreModel : membres) {
|
for (MembreModel membreModel : membres) {
|
||||||
if (!Objects.equals(membreModel.getClub(), clubModel.get()))
|
if (!Objects.equals(membreModel.getClub(), clubModel.get())){
|
||||||
|
LOGGER.info("Similar membres found: " + membreModel);
|
||||||
throw new DForbiddenException(
|
throw new DForbiddenException(
|
||||||
"Le membre n°" + membreModel.getLicence() + " n'appartient pas à votre club");
|
"Le membre n°" + membreModel.getLicence() + " n'appartient pas à votre club");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Uni<Void> uniResult = Uni.createFrom().voidItem();
|
Uni<Void> uniResult = Uni.createFrom().voidItem();
|
||||||
for (SimpleMembreInOutData dataIn : data2) {
|
for (SimpleMembreInOutData dataIn : data2) {
|
||||||
@ -229,12 +236,14 @@ public class MembreService {
|
|||||||
|
|
||||||
if (model.getEmail() != null) {
|
if (model.getEmail() != null) {
|
||||||
if (model.getLicence() != null && !model.getLicence().equals(dataIn.getLicence())) {
|
if (model.getLicence() != null && !model.getLicence().equals(dataIn.getLicence())) {
|
||||||
|
LOGGER.info("Similar membres found: " + model);
|
||||||
throw new DBadRequestException("Email déja utiliser");
|
throw new DBadRequestException("Email déja utiliser");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringSimilarity.similarity(model.getLname().toUpperCase(),
|
if (StringSimilarity.similarity(model.getLname().toUpperCase(),
|
||||||
dataIn.getNom().toUpperCase()) > 3 || StringSimilarity.similarity(
|
dataIn.getNom().toUpperCase()) > 3 || StringSimilarity.similarity(
|
||||||
model.getFname().toUpperCase(), dataIn.getPrenom().toUpperCase()) > 3) {
|
model.getFname().toUpperCase(), dataIn.getPrenom().toUpperCase()) > 3) {
|
||||||
|
LOGGER.info("Similar membres found: " + model);
|
||||||
throw new DBadRequestException("Email déja utiliser");
|
throw new DBadRequestException("Email déja utiliser");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,6 +253,7 @@ public class MembreService {
|
|||||||
if ((!add && StringSimilarity.similarity(model.getLname().toUpperCase(),
|
if ((!add && StringSimilarity.similarity(model.getLname().toUpperCase(),
|
||||||
dataIn.getNom().toUpperCase()) > 3) || (!add && StringSimilarity.similarity(
|
dataIn.getNom().toUpperCase()) > 3) || (!add && StringSimilarity.similarity(
|
||||||
model.getFname().toUpperCase(), dataIn.getPrenom().toUpperCase()) > 3)) {
|
model.getFname().toUpperCase(), dataIn.getPrenom().toUpperCase()) > 3)) {
|
||||||
|
LOGGER.info("Similar membres found: " + model);
|
||||||
throw new DBadRequestException(
|
throw new DBadRequestException(
|
||||||
"Pour enregistrer un nouveau membre, veuillez laisser le champ licence vide.");
|
"Pour enregistrer un nouveau membre, veuillez laisser le champ licence vide.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,10 @@ import fr.titionfire.ffsaf.utils.RoleAsso;
|
|||||||
import jakarta.ws.rs.FormParam;
|
import jakarta.ws.rs.FormParam;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
|
||||||
import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
||||||
import org.jboss.resteasy.reactive.PartType;
|
import org.jboss.resteasy.reactive.PartType;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
|
||||||
public class AffiliationRequestSaveForm {
|
public class AffiliationRequestSaveForm {
|
||||||
@Schema(description = "L'identifiant de l'affiliation.", example = "1", required = true)
|
@Schema(description = "L'identifiant de l'affiliation.", example = "1", required = true)
|
||||||
@FormParam("id")
|
@FormParam("id")
|
||||||
@ -171,4 +169,39 @@ public class AffiliationRequestSaveForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "AffiliationRequestSaveForm{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", siret=" + siret +
|
||||||
|
", rna='" + rna + '\'' +
|
||||||
|
", address='" + address + '\'' +
|
||||||
|
", contact='" + contact + '\'' +
|
||||||
|
", status_len=" + status.length +
|
||||||
|
", logo_len=" + logo.length +
|
||||||
|
", m1_mode=" + m1_mode +
|
||||||
|
", m1_role=" + m1_role +
|
||||||
|
", m1_lincence='" + m1_lincence + '\'' +
|
||||||
|
", m1_lname='" + m1_lname + '\'' +
|
||||||
|
", m1_fname='" + m1_fname + '\'' +
|
||||||
|
", m1_email='" + m1_email + '\'' +
|
||||||
|
", m1_email_mode=" + m1_email_mode +
|
||||||
|
", m2_mode=" + m2_mode +
|
||||||
|
", m2_role=" + m2_role +
|
||||||
|
", m2_lincence='" + m2_lincence + '\'' +
|
||||||
|
", m2_lname='" + m2_lname + '\'' +
|
||||||
|
", m2_fname='" + m2_fname + '\'' +
|
||||||
|
", m2_email='" + m2_email + '\'' +
|
||||||
|
", m2_email_mode=" + m2_email_mode +
|
||||||
|
", m3_mode=" + m3_mode +
|
||||||
|
", m3_role=" + m3_role +
|
||||||
|
", m3_lincence='" + m3_lincence + '\'' +
|
||||||
|
", m3_lname='" + m3_lname + '\'' +
|
||||||
|
", m3_fname='" + m3_fname + '\'' +
|
||||||
|
", m3_email='" + m3_email + '\'' +
|
||||||
|
", m3_email_mode=" + m3_email_mode +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user