feat: add Result Privacy membre setting
This commit is contained in:
@@ -2,6 +2,7 @@ package fr.titionfire.ffsaf.rest;
|
||||
|
||||
import fr.titionfire.ffsaf.domain.service.ResultService;
|
||||
import fr.titionfire.ffsaf.domain.service.UpdateService;
|
||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
@@ -46,7 +47,7 @@ public class ExternalResultEndpoints {
|
||||
@Path("/comb/list")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<HashMap<String, String>> combList() {
|
||||
return resultService.getCombList(id);
|
||||
return resultService.getCombList(id, ResultPrivacy.PUBLIC);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -55,7 +56,7 @@ public class ExternalResultEndpoints {
|
||||
public Uni<?> getArray(@QueryParam("comb") String comb) {
|
||||
if (comb.equals("0"))
|
||||
return Uni.createFrom().item("");
|
||||
return resultService.getCombArrayPublic(id, comb.substring(0, comb.indexOf('¤')), comb.substring(comb.indexOf('¤') + 1));
|
||||
return resultService.getCombArrayPublic(id, comb, ResultPrivacy.PUBLIC);
|
||||
}
|
||||
|
||||
@GET
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package fr.titionfire.ffsaf.rest.data;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.MatchModel;
|
||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||
import fr.titionfire.ffsaf.utils.TreeNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
@@ -38,15 +40,15 @@ public class ResultCategoryData {
|
||||
|
||||
@RegisterForReflection
|
||||
public record PouleArrayData(String red, boolean red_w, List<Integer[]> score, boolean blue_w, String blue, boolean end) {
|
||||
public static PouleArrayData fromModel(MatchModel matchModel) {
|
||||
public static PouleArrayData fromModel(MatchModel matchModel, MembreModel membreModel, ResultPrivacy privacy) {
|
||||
return new PouleArrayData(
|
||||
matchModel.getC1Name(),
|
||||
matchModel.getC1Name(membreModel, privacy),
|
||||
matchModel.isEnd() && matchModel.win() > 0,
|
||||
matchModel.isEnd() ?
|
||||
matchModel.getScores().stream().map(s -> new Integer[]{s.getS1(), s.getS2()}).toList()
|
||||
: new ArrayList<>(),
|
||||
matchModel.isEnd() && matchModel.win() < 0,
|
||||
matchModel.getC2Name(),
|
||||
matchModel.getC2Name(membreModel, privacy),
|
||||
matchModel.isEnd());
|
||||
}
|
||||
}
|
||||
@@ -54,8 +56,8 @@ public class ResultCategoryData {
|
||||
@RegisterForReflection
|
||||
public static record TreeData(long id, String c1FullName, String c2FullName, List<ScoreEmbeddable> scores,
|
||||
boolean end) {
|
||||
public static TreeData from(MatchModel match) {
|
||||
return new TreeData(match.getId(), match.getC1Name(), match.getC2Name(), match.getScores(), match.isEnd());
|
||||
public static TreeData from(MatchModel match, MembreModel membreModel, ResultPrivacy privacy) {
|
||||
return new TreeData(match.getId(), match.getC1Name(membreModel, privacy), match.getC2Name(membreModel, privacy), match.getScores(), match.isEnd());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,34 +19,32 @@ import java.util.Date;
|
||||
@AllArgsConstructor
|
||||
@RegisterForReflection
|
||||
public class SimpleMembre {
|
||||
@Schema(description = "L'identifiant du membre.", example = "1")
|
||||
@Schema(description = "L'identifiant du membre.", examples = "1")
|
||||
private long id;
|
||||
@Schema(description = "L'identifiant long du membre (userID).", example = "e81d1d35-d897-421e-8086-6c5e74d13c6e")
|
||||
@Schema(description = "L'identifiant long du membre (userID).", examples = "e81d1d35-d897-421e-8086-6c5e74d13c6e")
|
||||
private String userId;
|
||||
@Schema(description = "Le nom du membre.", example = "Dupont")
|
||||
@Schema(description = "Le nom du membre.", examples = "Dupont")
|
||||
private String lname = "";
|
||||
@Schema(description = "Le prénom du membre.", example = "Jean")
|
||||
@Schema(description = "Le prénom du membre.", examples = "Jean")
|
||||
private String fname = "";
|
||||
@Schema(description = "La catégorie du membre.", example = "SENIOR")
|
||||
@Schema(description = "La catégorie du membre.", examples = "SENIOR")
|
||||
private Categorie categorie;
|
||||
@Schema(description = "Le club du membre.")
|
||||
private SimpleClubModel club;
|
||||
@Schema(description = "Le genre du membre.", example = "H")
|
||||
@Schema(description = "Le genre du membre.", examples = "H")
|
||||
private Genre genre;
|
||||
@Schema(description = "Le numéro de licence du membre.", example = "12345")
|
||||
@Schema(description = "Le numéro de licence du membre.", examples = "12345")
|
||||
private Integer licence;
|
||||
@Schema(description = "Le pays du membre.", example = "FR")
|
||||
@Schema(description = "Le pays du membre.", examples = "FR")
|
||||
private String country;
|
||||
@Schema(description = "La date de naissance du membre.")
|
||||
private Date birth_date;
|
||||
@Schema(description = "L'adresse e-mail du membre.", example = "jean.dupont@example.com")
|
||||
@Schema(description = "L'adresse e-mail du membre.", examples = "jean.dupont@examples.com")
|
||||
private String email;
|
||||
@Schema(description = "Le rôle du membre dans l'association.", example = "MEMBRE")
|
||||
@Schema(description = "Le rôle du membre dans l'association.", examples = "MEMBRE")
|
||||
private RoleAsso role;
|
||||
@Schema(description = "Le grade d'arbitrage du membre.", example = "N/A")
|
||||
@Schema(description = "Le grade d'arbitrage du membre.", examples = "N/A")
|
||||
private GradeArbitrage grade_arbitrage;
|
||||
@Schema(hidden = true)
|
||||
private String url_photo;
|
||||
|
||||
public static SimpleMembre fromModel(MembreModel model) {
|
||||
if (model == null)
|
||||
@@ -66,7 +64,6 @@ public class SimpleMembre {
|
||||
.email(model.getEmail())
|
||||
.role(model.getRole())
|
||||
.grade_arbitrage(model.getGrade_arbitrage())
|
||||
.url_photo(model.getUrl_photo())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user