feat: add team support to cm

This commit is contained in:
2026-01-17 22:37:48 +01:00
parent a5bbc41dfd
commit e8d5d0fa0c
14 changed files with 325 additions and 54 deletions

View File

@@ -9,6 +9,10 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
@Data
@AllArgsConstructor
@RegisterForReflection
@@ -23,6 +27,7 @@ public class CombEntity {
String country;
int overCategory;
Integer weight;
List<CombEntity> teamMembers;
public static CombEntity fromModel(MembreModel model) {
if (model == null)
@@ -31,7 +36,7 @@ public class CombEntity {
return new CombEntity(model.getId(), model.getLname(), model.getFname(), model.getCategorie(),
model.getClub() == null ? null : model.getClub().getClubId(),
model.getClub() == null ? "Sans club" : model.getClub().getName(), model.getGenre(), model.getCountry(),
0, null);
0, null, new ArrayList<>());
}
@@ -40,7 +45,9 @@ public class CombEntity {
return null;
return new CombEntity(model.getId() * -1, model.getLname(), model.getFname(), model.getCategorie(), null,
model.getClub(), model.getGenre(), model.getCountry(), 0, model.getWeight());
model.getClub(), model.getGenre(), model.getCountry(), 0, model.getWeight(),
Stream.concat(model.getComb().stream().map(CombEntity::fromModel),
model.getGuest().stream().map(CombEntity::fromModel)).toList());
}
public static CombEntity fromModel(RegisterModel registerModel) {
@@ -51,6 +58,6 @@ public class CombEntity {
return new CombEntity(model.getId(), model.getLname(), model.getFname(), registerModel.getCategorie(),
registerModel.getClub2() == null ? null : registerModel.getClub2().getClubId(),
registerModel.getClub2() == null ? "Sans club" : registerModel.getClub2().getName(), model.getGenre(),
model.getCountry(), registerModel.getOverCategory(), registerModel.getWeight());
model.getCountry(), registerModel.getOverCategory(), registerModel.getWeight(), new ArrayList<>());
}
}

View File

@@ -325,7 +325,10 @@ public class CompetitionService {
}))
.chain(model -> {
model.setFname(data.getFname());
model.setLname(data.getLname());
if (data.getLname().equals("__team"))
model.setLname("_team");
else
model.setLname(data.getLname());
model.setGenre(data.getGenre());
model.setClub(data.getClub());
model.setCountry(data.getCountry());
@@ -467,7 +470,8 @@ public class CompetitionService {
.call(cm -> membreService.getById(combId)
.invoke(Unchecked.consumer(model -> {
if (model == null)
throw new DNotFoundException(String.format(trad.t("le.membre.n.existe.pas"), combId));
throw new DNotFoundException(
String.format(trad.t("le.membre.n.existe.pas"), combId));
if (!securityCtx.isInClubGroup(model.getClub().getId()))
throw new DForbiddenException();
})))