333 lines
8.3 KiB
TypeScript
333 lines
8.3 KiB
TypeScript
import { ActiviteDTO, AdminDTO, AthleteDTO, CoachDTO, SessionDTO } from "./classesDTO";
|
|
|
|
export type Groupe = "Entrainement" | "Competition" | "Loisir"| "";
|
|
|
|
|
|
export class Ligne{
|
|
id: number|null = null;
|
|
nom!: string;
|
|
composition!: Athlete[] //les joueurs compososant la ligne
|
|
tempsDeJeu!: number; // en minutes
|
|
}
|
|
|
|
export class User{
|
|
id: number|null = null;
|
|
keycloakId!: string;
|
|
nom!: string;
|
|
prenom!:string;
|
|
email!: string;
|
|
}
|
|
|
|
|
|
export class Admin extends User{
|
|
|
|
constructor(dto:AdminDTO);
|
|
constructor();
|
|
|
|
constructor(dto?:AdminDTO){
|
|
super();
|
|
this.id = dto?.id ?? null;
|
|
this.keycloakId = dto?.id_keycloak ?? "";
|
|
this.nom = dto?.name ?? "";
|
|
this.prenom = dto?.prenom ?? "";
|
|
this.email = ""; //TODO
|
|
}
|
|
|
|
toDTO():AdminDTO{
|
|
const dto:AdminDTO = {
|
|
id: this.id,
|
|
id_keycloak: this.keycloakId,
|
|
name: this.nom,
|
|
prenom: this.prenom,
|
|
};
|
|
return dto;
|
|
}
|
|
|
|
}
|
|
|
|
export class Athlete extends User{
|
|
groupes!: Groupe[];
|
|
sessionsID!: number[];
|
|
sessions: Session[] = [];
|
|
|
|
constructor(dto:AthleteDTO);
|
|
constructor();
|
|
|
|
constructor(dto?:AthleteDTO){
|
|
super();
|
|
this.id = dto?.id ?? null;
|
|
this.keycloakId = dto?.id_keycloak ?? "";
|
|
this.nom = dto?.name ?? "";
|
|
this.prenom = dto?.prenom ?? "" ;
|
|
this.email = ""; //TODO
|
|
this.groupes = dto?.groupes ?? [];
|
|
this.sessionsID = dto?.sessionIds ?? [];
|
|
this.sessions = [];
|
|
}
|
|
|
|
toDTO():AthleteDTO{
|
|
const dto:AthleteDTO = {
|
|
id: this.id,
|
|
id_keycloak: this.keycloakId,
|
|
name: this.nom,
|
|
prenom: this.prenom,
|
|
categorie: "",
|
|
niveau: "",
|
|
groupes: this.groupes,
|
|
sessionIds: this.sessionsID,
|
|
};
|
|
return dto;
|
|
}
|
|
|
|
}
|
|
|
|
export class Coach extends User{
|
|
sessionsID!: number[];
|
|
sessions: Session[] = [];
|
|
|
|
constructor(dto:CoachDTO);
|
|
constructor();
|
|
|
|
constructor(dto?:CoachDTO){
|
|
super();
|
|
this.id = dto?.id ?? null;
|
|
this.keycloakId = dto?.id_keycloak ?? "";
|
|
this.nom = dto?.name ?? "";
|
|
this.prenom = dto?.prenom ?? "";
|
|
this.email = ""; //TODO
|
|
this.sessionsID = dto?.sessionIds ?? [];
|
|
this.sessions = [];
|
|
}
|
|
|
|
toDTO():CoachDTO{
|
|
const dto:CoachDTO = {
|
|
id: this.id,
|
|
id_keycloak: this.keycloakId,
|
|
name: this.nom,
|
|
prenom: this.prenom,
|
|
sessionIds: this.sessionsID ,
|
|
};
|
|
return dto;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
export class Session{
|
|
id: number|null = null;
|
|
name!: string;
|
|
activitesID: number[] = [];
|
|
activites: Activite[] = [];
|
|
isRecurrent! : boolean;
|
|
creneau!: Date;
|
|
coach!: Coach;
|
|
athletesID!: number[]
|
|
athletes!: Athlete[]
|
|
duree! : number;
|
|
groupe! : Groupe;
|
|
ligne! : Ligne[];
|
|
|
|
constructor(dto:SessionDTO);
|
|
constructor();
|
|
|
|
constructor(dto?:SessionDTO){
|
|
this.id = dto?.id?? 0;
|
|
this.name = dto?.name?? "";
|
|
this.activitesID = dto?.activiteIds?? [];
|
|
this.activites = [];
|
|
this.isRecurrent = dto?.isRecurrent?? false;
|
|
this.creneau = dto? new Date(dto.creneau) : new Date();
|
|
//this.coach = new Coach(); //dto.coachId; //TODO
|
|
this.athletesID = dto?.athleteIds ?? [];
|
|
this.athletes = [];
|
|
this.duree = dto?.duree ?? 0;
|
|
this.groupe = dto?.groupe ?? "";
|
|
this.ligne = []; //TODO
|
|
|
|
}
|
|
|
|
toDTO():SessionDTO{
|
|
const dto:SessionDTO = {
|
|
id: this.id,
|
|
name: this.name,
|
|
isRecurrent: this.isRecurrent,
|
|
creneau: this.creneau.toISOString(),
|
|
duree: this.duree,
|
|
groupe: "", //TODO
|
|
coachId: this.coach?.id ?? null,
|
|
athleteIds: [],
|
|
activiteIds: []
|
|
};
|
|
return dto;
|
|
}
|
|
}
|
|
|
|
export class Activite{
|
|
id: number|null = null;
|
|
nom!: string;
|
|
session!: Session;
|
|
theme!: string;
|
|
data!: Map<string,string>;
|
|
duree!: number;
|
|
|
|
constructor(dto:ActiviteDTO);
|
|
constructor();
|
|
|
|
constructor(dto?:ActiviteDTO){
|
|
this.id = dto?.id ?? 0;
|
|
this.nom = dto?.name ?? "";
|
|
//this.session = dto.sessionId; //TODO
|
|
this.theme = dto?.theme ?? "";
|
|
//this.data = //TODO
|
|
this.duree = dto?.duree ?? 0;
|
|
|
|
}
|
|
|
|
toDTO():ActiviteDTO{
|
|
const dto:ActiviteDTO = {
|
|
id: this.id,
|
|
name: this.nom,
|
|
duree: this.duree,
|
|
dataActivite: [],
|
|
sessionId: this.session.id,
|
|
theme: this.theme
|
|
};
|
|
return dto;
|
|
}
|
|
|
|
}
|
|
/*
|
|
export function getUserTest():User{
|
|
const user = new Athlete();
|
|
const s1 = new Session();
|
|
const s2 = new Session();
|
|
const s3 = new Session();
|
|
const athlete1 = new Athlete();
|
|
athlete1.id = 1;
|
|
athlete1.nom = "Alice Dupont";
|
|
athlete1.email = "alice@nootnoot.yee";
|
|
athlete1.groupes = ["Entrainement"];
|
|
|
|
const athlete2 = new Athlete();
|
|
athlete2.id = 2;
|
|
athlete2.nom = "Bob Martin";
|
|
athlete2.groupes = ["Competition"];
|
|
|
|
const athlete3 = new Athlete();
|
|
athlete3.id = 3;
|
|
athlete3.nom = "Clara Lopez";
|
|
athlete3.groupes = ["Loisir"];
|
|
|
|
const ligne1 = new Ligne();
|
|
ligne1.id = 1;
|
|
ligne1.nom = "Ligne A";
|
|
ligne1.composition = [athlete1, athlete2]; // Alice + Bob
|
|
ligne1.tempsDeJeu = 45;
|
|
|
|
const ligne2 = new Ligne();
|
|
ligne2.id = 2;
|
|
ligne2.nom = "Ligne B";
|
|
ligne2.composition = [athlete2, athlete3]; // Bob + Clara
|
|
ligne2.tempsDeJeu = 40;
|
|
|
|
const ligne3 = new Ligne();
|
|
ligne3.id = 3;
|
|
ligne3.nom = "Ligne C";
|
|
ligne3.composition = [athlete1, athlete3]; // Alice + Clara
|
|
ligne3.tempsDeJeu = 50;
|
|
|
|
|
|
|
|
user.id = 0;
|
|
user.nom = "Emilien-Yee NootNoot";
|
|
user.email = "emilien@nootnoot.yee";
|
|
s1.creneau = new Date();
|
|
s1.id = 1;
|
|
s1.name = "Entrainement Frisbee"
|
|
s1.isRecurrent = true;
|
|
s1.ligne = [ligne1];
|
|
s1.duree= 90;
|
|
s1.athletes = [athlete1,athlete2];
|
|
var date2 = new Date();
|
|
date2.setDate(date2.getDate() + 2);
|
|
s2.creneau = date2;
|
|
s2.id = 2;
|
|
s2.isRecurrent = false;
|
|
s2.name = "entraintement 2"
|
|
s2.ligne = [ligne2];
|
|
s2.duree= 120;
|
|
s2.athletes = [athlete1,athlete2, athlete3];
|
|
|
|
s3.creneau = date2;
|
|
s3.id = 3;
|
|
s3.isRecurrent = false;
|
|
s3.name = "entraintement 3"
|
|
s3.ligne = [ligne3, ligne1];
|
|
s3.duree= 120;
|
|
s3.athletes = [athlete2, athlete3];
|
|
|
|
const act1 = new Activite();
|
|
act1.id = 1;
|
|
act1.nom = "Échauffement";
|
|
act1.theme = "Cardio";
|
|
act1.duree = 15;
|
|
act1.session = s1;
|
|
act1.data = new Map([["objectif", "Préparer le corps"], ["matériel", "Ballon"]]);
|
|
|
|
const act2 = new Activite();
|
|
act2.id = 2;
|
|
act2.nom = "Dribbles et passes";
|
|
act2.theme = "Technique";
|
|
act2.duree = 30;
|
|
act2.session = s1;
|
|
act2.data = new Map([["objectif", "Améliorer les passes"], ["niveau", "Intermédiaire"]]);
|
|
|
|
const act3 = new Activite();
|
|
act3.id = 3;
|
|
act3.nom = "Renforcement musculaire";
|
|
act3.theme = "Force";
|
|
act3.duree = 25;
|
|
act3.session = s2;
|
|
act3.data = new Map([["objectif", "Renforcer les jambes"], ["matériel", "Haltères"]]);
|
|
|
|
const act4 = new Activite();
|
|
act4.id = 4;
|
|
act4.nom = "Sprint et agilité";
|
|
act4.theme = "Vitesse";
|
|
act4.duree = 20;
|
|
act4.session = s2;
|
|
act4.data = new Map([["objectif", "Améliorer les sprints"], ["matériel", "Plots"]]);
|
|
|
|
const act5 = new Activite();
|
|
act5.id = 5;
|
|
act5.nom = "Match 5v5";
|
|
act5.theme = "Jeu";
|
|
act5.duree = 60;
|
|
act5.session = s3;
|
|
act5.data = new Map([["objectif", "Appliquer les techniques"], ["niveau", "Avancé"]]);
|
|
|
|
const act6 = new Activite();
|
|
act6.id = 6;
|
|
act6.nom = "Étirements";
|
|
act6.theme = "Récupération";
|
|
act6.duree = 10;
|
|
act6.session = s3;
|
|
act6.data = new Map([["objectif", "Éviter les blessures"], ["matériel", "Tapis"]]);
|
|
|
|
|
|
// attach the concrete activities to their sessions
|
|
s1.activites.push(act1);
|
|
s1.activites.push(act2);
|
|
s2.activites.push(act3);
|
|
s2.activites.push(act4);
|
|
s2.activites.push(act5);
|
|
s2.activites.push(act6);
|
|
|
|
user.sessions.push(s1);
|
|
user.sessions.push(s2);
|
|
user.sessions.push(s3);
|
|
|
|
|
|
return user;
|
|
}
|
|
*/ |