feat: upgrade aff find to user all id (Rna, siret, siren)
This commit is contained in:
parent
cf5d93630f
commit
9ab50238b9
@ -2,6 +2,7 @@ package fr.titionfire.ffsaf.domain.service;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.*;
|
||||
import fr.titionfire.ffsaf.data.repository.*;
|
||||
import fr.titionfire.ffsaf.rest.client.StateIdService;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleAffiliation;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleReqAffiliation;
|
||||
import fr.titionfire.ffsaf.rest.exception.DBadRequestException;
|
||||
@ -21,6 +22,7 @@ import io.smallrye.mutiny.unchecked.Unchecked;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||
import org.hibernate.reactive.mutiny.Mutiny;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
@ -60,6 +62,9 @@ public class AffiliationService {
|
||||
@Inject
|
||||
LoggerService ls;
|
||||
|
||||
@RestClient
|
||||
StateIdService stateIdService;
|
||||
|
||||
@ConfigProperty(name = "upload_dir")
|
||||
String media;
|
||||
|
||||
@ -73,6 +78,8 @@ public class AffiliationService {
|
||||
public Uni<AffiliationRequestModel> pre_save(AffiliationRequestForm form, boolean unique) {
|
||||
AffiliationRequestModel affModel = form.toModel();
|
||||
int currentSaison = Utils.getSaison();
|
||||
List<String> out = new ArrayList<>();
|
||||
out.add(affModel.getState_id());
|
||||
|
||||
return Uni.createFrom().item(affModel)
|
||||
.invoke(Unchecked.consumer(model -> {
|
||||
@ -80,14 +87,24 @@ public class AffiliationService {
|
||||
throw new DBadRequestException("Saison non valid");
|
||||
}
|
||||
}))
|
||||
.chain(() -> repositoryRequest.count("state_id = ?1 and saison = ?2", affModel.getState_id(),
|
||||
affModel.getSaison()))
|
||||
.chain(() -> stateIdService.get_status(affModel.getState_id()).onItem().transform(o -> {
|
||||
if (o.getId_rna() != null && !o.getId_rna().isBlank())
|
||||
out.add(o.getId_rna());
|
||||
if (o.getId_siren() != null && !o.getId_siren().isBlank())
|
||||
out.add(o.getId_siren());
|
||||
if (o.getIdentite().getId_siret_siege() != null && !o.getIdentite().getId_siret_siege().isBlank())
|
||||
out.add(o.getIdentite().getId_siret_siege());
|
||||
return out;
|
||||
}).onFailure().recoverWithItem(out)
|
||||
.chain(a -> repositoryRequest.count("state_id IN ?1 and saison = ?2",
|
||||
out, affModel.getSaison()))
|
||||
.onItem().invoke(Unchecked.consumer(count -> {
|
||||
if (count != 0 && unique) {
|
||||
throw new DBadRequestException("Demande d'affiliation déjà existante");
|
||||
}
|
||||
}))
|
||||
.chain(() -> clubRepository.find("StateId = ?1", affModel.getState_id()).firstResult().chain(club ->
|
||||
)
|
||||
.chain(() -> clubRepository.find("StateId IN ?1", out).firstResult().chain(club ->
|
||||
repository.count("club = ?1 and saison = ?2", club, affModel.getSaison())))
|
||||
.onItem().invoke(Unchecked.consumer(count -> {
|
||||
if (count != 0) {
|
||||
|
||||
@ -15,6 +15,7 @@ public class AssoData {
|
||||
@RegisterForReflection
|
||||
public static class Identite {
|
||||
String nom;
|
||||
String id_siret_siege;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@ -257,7 +257,7 @@ function AssoInfo({initData, needFile}) {
|
||||
|
||||
<div className="input-group mb-3">
|
||||
<span className="input-group-text">N° SIRET ou RNA*</span>
|
||||
<input type="text" className="form-control" placeholder="state_id" name="state_id" required value={stateId} disabled={!needFile}
|
||||
<input type="text" className="form-control" placeholder="N° SIRET ou RNA*" name="state_id" required value={stateId} disabled={!needFile}
|
||||
onChange={e => setStateId(e.target.value)}/>
|
||||
<button className="btn btn-outline-secondary" type="button" id="button-addon2"
|
||||
onClick={fetchStateId}>Rechercher
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user