add Training Entity and gateway
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
de5f390af1
commit
0b4e76e66f
@ -0,0 +1,121 @@
|
||||
[retour au README.md](../../../README.md)
|
||||
[Retour aux Documents](../../README_DOCUMENTS.md)
|
||||
[Retour au diagramme de classes](../README_DIAGRAMMES.md)
|
||||
|
||||
# BDD
|
||||
|
||||
```plantuml
|
||||
@startuml
|
||||
skinparam classAttributeIconSize 0
|
||||
package MLD{
|
||||
entity "Athlète" as athlete {
|
||||
{static} idAthlete
|
||||
nom
|
||||
prénom
|
||||
email
|
||||
sexe
|
||||
taille
|
||||
poids
|
||||
motDePasse
|
||||
dateNaissance
|
||||
}
|
||||
|
||||
entity "Amitié" as friendship{
|
||||
{static}# idAthlete1
|
||||
{static}# idAthlete2
|
||||
début
|
||||
}
|
||||
|
||||
entity "Notification" as notif {
|
||||
{static} idNotif
|
||||
message
|
||||
date
|
||||
statut
|
||||
urgence
|
||||
#athleteId
|
||||
}
|
||||
|
||||
entity "Coach" as coach {
|
||||
{static} idCoach
|
||||
// attributs spécifiques au coach
|
||||
#athleteId
|
||||
}
|
||||
|
||||
entity "Statistique" as stats {
|
||||
{static} idStatistique
|
||||
poids
|
||||
fcMoyenne
|
||||
fcMax
|
||||
caloriesBrûléesMoy
|
||||
date
|
||||
#athleteId
|
||||
}
|
||||
|
||||
entity "Entraînement" as training {
|
||||
{static} idEntrainement
|
||||
date
|
||||
description
|
||||
// Exercices
|
||||
latitude
|
||||
longitude
|
||||
feedback
|
||||
#coachId
|
||||
}
|
||||
|
||||
entity "Participe" as takepart {
|
||||
{static} #athleteId
|
||||
{static} #entrainementId
|
||||
}
|
||||
|
||||
|
||||
entity "SourceDonnée" as source {
|
||||
{static} idSource
|
||||
type
|
||||
modèle
|
||||
précision
|
||||
#athleteId
|
||||
}
|
||||
|
||||
entity "Activité" as activity {
|
||||
{static} idActivité
|
||||
type
|
||||
date
|
||||
heureDeDébut
|
||||
heureDeFin
|
||||
effortRessent
|
||||
variabilité
|
||||
variance
|
||||
ecartType
|
||||
moyenne
|
||||
maximum
|
||||
minimum
|
||||
temperatureMoyenne
|
||||
#athleteId
|
||||
#sourceId
|
||||
}
|
||||
entity "FréquenceCardiaque" as fc {
|
||||
{static} idFc
|
||||
altitude
|
||||
temps : time
|
||||
température
|
||||
bpm
|
||||
longitude
|
||||
latitude
|
||||
#activitéId
|
||||
}
|
||||
|
||||
}
|
||||
activity --> athlete
|
||||
activity --> source
|
||||
activity <-- fc
|
||||
coach --> athlete
|
||||
athlete <-- source
|
||||
stats --> athlete
|
||||
takepart --> athlete
|
||||
takepart --> training
|
||||
friendship --> athlete
|
||||
notif --> athlete
|
||||
coach <-- training
|
||||
athlete <-- friendship
|
||||
@enduml
|
||||
```
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class EntrainementEntity
|
||||
{
|
||||
private $idEntrainement;
|
||||
private $date;
|
||||
private $description;
|
||||
private $latitude;
|
||||
private $longitude;
|
||||
private $feedback;
|
||||
private $coachId;
|
||||
|
||||
public function getIdEntrainement()
|
||||
{
|
||||
return $this->idEntrainement;
|
||||
}
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
public function getLatitude()
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
public function getLongitude()
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
public function getFeedback()
|
||||
{
|
||||
return $this->feedback;
|
||||
}
|
||||
public function getCoachId()
|
||||
{
|
||||
return $this->coachId;
|
||||
}
|
||||
public function setIdEntrainement($idEntrainement)
|
||||
{
|
||||
$this->idEntrainement = $idEntrainement;
|
||||
}
|
||||
public function setDate($date)
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
public function setLatitude($latitude)
|
||||
{
|
||||
$this->latitude = $latitude;
|
||||
}
|
||||
public function setLongitude($longitude)
|
||||
{
|
||||
$this->longitude = $longitude;
|
||||
}
|
||||
public function setFeedback($feedback)
|
||||
{
|
||||
$this->feedback = $feedback;
|
||||
}
|
||||
public function setCoachId($coachId)
|
||||
{
|
||||
$this->coachId = $coachId;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
class EntrainementGateway
|
||||
{
|
||||
private Connexion $connection;
|
||||
|
||||
public function __construct(Connexion $connection) {
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function getEntrainements(): array
|
||||
{
|
||||
$query = "SELECT * FROM Entrainement";
|
||||
$res = $this->connection->executeWithErrorHandling($query);
|
||||
return $res;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
use Model\Athlete;
|
||||
use Model\Training;
|
||||
use Model\User;
|
||||
|
||||
class EntrainementMapper
|
||||
{
|
||||
public function entrainementSqlToEntity(array $data): array {
|
||||
$entrainementEntities = [];
|
||||
|
||||
foreach ($data as $entrainementData) {
|
||||
$entrainement = new EntrainementEntity();
|
||||
if (isset($entrainementData['idEntrainement'])) {
|
||||
$entrainement->setIdEntrainement($entrainementData['idEntrainement']);
|
||||
}
|
||||
|
||||
if (isset($entrainementData['date'])) {
|
||||
$entrainement->setDate($entrainementData['date']);
|
||||
}
|
||||
|
||||
if (isset($entrainementData['description'])) {
|
||||
$entrainement->setDescription($entrainementData['description']);
|
||||
}
|
||||
|
||||
if (isset($entrainementData['latitude'])) {
|
||||
$entrainement->setLatitude($entrainementData['latitude']);
|
||||
}
|
||||
|
||||
if (isset($entrainementData['longitude'])) {
|
||||
$entrainement->setLongitude($entrainementData['longitude']);
|
||||
}
|
||||
|
||||
if (isset($entrainementData['feedback'])) {
|
||||
$entrainement->setFeedback($entrainementData['feedback']);
|
||||
}
|
||||
|
||||
if (isset($entrainementData['coachId'])) {
|
||||
$entrainement->setCoachId($entrainementData['coachId']);
|
||||
}
|
||||
|
||||
$entrainementEntities[] = $entrainement;
|
||||
}
|
||||
|
||||
return $entrainementEntities;
|
||||
}
|
||||
|
||||
public function entrainementEntityToModel(EntrainementEntity $entrainementEntity): Training {
|
||||
return new Training(
|
||||
$entrainementEntity->getIdEntrainement(),
|
||||
$entrainementEntity->getDate(),
|
||||
$entrainementEntity->getDescription(),
|
||||
$entrainementEntity->getLatitude(),
|
||||
$entrainementEntity->getLongitude(),
|
||||
$entrainementEntity->getFeedback()
|
||||
);
|
||||
}
|
||||
|
||||
public function entrainementToEntity(Training $training):EntrainementEntity{
|
||||
|
||||
$train = new EntrainementEntity();
|
||||
$train->setIdEntrainement($training->getId());
|
||||
$train->setDate($training->getDate());
|
||||
$train->setDescription($training->getDescription());
|
||||
$train->setLatitude($training->getLatitude());
|
||||
$train->setLongitude($training->getLongitude());
|
||||
$train->setFeedback($training->getFeedback());
|
||||
$train->setCoachId(1);
|
||||
|
||||
return $train;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue