wip: send competition data
This commit is contained in:
@@ -6,6 +6,7 @@ import fr.titionfire.ffsaf.rest.data.MatchData;
|
||||
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
||||
import fr.titionfire.ffsaf.utils.CompetitionSystem;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
@@ -60,10 +61,17 @@ public class MatchEndpoints {
|
||||
return service.addOrUpdate(checkPerm, system, data);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("score/{id}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<?> updateScore(@PathParam("id") Long id, List<ScoreEmbeddable> scores) {
|
||||
return service.updateScore(system, id, scores);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<?> delete(@PathParam("id") Long id) {
|
||||
return service.delete(checkPerm, id);
|
||||
return service.delete(checkPerm, system, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package fr.titionfire.ffsaf.rest;
|
||||
import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import fr.titionfire.ffsaf.domain.service.PouleService;
|
||||
import fr.titionfire.ffsaf.rest.data.PouleData;
|
||||
import fr.titionfire.ffsaf.rest.data.PouleFullData;
|
||||
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
||||
import fr.titionfire.ffsaf.utils.CompetitionSystem;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
import io.quarkus.security.Authenticated;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import io.smallrye.mutiny.unchecked.Unchecked;
|
||||
@@ -18,7 +18,7 @@ import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Authenticated
|
||||
// @Authenticated
|
||||
@Path("api/poule/{system}/")
|
||||
public class PouleEndpoints {
|
||||
|
||||
@@ -54,15 +54,23 @@ public class PouleEndpoints {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<PouleData> addOrUpdate(PouleData data) {
|
||||
return service.addOrUpdate(checkPerm, system, data);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("sync")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Uni<?> syncPoule(PouleFullData data) {
|
||||
return service.syncPoule(system, data);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<?> delete(@PathParam("id") Long id) {
|
||||
return service.delete(checkPerm, id);
|
||||
return service.delete(checkPerm, system, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,18 @@ public class MatchData {
|
||||
private String c2_str;
|
||||
private Long poule;
|
||||
private long poule_ord;
|
||||
private boolean isEnd = true;
|
||||
private char groupe;
|
||||
private List<ScoreEmbeddable> scores;
|
||||
|
||||
public static MatchData fromModel(MatchModel model) {
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
return new MatchData(model.getSystemId(), model.getC1_id().getId(), model.getC1_str(), model.getC2_id().getId(),
|
||||
model.getC2_str(), model.getPoule(), model.getPoule_ord(), model.getScores());
|
||||
return new MatchData(model.getSystemId(),
|
||||
(model.getC1_id() == null) ? null : model.getC1_id().getId(), model.getC1_str(),
|
||||
(model.getC2_id() == null) ? null : model.getC2_id().getId(), model.getC2_str(),
|
||||
model.getPoule().getId(), model.getPoule_ord(), model.isEnd(), model.getGroupe(),
|
||||
model.getScores());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package fr.titionfire.ffsaf.rest.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PouleFullData {
|
||||
private Long id;
|
||||
private String name;
|
||||
private Long compet;
|
||||
private Integer type;
|
||||
private List<MatchData> matches;
|
||||
private List<TreeData> trees;
|
||||
|
||||
/*public static PouleFullData fromModel(PouleModel pouleModel) {
|
||||
if (pouleModel == null)
|
||||
return null;
|
||||
|
||||
PouleEntity pouleEntity = PouleEntity.fromModel(pouleModel);
|
||||
|
||||
return new PouleFullData(pouleEntity.getId(), pouleEntity.getName(), pouleEntity.getCompet().getId(),
|
||||
pouleEntity.getType(), pouleModel.getMatchs().stream().map(MatchData::fromModel).toList(),
|
||||
pouleEntity.getTrees().stream().map(TreeData::fromEntity).toList());
|
||||
}*/
|
||||
}
|
||||
@@ -12,17 +12,15 @@ public class TreeData {
|
||||
private Long id;
|
||||
private Long poule;
|
||||
private Integer level;
|
||||
private MatchData match;
|
||||
private Long match;
|
||||
private TreeData left;
|
||||
private TreeData right;
|
||||
private TreeData associatedNode;
|
||||
|
||||
public static TreeData fromModel(TreeModel model) {
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
return new TreeData(model.getId(), model.getPoule(), model.getLevel(), MatchData.fromModel(model.getMatch()),
|
||||
fromModel(model.getLeft()),
|
||||
fromModel(model.getRight()), null);
|
||||
return new TreeData(model.getId(), model.getPoule(), model.getLevel(), model.getMatch().getId(),
|
||||
fromModel(model.getLeft()), fromModel(model.getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user