fix(cat): age map
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 6m55s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 6m55s
This commit is contained in:
@@ -5,6 +5,7 @@ import fr.titionfire.ffsaf.data.repository.CombRepository;
|
||||
import fr.titionfire.ffsaf.data.repository.MatchRepository;
|
||||
import fr.titionfire.ffsaf.data.repository.PouleRepository;
|
||||
import fr.titionfire.ffsaf.rest.data.MatchData;
|
||||
import fr.titionfire.ffsaf.rest.exception.DNotFoundException;
|
||||
import fr.titionfire.ffsaf.utils.CompetitionSystem;
|
||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
||||
@@ -34,14 +35,14 @@ public class MatchService {
|
||||
|
||||
public Uni<MatchData> getById(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
||||
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
||||
.onItem().ifNull().failWith(() -> new RuntimeException("Match not found"))
|
||||
.onItem().ifNull().failWith(() -> new DNotFoundException("Match not found"))
|
||||
.call(data -> permService.hasViewPerm(securityCtx, data.getPoule().getCompet()))
|
||||
.map(MatchData::fromModel);
|
||||
}
|
||||
|
||||
public Uni<List<MatchData>> getAllByPoule(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
||||
return pouleRepository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
||||
.onItem().ifNull().failWith(() -> new RuntimeException("Poule not found"))
|
||||
.onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found"))
|
||||
.call(data -> permService.hasViewPerm(securityCtx, data.getCompet()))
|
||||
.chain(data -> repository.list("poule = ?1", data.getId())
|
||||
.map(o -> o.stream().map(MatchData::fromModel).toList()));
|
||||
@@ -53,7 +54,7 @@ public class MatchService {
|
||||
if (o == null) {
|
||||
return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system)
|
||||
.firstResult()
|
||||
.onItem().ifNull().failWith(() -> new RuntimeException("Poule not found"))
|
||||
.onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found"))
|
||||
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet()))
|
||||
.map(pouleModel -> {
|
||||
MatchModel model = new MatchModel();
|
||||
@@ -67,7 +68,7 @@ public class MatchService {
|
||||
} else {
|
||||
return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system)
|
||||
.firstResult()
|
||||
.onItem().ifNull().failWith(() -> new RuntimeException("Poule not found"))
|
||||
.onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found"))
|
||||
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet()))
|
||||
.map(__ -> o);
|
||||
}
|
||||
@@ -95,7 +96,7 @@ public class MatchService {
|
||||
public Uni<?> updateScore(SecurityCtx securityCtx, CompetitionSystem system, Long id,
|
||||
List<ScoreEmbeddable> scores) {
|
||||
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
||||
.onItem().ifNull().failWith(() -> new RuntimeException("Match not found"))
|
||||
.onItem().ifNull().failWith(() -> new DNotFoundException("Match not found"))
|
||||
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getPoule().getCompet()))
|
||||
.invoke(data -> {
|
||||
data.getScores().clear();
|
||||
@@ -107,7 +108,7 @@ public class MatchService {
|
||||
|
||||
public Uni<?> delete(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
||||
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
||||
.onItem().ifNull().failWith(() -> new RuntimeException("Match not found"))
|
||||
.onItem().ifNull().failWith(() -> new DNotFoundException("Match not found"))
|
||||
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getPoule().getCompet()))
|
||||
.chain(data -> Panache.withTransaction(() -> repository.delete(data)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user