fix: affiliation request page minor bug
This commit is contained in:
@@ -11,6 +11,7 @@ import fr.titionfire.ffsaf.utils.Utils;
|
||||
import io.quarkus.hibernate.reactive.panache.Panache;
|
||||
import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import io.smallrye.mutiny.unchecked.Unchecked;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
@@ -57,7 +58,13 @@ public class AffiliationService {
|
||||
affModel.setSaison(Utils.getSaison());
|
||||
|
||||
// noinspection ResultOfMethodCallIgnored
|
||||
return Uni.createFrom().item(affModel)
|
||||
return repositoryRequest.count("siret = ?1 and saison = ?2", affModel.getSiret(), affModel.getSaison())
|
||||
.onItem().invoke(Unchecked.consumer(count -> {
|
||||
if (count != 0) {
|
||||
throw new IllegalArgumentException("Affiliation request already exists");
|
||||
}
|
||||
}))
|
||||
.map(o -> affModel)
|
||||
.call(model -> ((model.getM1_lincence() != -1) ? combRepository.find("licence",
|
||||
model.getM1_lincence()).count().invoke(count -> {
|
||||
if (count == 0) {
|
||||
@@ -293,6 +300,8 @@ public class AffiliationService {
|
||||
}
|
||||
|
||||
public Uni<?> deleteReqAffiliation(long id) {
|
||||
return Panache.withTransaction(() -> repositoryRequest.deleteById(id));
|
||||
return Panache.withTransaction(() -> repositoryRequest.deleteById(id))
|
||||
.call(__ -> Utils.deleteMedia(id, media, "aff_request/logo"))
|
||||
.call(__ -> Utils.deleteMedia(id, media, "aff_request/status"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user