feat: ban competition + competition list sort

This commit is contained in:
2025-08-21 11:11:04 +02:00
parent 2a1bdfbdcb
commit 0fc871bd46
6 changed files with 85 additions and 20 deletions

View File

@@ -264,6 +264,12 @@ public class CompetitionService {
if ("admin".equals(source))
return permService.hasEditPerm(securityCtx, id)
.chain(c -> findComb(data.getLicence(), data.getFname(), data.getLname())
.call(combModel -> {
if (c.getBanMembre() == null)
c.setBanMembre(new ArrayList<>());
c.getBanMembre().remove(combModel.getId());
return Panache.withTransaction(() -> repository.persist(c));
})
.chain(combModel -> updateRegister(data, c, combModel, true)))
.chain(r -> Mutiny.fetch(r.getMembre().getLicences())
.map(licences -> SimpleRegisterComb.fromModel(r, licences)));
@@ -368,9 +374,20 @@ public class CompetitionService {
}
}
public Uni<Void> removeRegisterComb(SecurityCtx securityCtx, Long id, Long combId, String source) {
public Uni<Void> removeRegisterComb(SecurityCtx securityCtx, Long id, Long combId, String source, boolean ban) {
if ("admin".equals(source))
return permService.hasEditPerm(securityCtx, id)
.chain(cm -> {
if (cm.getBanMembre() == null)
cm.setBanMembre(new ArrayList<>());
if (ban) {
if (!cm.getBanMembre().contains(combId))
cm.getBanMembre().add(combId);
} else {
cm.getBanMembre().remove(combId);
}
return Panache.withTransaction(() -> repository.persist(cm));
})
.chain(c -> deleteRegister(combId, c, true));
if ("club".equals(source))
return repository.findById(id)