feat: add Result Privacy membre setting
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package fr.titionfire.ffsaf.data.model;
|
||||
|
||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
||||
|
||||
public interface CombModel {
|
||||
Long getCombId();
|
||||
String getName();
|
||||
String getName(MembreModel model, ResultPrivacy privacy);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package fr.titionfire.ffsaf.data.model;
|
||||
|
||||
import fr.titionfire.ffsaf.utils.Categorie;
|
||||
import fr.titionfire.ffsaf.utils.Genre;
|
||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -17,7 +18,7 @@ import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "competition_guest")
|
||||
public class CompetitionGuestModel {
|
||||
public class CompetitionGuestModel implements CombModel {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@@ -44,7 +45,18 @@ public class CompetitionGuestModel {
|
||||
this.lname = s.substring(s.indexOf(" ") + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCombId() {
|
||||
return this.id * -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return fname + " " + lname;
|
||||
return this.fname + " " + this.lname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(MembreModel model, ResultPrivacy privacy) {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.titionfire.ffsaf.data.model;
|
||||
|
||||
import fr.titionfire.ffsaf.utils.CompetitionSystem;
|
||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.persistence.*;
|
||||
@@ -9,6 +10,7 @@ import lombok.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -65,19 +67,35 @@ public class MatchModel {
|
||||
@JoinColumn(name = "match", referencedColumnName = "id")
|
||||
List<CardboardModel> cardboard = new ArrayList<>();
|
||||
|
||||
public String getC1Name(MembreModel model, ResultPrivacy privacy) {
|
||||
if (c1_id != null)
|
||||
return c1_id.getName(model, privacy);
|
||||
if (c1_guest != null)
|
||||
return c1_guest.getName(model, privacy);
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getC2Name(MembreModel model, ResultPrivacy privacy) {
|
||||
if (c2_id != null)
|
||||
return c2_id.getName(model, privacy);
|
||||
if (c2_guest != null)
|
||||
return c2_guest.getName(model, privacy);
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getC1Name() {
|
||||
if (c1_id != null)
|
||||
return c1_id.fname + " " + c1_id.lname;
|
||||
return c1_id.getName();
|
||||
if (c1_guest != null)
|
||||
return c1_guest.fname + " " + c1_guest.lname;
|
||||
return c1_guest.getName();
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getC2Name() {
|
||||
if (c2_id != null)
|
||||
return c2_id.fname + " " + c2_id.lname;
|
||||
return c2_id.getName();
|
||||
if (c2_guest != null)
|
||||
return c2_guest.fname + " " + c2_guest.lname;
|
||||
return c2_guest.getName();
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -94,4 +112,24 @@ public class MatchModel {
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public boolean isC1(Object comb) {
|
||||
if (comb instanceof Long id_) {
|
||||
if (id_ >= 0)
|
||||
return Objects.equals(this.c1_id != null ? this.c1_id.getId() : null, id_);
|
||||
else
|
||||
return Objects.equals(this.c1_guest != null ? this.c1_guest.getId() : null, -id_);
|
||||
}
|
||||
return Objects.equals(this.c1_id, comb) || Objects.equals(this.c1_guest, comb);
|
||||
}
|
||||
|
||||
public boolean isC2(Object comb) {
|
||||
if (comb instanceof Long id_) {
|
||||
if (id_ >= 0)
|
||||
return Objects.equals(this.c2_id != null ? this.c2_id.getId() : null, id_);
|
||||
else
|
||||
return Objects.equals(this.c2_guest != null ? this.c2_guest.getId() : null, -id_);
|
||||
}
|
||||
return Objects.equals(this.c2_id, comb) || Objects.equals(this.c2_guest, comb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package fr.titionfire.ffsaf.data.model;
|
||||
|
||||
import fr.titionfire.ffsaf.utils.Categorie;
|
||||
import fr.titionfire.ffsaf.utils.Genre;
|
||||
import fr.titionfire.ffsaf.utils.GradeArbitrage;
|
||||
import fr.titionfire.ffsaf.utils.RoleAsso;
|
||||
import fr.titionfire.ffsaf.utils.*;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
@@ -11,6 +8,7 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -21,23 +19,23 @@ import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "membre")
|
||||
public class MembreModel implements LoggableModel {
|
||||
public class MembreModel implements LoggableModel, CombModel {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Access(AccessType.PROPERTY)
|
||||
@Schema(description = "L'identifiant du membre.", example = "1")
|
||||
@Schema(description = "L'identifiant du membre.", examples = "1")
|
||||
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")
|
||||
String userId;
|
||||
|
||||
@Schema(description = "Le nom du membre.", example = "Dupont")
|
||||
@Schema(description = "Le nom du membre.", examples = "Dupont")
|
||||
String lname;
|
||||
@Schema(description = "Le prénom du membre.", example = "Jean")
|
||||
@Schema(description = "Le prénom du membre.", examples = "Jean")
|
||||
String fname;
|
||||
|
||||
@Schema(description = "La catégorie du membre.", example = "SENIOR")
|
||||
@Schema(description = "La catégorie du membre.", examples = "SENIOR")
|
||||
Categorie categorie;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@@ -45,29 +43,30 @@ public class MembreModel implements LoggableModel {
|
||||
@Schema(description = "Le club du membre.")
|
||||
ClubModel club;
|
||||
|
||||
@Schema(description = "Le genre du membre.", example = "H")
|
||||
@Schema(description = "Le genre du membre.", examples = "H")
|
||||
Genre genre;
|
||||
|
||||
@Schema(description = "Le numéro de licence du membre.", example = "12345")
|
||||
@Schema(description = "Le numéro de licence du membre.", examples = "12345")
|
||||
Integer licence;
|
||||
|
||||
@Schema(description = "Le pays du membre.", example = "FR")
|
||||
@Schema(description = "Le pays du membre.", examples = "FR")
|
||||
String country;
|
||||
|
||||
@Schema(description = "La date de naissance du membre.")
|
||||
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")
|
||||
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")
|
||||
RoleAsso role;
|
||||
|
||||
@Schema(description = "Le grade d'arbitrage du membre.", example = "NA")
|
||||
@Schema(description = "Le grade d'arbitrage du membre.", examples = "NA")
|
||||
GradeArbitrage grade_arbitrage;
|
||||
|
||||
@Schema(hidden = true)
|
||||
String url_photo;
|
||||
@Schema(description = "La confidentialité de ces résultats", examples = "PUBLIC")
|
||||
@Column(nullable = false, columnDefinition = "smallint default 0")
|
||||
ResultPrivacy resultPrivacy = ResultPrivacy.PUBLIC;
|
||||
|
||||
@OneToMany(mappedBy = "membre", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@Schema(description = "Les licences du membre. (optionnel)")
|
||||
@@ -100,4 +99,25 @@ public class MembreModel implements LoggableModel {
|
||||
", grade_arbitrage=" + grade_arbitrage +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCombId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.fname + " " + this.lname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(MembreModel model, ResultPrivacy privacy) {
|
||||
if (model == null || !Objects.equals(this.getId(), model.getId())) {
|
||||
if (model == null && this.getResultPrivacy() != ResultPrivacy.PUBLIC)
|
||||
return "Anonyme";
|
||||
if (this.getResultPrivacy().ordinal() > privacy.ordinal())
|
||||
return "Anonyme";
|
||||
}
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user