feat: support decimal on weight
This commit is contained in:
@@ -43,8 +43,8 @@ public class CompetitionGuestModel implements CombModel {
|
||||
|
||||
String country = "fr";
|
||||
|
||||
Integer weight = null;
|
||||
Integer weightReal = null;
|
||||
Float weight = null;
|
||||
Float weightReal = null;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
|
||||
@JoinTable(
|
||||
@@ -109,7 +109,7 @@ public class CompetitionGuestModel implements CombModel {
|
||||
return Stream.concat(comb.stream(), guest.stream()).anyMatch(c -> Objects.equals(c, comb_));
|
||||
}
|
||||
|
||||
public Integer getWeight2() {
|
||||
public Float getWeight2() {
|
||||
return (this.weightReal != null) ? this.weightReal : this.weight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class RegisterModel {
|
||||
@JoinColumn(name = "id_membre")
|
||||
MembreModel membre;
|
||||
|
||||
Integer weight;
|
||||
Integer weightReal;
|
||||
Float weight;
|
||||
Float weightReal;
|
||||
int overCategory = 0;
|
||||
Categorie categorie;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RegisterModel {
|
||||
)
|
||||
List<CatPresetModel> categoriesInscrites = new ArrayList<>();
|
||||
|
||||
public RegisterModel(CompetitionModel competition, MembreModel membre, Integer weight, int overCategory,
|
||||
public RegisterModel(CompetitionModel competition, MembreModel membre, Float weight, int overCategory,
|
||||
Categorie categorie, ClubModel club) {
|
||||
this.id = new RegisterId(competition.getId(), membre.getId());
|
||||
this.competition = competition;
|
||||
@@ -91,7 +91,7 @@ public class RegisterModel {
|
||||
return Categorie.values()[Math.min(tmp.ordinal() + this.overCategory, Categorie.values().length - 1)];
|
||||
}
|
||||
|
||||
public Integer getWeight2() {
|
||||
public Float getWeight2() {
|
||||
if (weightReal != null)
|
||||
return weightReal;
|
||||
return weight;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CombEntity {
|
||||
Genre genre;
|
||||
String country;
|
||||
int overCategory;
|
||||
Integer weight;
|
||||
Float weight;
|
||||
List<CombEntity> teamMembers;
|
||||
List<Long> categoriesInscrites;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CompetitionData {
|
||||
public static class SimpleRegister {
|
||||
long id;
|
||||
int overCategory;
|
||||
Integer weight;
|
||||
Float weight;
|
||||
Categorie categorie;
|
||||
Long club;
|
||||
String club_str;
|
||||
|
||||
@@ -18,8 +18,8 @@ public class RegisterRequestData {
|
||||
private String fname;
|
||||
private String lname;
|
||||
|
||||
private Integer weight;
|
||||
private Integer weightReal;
|
||||
private Float weight;
|
||||
private Float weightReal;
|
||||
private Integer overCategory;
|
||||
private boolean lockEdit = false;
|
||||
private List<Long> categoriesInscrites;
|
||||
|
||||
@@ -26,8 +26,8 @@ public class SimpleRegisterComb {
|
||||
private Categorie categorie;
|
||||
private SimpleClubModel club;
|
||||
private Integer licence;
|
||||
private Integer weight;
|
||||
private Integer weightReal;
|
||||
private Float weight;
|
||||
private Float weightReal;
|
||||
private int overCategory;
|
||||
private boolean hasLicenceActive;
|
||||
private boolean lockEdit;
|
||||
|
||||
@@ -86,7 +86,7 @@ public class RTeam {
|
||||
.max(Integer::compareTo)
|
||||
.map(i -> Categorie.values()[i]).orElse(Categorie.SENIOR1));
|
||||
|
||||
List<Integer> s = Stream.concat(
|
||||
List<Float> s = Stream.concat(
|
||||
pair.getKey().stream().map(RegisterModel::getWeight),
|
||||
pair.getValue().stream().map(CompetitionGuestModel::getWeight))
|
||||
.filter(Objects::nonNull).toList();
|
||||
@@ -95,7 +95,7 @@ public class RTeam {
|
||||
} else if (s.size() == 1) {
|
||||
team.setWeight(s.get(0));
|
||||
} else {
|
||||
team.setWeight((int) s.stream().mapToInt(Integer::intValue)
|
||||
team.setWeight((float) s.stream().mapToDouble(Float::doubleValue)
|
||||
.average()
|
||||
.orElse(0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user