fix(comp): delete poule

This commit is contained in:
Thibaut Valentin 2025-03-11 11:35:08 +01:00
parent fbbfef37ba
commit c7b5f3ef61

View File

@ -262,7 +262,6 @@ public class PouleService {
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
.onItem().ifNull().failWith(() -> new RuntimeException("Poule not found"))
.call(o -> permService.hasEditPerm(securityCtx, o.getCompet()))
.call(o -> Mutiny.fetch(o.getMatchs()))
.call(o -> Mutiny.fetch(o.getTree())
.call(o2 -> o2.isEmpty() ? Uni.createFrom().nullItem() :
Uni.createFrom().item(o2.stream().peek(m -> {
@ -275,10 +274,7 @@ public class PouleService {
Panache.withTransaction(() -> treeRepository.delete("id IN ?1", in)))
)
)
.call(o -> o.getMatchs().isEmpty() ? Uni.createFrom().nullItem() :
Panache.withTransaction(() -> Uni.join().all(
o.getMatchs().stream().map(l -> matchRepository.deleteById(l.getId())).toList())
.andCollectFailures()))
.call(o -> matchRepository.delete("poule.id = ?1", o.getId()))
.chain(model -> Panache.withTransaction(() -> repository.delete("id", model.getId())));
}
}