feat(comp): add more register data
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 6m25s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 6m25s
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package fr.titionfire.ffsaf.utils;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@RegisterForReflection
|
||||
|
||||
@Embeddable
|
||||
public class RegisterEmbeddable {
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "id_membre")
|
||||
MembreModel membre;
|
||||
|
||||
Integer weight;
|
||||
int overCategory = 0;
|
||||
}
|
||||
@@ -36,6 +36,43 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Calendar toCalendar(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
return cal;
|
||||
}
|
||||
|
||||
public static Categorie getCategoryFormBirthDate(Date birth_date, Date currentDate) {
|
||||
|
||||
int currentSaison = getSaison(currentDate);
|
||||
int birthYear = toCalendar(birth_date).get(Calendar.YEAR);
|
||||
|
||||
int diff = currentSaison - birthYear;
|
||||
if (diff < 6) {
|
||||
return Categorie.SUPER_MINI;
|
||||
} else if (diff < 8) {
|
||||
return Categorie.MINI_POUSSIN;
|
||||
} else if (diff < 10) {
|
||||
return Categorie.POUSSIN;
|
||||
} else if (diff < 12) {
|
||||
return Categorie.BENJAMIN;
|
||||
} else if (diff < 14) {
|
||||
return Categorie.MINIME;
|
||||
} else if (diff < 16) {
|
||||
return Categorie.CADET;
|
||||
} else if (diff < 18) {
|
||||
return Categorie.JUNIOR;
|
||||
} else if (diff < 24) {
|
||||
return Categorie.SENIOR1;
|
||||
} else if (diff < 34) {
|
||||
return Categorie.SENIOR2;
|
||||
} else if (diff < 44) {
|
||||
return Categorie.VETERAN1;
|
||||
} else {
|
||||
return Categorie.VETERAN2;
|
||||
}
|
||||
}
|
||||
|
||||
public static Uni<String> moveMedia(long idSrc, long idDest, String media, String dirSrc, String dirDst) {
|
||||
return Uni.createFrom().nullItem().map(__ -> {
|
||||
File dirFile = new File(media, dirSrc);
|
||||
@@ -199,4 +236,19 @@ public class Utils {
|
||||
return "Ok";
|
||||
});
|
||||
}
|
||||
|
||||
public static int getDaysBeforeCompetition(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.set(Calendar.HOUR_OF_DAY, 0);
|
||||
now.set(Calendar.MINUTE, 0);
|
||||
now.set(Calendar.SECOND, 0);
|
||||
|
||||
return (int) ((calendar.getTimeInMillis() - now.getTimeInMillis()) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user