Merge branch 'merged' of https://codefirst.iut.uca.fr/git/HeartDev/Web into merged
commit
7bbedee03c
@ -1,65 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: HeartTrack
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
- merged
|
|
||||||
event:
|
|
||||||
- push
|
|
||||||
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Test ✔️
|
|
||||||
- name: test
|
|
||||||
image: composer:2.6
|
|
||||||
commands:
|
|
||||||
- cd Sources
|
|
||||||
# Installe les dépendances PHP si nécessaire
|
|
||||||
- composer install --no-interaction
|
|
||||||
- ./vendor/bin/phpunit tests
|
|
||||||
|
|
||||||
# Sonar static code analisis deployment
|
|
||||||
# TODO : use an image that already have unzip
|
|
||||||
- name: code-analysis
|
|
||||||
image: php:8.1-cli
|
|
||||||
environment:
|
|
||||||
SONAR_TOKEN:
|
|
||||||
from_secret: SONAR_TOKEN
|
|
||||||
commands:
|
|
||||||
- apt-get update && apt-get install -y curl unzip
|
|
||||||
- export SONAR_SCANNER_VERSION=4.7.0.2747
|
|
||||||
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
|
|
||||||
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
|
|
||||||
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
|
||||||
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
|
|
||||||
- export SONAR_SCANNER_OPTS="-server"
|
|
||||||
- cd Sources
|
|
||||||
- sonar-scanner -D sonar.projectKey=HeartTrack -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
|
|
||||||
depends_on: [ test ]
|
|
||||||
|
|
||||||
# build image and push on the registry ✔️
|
|
||||||
- name: docker-build-and-push
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
dockerfile: Sources/config/Dockerfile
|
|
||||||
context: Sources
|
|
||||||
registry: hub.codefirst.iut.uca.fr
|
|
||||||
repo: hub.codefirst.iut.uca.fr/david.d_almeida/web
|
|
||||||
username:
|
|
||||||
from_secret: SECRET_REGISTRY_USERNAME
|
|
||||||
password:
|
|
||||||
from_secret: SECRET_REGISTRY_PASSWORD
|
|
||||||
git_auth: true
|
|
||||||
|
|
||||||
- name: notify
|
|
||||||
image: ruby:2.1
|
|
||||||
when:
|
|
||||||
status: [ success ]
|
|
||||||
ref:
|
|
||||||
include:
|
|
||||||
- refs/tags/*-demo
|
|
||||||
commands:
|
|
||||||
- sh ./notifymail.sh
|
|
||||||
depends_on: [ docker-build-and-push ]
|
|
@ -0,0 +1,243 @@
|
|||||||
|
[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 "Athlete" as athlete {
|
||||||
|
{static} idAthlete
|
||||||
|
username
|
||||||
|
nom
|
||||||
|
prenom
|
||||||
|
email
|
||||||
|
sexe
|
||||||
|
taille
|
||||||
|
poids
|
||||||
|
motDePasse
|
||||||
|
dateNaissance
|
||||||
|
isCoach
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Amitie" as friendship{
|
||||||
|
{static}# idAthlete1
|
||||||
|
{static}# idAthlete2
|
||||||
|
début
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Notification" as notif {
|
||||||
|
{static} idNotif
|
||||||
|
message
|
||||||
|
date
|
||||||
|
statut
|
||||||
|
urgence
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Envoi" as sendNotif{
|
||||||
|
{static}# idAthlete
|
||||||
|
{static}# idNotif
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Statistique" as stats {
|
||||||
|
{static} idStatistique
|
||||||
|
poids
|
||||||
|
fcMoyenne
|
||||||
|
fcMax
|
||||||
|
caloriesBruleesMoy
|
||||||
|
date
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Entrainement" as training {
|
||||||
|
{static} idEntrainement
|
||||||
|
date
|
||||||
|
description
|
||||||
|
latitude
|
||||||
|
longitude
|
||||||
|
feedback
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Participe" as takepart {
|
||||||
|
{static} #athleteId
|
||||||
|
{static} #entrainementId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Donne" as givepart {
|
||||||
|
{static} #coachId
|
||||||
|
{static} #entrainementId
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity "SourceDonnee" as source {
|
||||||
|
{static} idSource
|
||||||
|
type
|
||||||
|
modele
|
||||||
|
precision
|
||||||
|
#athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Activite" as activity {
|
||||||
|
{static} idActivité
|
||||||
|
type
|
||||||
|
date
|
||||||
|
heureDeDebut
|
||||||
|
heureDeFin
|
||||||
|
effortRessent
|
||||||
|
variabilite
|
||||||
|
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
|
||||||
|
athlete <-- source
|
||||||
|
stats --> athlete
|
||||||
|
takepart --> athlete
|
||||||
|
takepart --> training
|
||||||
|
givepart --> athlete
|
||||||
|
givepart --> training
|
||||||
|
sendNotif --> athlete
|
||||||
|
sendNotif --> notif
|
||||||
|
friendship --> athlete
|
||||||
|
notif --> athlete
|
||||||
|
athlete <-- friendship
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
```plantuml
|
||||||
|
@startuml
|
||||||
|
|
||||||
|
class Athlete {
|
||||||
|
idAthlete
|
||||||
|
username
|
||||||
|
nom
|
||||||
|
prenom
|
||||||
|
email
|
||||||
|
sexe
|
||||||
|
taille
|
||||||
|
poids
|
||||||
|
motDePasse
|
||||||
|
dateNaissance
|
||||||
|
isCoach
|
||||||
|
}
|
||||||
|
|
||||||
|
class Amitie {
|
||||||
|
idAthlete1
|
||||||
|
idAthlete2
|
||||||
|
}
|
||||||
|
|
||||||
|
class Notification {
|
||||||
|
idNotif
|
||||||
|
message
|
||||||
|
date
|
||||||
|
statut
|
||||||
|
urgence
|
||||||
|
athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
class Envoi {
|
||||||
|
idAthlete
|
||||||
|
idNotif
|
||||||
|
}
|
||||||
|
|
||||||
|
class Statistique {
|
||||||
|
idStatistique
|
||||||
|
poids
|
||||||
|
fcMoyenne
|
||||||
|
fcMax
|
||||||
|
caloriesBruleesMoy
|
||||||
|
date
|
||||||
|
athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
class Entrainement {
|
||||||
|
idEntrainement
|
||||||
|
date
|
||||||
|
description
|
||||||
|
latitude
|
||||||
|
longitude
|
||||||
|
feedback
|
||||||
|
athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
class Participe {
|
||||||
|
athleteId
|
||||||
|
entrainementId
|
||||||
|
}
|
||||||
|
|
||||||
|
class Donne {
|
||||||
|
coachId
|
||||||
|
entrainementId
|
||||||
|
}
|
||||||
|
|
||||||
|
class SourceDonnee {
|
||||||
|
idSource
|
||||||
|
type
|
||||||
|
modele
|
||||||
|
precision
|
||||||
|
athleteId
|
||||||
|
}
|
||||||
|
|
||||||
|
class Activite {
|
||||||
|
idActivite
|
||||||
|
type
|
||||||
|
date
|
||||||
|
heureDeDebut
|
||||||
|
heureDeFin
|
||||||
|
effortRessent
|
||||||
|
variabilite
|
||||||
|
variance
|
||||||
|
ecartType
|
||||||
|
moyenne
|
||||||
|
maximum
|
||||||
|
minimum
|
||||||
|
temperatureMoyenne
|
||||||
|
athleteId
|
||||||
|
sourceId
|
||||||
|
}
|
||||||
|
|
||||||
|
class FrequenceCardiaque {
|
||||||
|
idFc
|
||||||
|
altitude
|
||||||
|
temps
|
||||||
|
temperature
|
||||||
|
bpm
|
||||||
|
longitude
|
||||||
|
latitude
|
||||||
|
activiteId
|
||||||
|
}
|
||||||
|
|
||||||
|
Athlete "1" --o "0..*" Amitie
|
||||||
|
Athlete "1" --o "0..*" Notification
|
||||||
|
Athlete "1" --o "0..*" Statistique
|
||||||
|
Athlete "1" --o "0..*" Entrainement
|
||||||
|
Entrainement "0..*" --o "0..*" Athlete : Participants
|
||||||
|
Entrainement "0..*" --o "0..*" Athlete : Coachs
|
||||||
|
Athlete "1" --o "0..*" SourceDonnee
|
||||||
|
Activite "1" --o "0..*" FrequenceCardiaque
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 2.0 MiB |
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,79 @@
|
|||||||
{% extends "authbase.html.twig" %}
|
{% extends "authbase.html.twig" %}
|
||||||
|
|
||||||
{% block css %}{{css}}{% endblock %}
|
{% block css %}{{ css }}{% endblock %}
|
||||||
|
|
||||||
{% block title %}Connexion - HearthTrack{% endblock %}
|
{% block title %}Connexion - HearthTrack{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
{#<<<<<<< HEAD#}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-lg-5">
|
<div class="col-lg-5">
|
||||||
<div class="card shadow-lg border-0 rounded-lg mt-5">
|
<div class="card shadow-lg border-0 rounded-lg mt-5">
|
||||||
<div class="card-header"><h3 class="text-center font-weight-light my-4">Connexion</h3></div>
|
<div class="card-header"><h3 class="text-center font-weight-light my-4">Connexion</h3></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form>
|
{% if login_error %}
|
||||||
|
{% for value in login_error %}
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
{{ value }}
|
||||||
|
{#=======#}
|
||||||
|
{# <div class="container">#}
|
||||||
|
{# <div class="row justify-content-center">#}
|
||||||
|
{# <div class="col-lg-5">#}
|
||||||
|
{# <div class="card shadow-lg border-0 rounded-lg mt-5">#}
|
||||||
|
{# <div class="card-header"><h3 class="text-center font-weight-light my-4">Connexion</h3></div>#}
|
||||||
|
{# <div class="card-body">#}
|
||||||
|
{# <form>#}
|
||||||
|
{# <div class="form-floating mb-3">#}
|
||||||
|
{# <input class="form-control" id="inputEmail" type="email" placeholder="nom@exemple.com" />#}
|
||||||
|
{# <label for="inputEmail">Adresse eMail</label>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# <div class="form-floating mb-3">#}
|
||||||
|
{# <input class="form-control" id="inputPassword" type="password" placeholder="Mot de passe" />#}
|
||||||
|
{# <label for="inputPassword">Mot de passe</label>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# <div class="form-check mb-3">#}
|
||||||
|
{# <input class="form-check-input" id="inputRememberPassword" type="checkbox" value="" />#}
|
||||||
|
{# <label class="form-check-label" for="inputRememberPassword">Mémoriser le mot de passe</label>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# <div class="d-flex align-items-center justify-content-between mt-4 mb-0">#}
|
||||||
|
{# <a class="small" href="/pass">Mot de passe oublié ?</a>#}
|
||||||
|
{# <a class="btn btn-primary" href="/home">Se connecter</a>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# </form>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# <div class="card-footer text-center py-3">#}
|
||||||
|
{# <div class="small"><a href="/regist">Besoin d'un compte ? Inscrivez-vous !</a></div>#}
|
||||||
|
{# </div>#}
|
||||||
|
{#>>>>>>> origin/merged_PLE#}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form method="post" action="/login">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input class="form-control" id="inputEmail" type="email" placeholder="nom@exemple.com" />
|
<input class="form-control" id="email" name="email" type="text" placeholder="Nom d'utilisateur" />
|
||||||
<label for="inputEmail">Adresse eMail</label>
|
<label for="email">Nom d'utilisateur</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input class="form-control" id="inputPassword" type="password" placeholder="Mot de passe" />
|
<input class="form-control" id="password" name="password" type="password" placeholder="Mot de passe" />
|
||||||
<label for="inputPassword">Mot de passe</label>
|
<label for="password">Mot de passe</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check mb-3">
|
<div class="form-check mb-3">
|
||||||
<input class="form-check-input" id="inputRememberPassword" type="checkbox" value="" />
|
<input class="form-check-input" id="inputRememberPassword" type="checkbox" value="" />
|
||||||
<label class="form-check-label" for="inputRememberPassword">Mémoriser le mot de passe</label>
|
<label class="form-check-label" for="inputRememberPassword">Mémoriser le mot de passe</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center justify-content-between mt-4 mb-0">
|
<div class="d-flex align-items-center justify-content-between mt-4 mb-0">
|
||||||
<a class="small" href="/pass">Mot de passe oublié ?</a>
|
<a class="small" href="/forgetPassword">Mot de passe oublié ?</a>
|
||||||
<a class="btn btn-primary" href="/home">Se connecter</a>
|
<button class="btn btn-primary" type="submit">Se connecter</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer text-center py-3">
|
<div class="card-footer text-center py-3">
|
||||||
<div class="small"><a href="/regist">Besoin d'un compte ? Inscrivez-vous !</a></div>
|
<div class="small"><a href="/register">Besoin d'un compte ? Inscrivez-vous !</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Data\Core;
|
|
||||||
|
|
||||||
use Model\User;
|
|
||||||
use Model\Athlete;
|
|
||||||
use Model\CoachAthlete;
|
|
||||||
use Repository\IUserRepository;
|
|
||||||
use Shared\IHashPassword;
|
|
||||||
|
|
||||||
class AuthService implements IAuthService {
|
|
||||||
private IUserRepository $userRepository;
|
|
||||||
private IHashPassword $passwordHacher;
|
|
||||||
private ?User $currentUser = null;
|
|
||||||
|
|
||||||
public function __construct(IUserRepository $userRepository, IHashPassword $passwordHacher) {
|
|
||||||
$this->userRepository = $userRepository;
|
|
||||||
$this->passwordHacher = $passwordHacher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function login(string $email, string $password): bool {
|
|
||||||
$user = $this->userRepository->getItemByEmail($email);
|
|
||||||
if ($user === null || !$this->validatePassword($password, $user->getPasswordHash())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->currentUser = $user;
|
|
||||||
// Add session handling logic here
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function register(string $email, string $password, array $data): bool {
|
|
||||||
if ($this->userRepository->getItemByEmail($email)) {
|
|
||||||
throw new \Exception('User already exists');
|
|
||||||
}
|
|
||||||
|
|
||||||
$hashedPassword = $this->passwordHacher->hashPassword($password);
|
|
||||||
$prenom = $data['prenom'];
|
|
||||||
$username = $data['username'];
|
|
||||||
$nom = $data['nom'];
|
|
||||||
$email = $data['email'];
|
|
||||||
$sexe = $data['sexe'];
|
|
||||||
$taille = $data['taille'];
|
|
||||||
$poids = $data['poids'];
|
|
||||||
$dateNaissance = $data['dateNaissance'] ;
|
|
||||||
$roleName = $data['roleName'];
|
|
||||||
$role = null;
|
|
||||||
if($roleName == "Coach"){
|
|
||||||
$role = new CoachAthlete();
|
|
||||||
}
|
|
||||||
else if($roleName == "Athlete"){
|
|
||||||
$role = new Athlete();
|
|
||||||
}
|
|
||||||
// Create a new user instance (you should expand on this with more data as needed)
|
|
||||||
$user = new User(
|
|
||||||
random_int(0, 100),
|
|
||||||
$nom,
|
|
||||||
$prenom,
|
|
||||||
$username,
|
|
||||||
$email,
|
|
||||||
$hashedPassword,
|
|
||||||
$sexe,
|
|
||||||
$taille,
|
|
||||||
$poids,
|
|
||||||
$dateNaissance,
|
|
||||||
//should use reflexion
|
|
||||||
$role
|
|
||||||
);
|
|
||||||
$this->userRepository->addItem($user);
|
|
||||||
$this->currentUser = $user;
|
|
||||||
// Add session handling logic here
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logout(): void {
|
|
||||||
$this->currentUser = null;
|
|
||||||
// Add session handling logic here
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentUser(): ?User {
|
|
||||||
return $this->currentUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function validatePassword(string $password, string $hash): bool {
|
|
||||||
// Implement password validation logic (e.g., using password_verify if using bcrypt)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
|
|
||||||
class ActiviteGateway {
|
|
||||||
private $connection;
|
|
||||||
|
|
||||||
public function __construct(Connection $connection) {
|
|
||||||
$this->connection = $connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActivite() {
|
|
||||||
$query = "SELECT * FROM Activite";
|
|
||||||
return $this->connection->executeWithErrorHandling($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteById(int $activiteId) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE idActivite = :id";
|
|
||||||
$params = [':id' => [$activiteId, PDO::PARAM_INT]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteByType(string $type) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE type = :type";
|
|
||||||
$params = [':type' => [$type, PDO::PARAM_STR]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteByDate(string $date) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE date = :date";
|
|
||||||
$params = [':date' => [$date, PDO::PARAM_STR]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteByTimeRange(string $startTime, string $endTime) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE heureDebut >= :startTime AND heureFin <= :endTime";
|
|
||||||
$params = [
|
|
||||||
':startTime' => [$startTime, PDO::PARAM_STR],
|
|
||||||
':endTime' => [$endTime, PDO::PARAM_STR]
|
|
||||||
];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteByEffort(int $effortRessenti) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE effortRessenti = :effort";
|
|
||||||
$params = [':effort' => [$effortRessenti, PDO::PARAM_INT]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteByVariability(int $variabilite) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE variabilite = :variability";
|
|
||||||
$params = [':variability' => [$variabilite, PDO::PARAM_INT]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActiviteByTemperature(int $temperatureMoyenne) {
|
|
||||||
$query = "SELECT * FROM Activite WHERE temperatureMoyenne = :temperature";
|
|
||||||
$params = [':temperature' => [$temperatureMoyenne, PDO::PARAM_INT]];
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addActivite(ActiviteEntity $activite) {
|
|
||||||
$query = "INSERT INTO Activite (type, date, heureDebut, heureDeFin, effortRessenti, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne)
|
|
||||||
VALUES (:type, :date, :heureDebut, :heureDeFin, :effortRessenti, :variabilite, :variance, :ecartType, :moyenne, :maximum, :minimum, :temperatureMoyenne)";
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
':type' => $activite->getType(),
|
|
||||||
':date' => $activite->getDate()->format('Y-m-d'), // Format date pour SQL
|
|
||||||
':heureDebut' => $activite->getHeureDebut()->format('H:i:s'), // Format heure pour SQL
|
|
||||||
':heureDeFin' => $activite->getHeureFin()->format('H:i:s'), // Format heure pour SQL
|
|
||||||
':effortRessenti' => $activite->getEffortRessenti(),
|
|
||||||
':variabilite' => $activite->getVariabilite(),
|
|
||||||
':variance' => $activite->getVariance(),
|
|
||||||
':ecartType' => $activite->getEcartType(),
|
|
||||||
':moyenne' => $activite->getMoyenne(),
|
|
||||||
':maximum' => $activite->getMaximum(),
|
|
||||||
':minimum' => $activite->getMinimum(),
|
|
||||||
':temperatureMoyenne' => $activite->getTemperatureMoyenne(),
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateActivite(ActiviteEntity $oldActivite, ActiviteEntity $newActivite) {
|
|
||||||
$query = "UPDATE Activite
|
|
||||||
SET type = :type, date = :date, heureDebut = :heureDebut, heureDeFin = :heureDeFin,
|
|
||||||
effortRessenti = :effortRessenti, variabilite = :variabilite, variance = :variance, ecartType = :ecartType, moyenne = :moyenne, maximum = :maximum, minimum = :minimum, temperatureMoyenne = :temperatureMoyenne
|
|
||||||
WHERE idActivite = :idActivite";
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
':idActivite' => $oldActivite->getIdActivite(),
|
|
||||||
':type' => $newActivite->getType(),
|
|
||||||
':date' => $newActivite->getDate()->format('Y-m-d'), // Format date pour SQL
|
|
||||||
':heureDebut' => $newActivite->getHeureDebut()->format('H:i:s'), // Format heure pour SQL
|
|
||||||
':heureDeFin' => $newActivite->getHeureFin()->format('H:i:s'), // Format heure pour SQL
|
|
||||||
':effortRessenti' => $newActivite->getEffortRessenti(),
|
|
||||||
':variabilite' => $newActivite->getVariabilite(),
|
|
||||||
':variance' => $newActivite->getVariance(),
|
|
||||||
':ecartType' => $newActivite->getEcartType(),
|
|
||||||
':moyenne' => $newActivite->getMoyenne(),
|
|
||||||
':maximum' => $newActivite->getMaximum(),
|
|
||||||
':minimum' => $newActivite->getMinimum(),
|
|
||||||
':temperatureMoyenne' => $newActivite->getTemperatureMoyenne(),
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteActivite(int $idActivite) {
|
|
||||||
$query = "DELETE FROM Activite WHERE idActivite = :idActivite";
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
':idActivite' => $idActivite,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->connection->executeWithErrorHandling($query, $params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
use Model\Activite;
|
|
||||||
|
|
||||||
class ActiviteMapper {
|
|
||||||
public function map(array $data):ActiviteEntity {
|
|
||||||
$activite = new ActiviteEntity();
|
|
||||||
$activite->setIdActivite($data['idActivite']);
|
|
||||||
$activite->setType($data['type']);
|
|
||||||
$activite->setDate($data['date']);
|
|
||||||
$activite->setHeureDebut($data['heureDebut']);
|
|
||||||
$activite->setHeureFin($data['heureFin']);
|
|
||||||
$activite->setEffortRessenti($data['effortRessenti']);
|
|
||||||
$activite->setVariabilite($data['variabilite']);
|
|
||||||
$activite->setVariance($data['variance']);
|
|
||||||
$activite->setEcartType($data['ecartType']);
|
|
||||||
$activite->setMoyenne($data['moyenne']);
|
|
||||||
$activite->setMaximum($data['maximum']);
|
|
||||||
$activite->setMinimum($data['minimum']);
|
|
||||||
$activite->setTemperatureMoyenne($data['temperatureMoyenne']);
|
|
||||||
|
|
||||||
return $activite;
|
|
||||||
}
|
|
||||||
|
|
||||||
//public function ActiviteEntityToModel(ActiviteEntity entity): Activite;
|
|
||||||
|
|
||||||
public function ActiviteEntityToModel(ActiviteEntity $activiteEntity):Activite{
|
|
||||||
|
|
||||||
$act = new Activite(
|
|
||||||
$activiteEntity->getIdActivite(),
|
|
||||||
$activiteEntity->getType(),
|
|
||||||
$activiteEntity->getDate(),
|
|
||||||
$activiteEntity->getHeureDebut(),
|
|
||||||
$activiteEntity->getHeureFin(),
|
|
||||||
$activiteEntity->getEffortRessenti(),
|
|
||||||
$activiteEntity->getVariabilite(),
|
|
||||||
$activiteEntity->getVariance(),
|
|
||||||
$activiteEntity->getEcartType(),
|
|
||||||
$activiteEntity->getMoyenne(),
|
|
||||||
$activiteEntity->getMaximum(),
|
|
||||||
$activiteEntity->getMinimum(),
|
|
||||||
$activiteEntity->getTemperatureMoyenne()
|
|
||||||
);
|
|
||||||
|
|
||||||
return $act;
|
|
||||||
}
|
|
||||||
//public function ActiviteToEntity(Activite model): ActiviteEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
use \PDO;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class ActivityGateway {
|
||||||
|
private Connexion $connection;
|
||||||
|
|
||||||
|
public function __construct(Connexion $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivity() {
|
||||||
|
$query = "SELECT * FROM Activite";
|
||||||
|
return $this->connection->executeWithErrorHandling($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityById(int $activityId) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE idActivite = :id";
|
||||||
|
$params = [':id' => $activityId];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByType(string $type) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE type = :type";
|
||||||
|
$params = [':type' => [$type, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByDate(string $date) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE date = :date";
|
||||||
|
$params = [':date' => [$date, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByTimeRange(string $startTime, string $endTime) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE heureDebut >= :startTime AND heureFin <= :endTime";
|
||||||
|
$params = [
|
||||||
|
':startTime' => [$startTime, PDO::PARAM_STR],
|
||||||
|
':endTime' => [$endTime, PDO::PARAM_STR]
|
||||||
|
];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByEffort(int $effortRessenti) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE effortRessenti = :effort";
|
||||||
|
$params = [':effort' => [$effortRessenti, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByVariability(int $variabilite) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE variabilite = :variability";
|
||||||
|
$params = [':variability' => [$variabilite, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getActivityByTemperature(int $temperatureMoyenne) {
|
||||||
|
$query = "SELECT * FROM Activite WHERE temperatureMoyenne = :temperature";
|
||||||
|
$params = [':temperature' => [$temperatureMoyenne, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addActivity(ActivityEntity $activity) {
|
||||||
|
$query = "INSERT INTO Activite (idactivite, type, date, heurededebut, heuredefin, effortressent, variabilite, variance, ecarttype, moyenne, maximum, minimum, temperaturemoyenne, athleteid, sourceid)
|
||||||
|
VALUES (:idactivite, :type, :date, :heureDebut, :heureDeFin, :effortRessenti, :variabilite, :variance, :ecartType, :moyenne, :maximum, :minimum, :temperatureMoyenne, :athleteid, :sourceid)";
|
||||||
|
$params = [
|
||||||
|
':idactivite' => $activity->getIdActivity(),
|
||||||
|
':type' => $activity->getType(),
|
||||||
|
':date' => $activity->getDate()->format('Y-m-d'), // Format date pour SQL
|
||||||
|
':heureDebut' => $activity->getHeureDebut()->format('H:i:s'), // Format heure pour SQL
|
||||||
|
':heureDeFin' => $activity->getHeureFin()->format('H:i:s'), // Format heure pour SQL
|
||||||
|
':effortRessenti' => $activity->getEffortRessenti(),
|
||||||
|
':variabilite' => $activity->getVariability(),
|
||||||
|
':variance' => $activity->getVariance(),
|
||||||
|
':ecartType' => $activity->getEcartType(),
|
||||||
|
':moyenne' => $activity->getMoyenne(),
|
||||||
|
':maximum' => $activity->getMaximum(),
|
||||||
|
':minimum' => $activity->getMinimum(),
|
||||||
|
':temperatureMoyenne' => $activity->getTemperatureMoyenne(),
|
||||||
|
':athleteid' => 1,
|
||||||
|
':sourceid' => 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateActivity(ActivityEntity $oldActivity, ActivityEntity $newActivity) {
|
||||||
|
$query = "UPDATE Activite
|
||||||
|
SET type = :type, date = :date, heureDebut = :heureDebut, heureDeFin = :heureDeFin,
|
||||||
|
effortRessenti = :effortRessenti, variabilite = :variabilite, variance = :variance, ecartType = :ecartType, moyenne = :moyenne, maximum = :maximum, minimum = :minimum, temperatureMoyenne = :temperatureMoyenne
|
||||||
|
WHERE idActivite = :idActivite";
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
':idActivite' => $oldActivity->getIdActivity(),
|
||||||
|
':type' => $newActivity->getType(),
|
||||||
|
':date' => $newActivity->getDate()->format('Y-m-d'), // Format date pour SQL
|
||||||
|
':heureDebut' => $newActivity->getHeureDebut()->format('H:i:s'), // Format heure pour SQL
|
||||||
|
':heureDeFin' => $newActivity->getHeureFin()->format('H:i:s'), // Format heure pour SQL
|
||||||
|
':effortRessenti' => $newActivity->getEffortRessenti(),
|
||||||
|
':variabilite' => $newActivity->getVariabilite(),
|
||||||
|
':variance' => $newActivity->getVariance(),
|
||||||
|
':ecartType' => $newActivity->getEcartType(),
|
||||||
|
':moyenne' => $newActivity->getMoyenne(),
|
||||||
|
':maximum' => $newActivity->getMaximum(),
|
||||||
|
':minimum' => $newActivity->getMinimum(),
|
||||||
|
':temperatureMoyenne' => $newActivity->getTemperatureMoyenne(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteActivity(int $idActivity) {
|
||||||
|
$query = "DELETE FROM Activite WHERE idActivite = :idActivity";
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
':idActivity' => $idActivity,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
use DateTime;
|
||||||
|
use Model\Activity;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class ActivityMapper {
|
||||||
|
public function activitySqlToEntity(array $data):array
|
||||||
|
{
|
||||||
|
$activityEntities = [];
|
||||||
|
|
||||||
|
foreach ($data as $activityData) {
|
||||||
|
$activity = new ActivityEntity();
|
||||||
|
|
||||||
|
if (isset($activityData['idActivite'])) {
|
||||||
|
$activity->setIdActivity($activityData['idActivite']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['type'])) {
|
||||||
|
$activity->setType($activityData['type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (isset($activityData['date'])) {
|
||||||
|
// $activity->setDate(DateTime::createFromFormat('yyyy-mm--dd',$activityData['date']));
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (isset($activityData['heureDeDebut'])) {
|
||||||
|
$activity->setHeureDebut(new DateTime($activityData['heureDeDebut']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['heureDeFin'])) {
|
||||||
|
$activity->setHeureFin(new DateTime($activityData['heureDeFin']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['effortRessent'])) {
|
||||||
|
$activity->setEffortRessenti($activityData['effortRessent']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['variabilite'])) {
|
||||||
|
$activity->setVariabilite($activityData['variabilite']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['variance'])) {
|
||||||
|
$activity->setVariance($activityData['variance']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['ecartType'])) {
|
||||||
|
$activity->setEcartType($activityData['ecartType']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['moyenne'])) {
|
||||||
|
$activity->setMoyenne($activityData['moyenne']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['maximum'])) {
|
||||||
|
$activity->setMaximum($activityData['maximum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['minimum'])) {
|
||||||
|
$activity->setMinimum($activityData['minimum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($activityData['temperatureMoyenne'])) {
|
||||||
|
$activity->setTemperatureMoyenne($activityData['temperatureMoyenne']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$activityEntities[] = $activity;
|
||||||
|
}
|
||||||
|
Log::dd($activityEntities);
|
||||||
|
return $activityEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity {
|
||||||
|
$date = new DateTime($activiteEntity->getDate());
|
||||||
|
$heureDebut = new \DateTime($activiteEntity->getHeureDebut());
|
||||||
|
$heureFin = new \DateTime($activiteEntity->getHeureFin());
|
||||||
|
$effortRessenti = intval($activiteEntity->getEffortRessenti());
|
||||||
|
$variability = floatval($activiteEntity->getVariability());
|
||||||
|
$variance = floatval($activiteEntity->getVariance());
|
||||||
|
$ecartType = floatval($activiteEntity->getEcartType());
|
||||||
|
|
||||||
|
$act = new Activity(
|
||||||
|
$activiteEntity->getType(),
|
||||||
|
$date,
|
||||||
|
$heureDebut,
|
||||||
|
$heureFin,
|
||||||
|
$effortRessenti,
|
||||||
|
$variability,
|
||||||
|
$variance,
|
||||||
|
$ecartType,
|
||||||
|
$activiteEntity->getMoyenne(),
|
||||||
|
$activiteEntity->getMaximum(),
|
||||||
|
$activiteEntity->getMinimum(),
|
||||||
|
$activiteEntity->getTemperatureMoyenne(),
|
||||||
|
'false'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $act;
|
||||||
|
}
|
||||||
|
//public function ActivityToEntity(Activity model): ActivityEntity;
|
||||||
|
|
||||||
|
public function activityToEntity(Activity $act):ActivityEntity{
|
||||||
|
$actEntity = new ActivityEntity();
|
||||||
|
$actEntity->setIdActivity($act->getIdActivity());
|
||||||
|
$actEntity->setType($act->getType());
|
||||||
|
$actEntity->setDate($act->getDate());
|
||||||
|
$actEntity->setHeureDebut($act->getHeureDebut());
|
||||||
|
$actEntity->setHeureFin($act->getHeureFin());
|
||||||
|
$actEntity->setEffortRessenti($act->getEffortRessenti());
|
||||||
|
$actEntity->setVariabilite($act->getVariability());
|
||||||
|
$actEntity->setVariance($act->getVariance());
|
||||||
|
$actEntity->setEcartType($act->getStandardDeviation());
|
||||||
|
$actEntity->setMoyenne($act->getAverage());
|
||||||
|
$actEntity->setMaximum($act->getMaximum());
|
||||||
|
$actEntity->setMinimum($act->getMinimum());
|
||||||
|
$actEntity->setTemperatureMoyenne($act->getAvrTemperature());
|
||||||
|
|
||||||
|
return $actEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
class AnalyzeEntity
|
||||||
|
{
|
||||||
|
private $idFc;
|
||||||
|
private $altitude;
|
||||||
|
private $time;
|
||||||
|
private $temperature;
|
||||||
|
private $bpm;
|
||||||
|
private $longitude;
|
||||||
|
private $latitude;
|
||||||
|
private $idactivity;
|
||||||
|
public function getIdFC()
|
||||||
|
{
|
||||||
|
return $this->idFc;
|
||||||
|
}
|
||||||
|
public function getAltitude()
|
||||||
|
{
|
||||||
|
return $this->altitude;
|
||||||
|
}
|
||||||
|
public function getTime()
|
||||||
|
{
|
||||||
|
return $this->temps;
|
||||||
|
}
|
||||||
|
public function getTemperature()
|
||||||
|
{
|
||||||
|
return $this->temperature;
|
||||||
|
}
|
||||||
|
public function getBpm()
|
||||||
|
{
|
||||||
|
return $this->bpm;
|
||||||
|
}
|
||||||
|
public function getLongitude()
|
||||||
|
{
|
||||||
|
return $this->longitude;
|
||||||
|
}
|
||||||
|
public function getLatitude()
|
||||||
|
{
|
||||||
|
return $this->latitude;
|
||||||
|
}
|
||||||
|
public function getIdActivity()
|
||||||
|
{
|
||||||
|
return $this->idactivity;
|
||||||
|
}
|
||||||
|
public function setIdFC($idFc)
|
||||||
|
{
|
||||||
|
$this->idFc = $idFc;
|
||||||
|
}
|
||||||
|
public function setAltitude($altitude)
|
||||||
|
{
|
||||||
|
$this->altitude = $altitude;
|
||||||
|
}
|
||||||
|
public function setTime($time)
|
||||||
|
{
|
||||||
|
$this->time = $time;
|
||||||
|
}
|
||||||
|
public function setTemperature($temperature)
|
||||||
|
{
|
||||||
|
$this->temperature = $temperature;
|
||||||
|
}
|
||||||
|
public function setBpm($bpm)
|
||||||
|
{
|
||||||
|
$this->bpm = $bpm;
|
||||||
|
}
|
||||||
|
public function setLongitude($longitude)
|
||||||
|
{
|
||||||
|
$this->longitude = $longitude;
|
||||||
|
}
|
||||||
|
public function setLatitude($latitude)
|
||||||
|
{
|
||||||
|
$this->latitude = $latitude;
|
||||||
|
}
|
||||||
|
public function setIdActivity($idactivity)
|
||||||
|
{
|
||||||
|
$this->idactivity = $idactivity;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
class AnalyzeGateway
|
||||||
|
{
|
||||||
|
private Connexion $connection;
|
||||||
|
|
||||||
|
public function __construct(Connexion $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFrequenceCardiaque() {
|
||||||
|
$query = "SELECT * FROM FrequenceCardiaque";
|
||||||
|
return $this->connection->executeWithErrorHandling($query);
|
||||||
|
}
|
||||||
|
public function getFrequenceCardiaqueByIdActivity(int $activityId)
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM FrequenceCardiaque WHERE activiteid = :id";
|
||||||
|
$params = [':id' => $activityId];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class AnalyzeMapper
|
||||||
|
{
|
||||||
|
public function analyzeSqlToEntity(array $data):array
|
||||||
|
{
|
||||||
|
$analyzeEntities = [];
|
||||||
|
|
||||||
|
foreach ($data as $analyzeData) {
|
||||||
|
$analyze = new ActivityEntity();
|
||||||
|
|
||||||
|
if (isset($analyzeData['idactivite'])) {
|
||||||
|
$analyze->setIdActivity($analyzeData['idactivite']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['type'])) {
|
||||||
|
$analyze->setType($analyzeData['type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['date'])) {
|
||||||
|
$analyze->setDate($analyzeData['date']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['heurededebut'])) {
|
||||||
|
$analyze->setHeureDebut($analyzeData['heurededebut']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['heuredefin'])) {
|
||||||
|
$analyze->setHeureFin($analyzeData['heuredefin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['effortressent'])) {
|
||||||
|
$analyze->setEffortRessenti($analyzeData['effortressent']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['variabilite'])) {
|
||||||
|
$analyze->setVariabilite($analyzeData['variabilite']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['variance'])) {
|
||||||
|
$analyze->setVariance($analyzeData['variance']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['ecarttype'])) {
|
||||||
|
$analyze->setEcartType($analyzeData['ecarttype']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['moyenne'])) {
|
||||||
|
$analyze->setMoyenne($analyzeData['moyenne']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['maximum'])) {
|
||||||
|
$analyze->setMaximum($analyzeData['maximum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['minimum'])) {
|
||||||
|
$analyze->setMinimum($analyzeData['minimum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($analyzeData['temperaturemoyenne'])) {
|
||||||
|
$analyze->setTemperatureMoyenne($analyzeData['temperaturemoyenne']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$analyzeEntities[] = $analyze;
|
||||||
|
}
|
||||||
|
return $analyzeEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
// public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity {
|
||||||
|
// $date = new DateTime($activiteEntity->getDate());
|
||||||
|
// $heureDebut = new \DateTime($activiteEntity->getHeureDebut());
|
||||||
|
// $heureFin = new \DateTime($activiteEntity->getHeureFin());
|
||||||
|
// $effortRessenti = intval($activiteEntity->getEffortRessenti());
|
||||||
|
// $variability = floatval($activiteEntity->getVariability());
|
||||||
|
// $variance = floatval($activiteEntity->getVariance());
|
||||||
|
// $ecartType = floatval($activiteEntity->getEcartType());
|
||||||
|
//
|
||||||
|
// $act = new Activity(
|
||||||
|
// $activiteEntity->getIdActivity(),
|
||||||
|
// $activiteEntity->getType(),
|
||||||
|
// $date,
|
||||||
|
// $heureDebut,
|
||||||
|
// $heureFin,
|
||||||
|
// $effortRessenti,
|
||||||
|
// $variability,
|
||||||
|
// $variance,
|
||||||
|
// $ecartType,
|
||||||
|
// $activiteEntity->getMoyenne(),
|
||||||
|
// $activiteEntity->getMaximum(),
|
||||||
|
// $activiteEntity->getMinimum(),
|
||||||
|
// $activiteEntity->getTemperatureMoyenne(),
|
||||||
|
// 'false'
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// return $act;
|
||||||
|
// }
|
||||||
|
//public function ActivityToEntity(Activity model): ActivityEntity;
|
||||||
|
|
||||||
|
// public function activityToEntity( $act):ActivityEntity{
|
||||||
|
//
|
||||||
|
// $act = new ActivityEntity();
|
||||||
|
// $act->setIdActivity($act->getIdActivity()());
|
||||||
|
// $act->setType($act->getType());
|
||||||
|
// $act->setDate($act->getDate());
|
||||||
|
// $act->setHeureDebut($act->getHeureDebut());
|
||||||
|
// $act->setHeureFin($act->getHeureFin());
|
||||||
|
// $act->setEffortRessenti($act->getEffortRessenti());
|
||||||
|
// $act->setVariabilite($act->getVariability());
|
||||||
|
// $act->setVariance($act->getVariance());
|
||||||
|
// $act->setEcartType($act->getEcartType());
|
||||||
|
// $act->setMoyenne($act->getMoyenne());
|
||||||
|
// $act->setMaximum($act->getMaximum());
|
||||||
|
// $act->setMinimum($act->getMinimum());
|
||||||
|
// $act->setTemperatureMoyenne($act->getTemperatureMoyenne());
|
||||||
|
//
|
||||||
|
// return $act;
|
||||||
|
// }
|
||||||
|
}
|
@ -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,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
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,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use Model\Athlete;
|
||||||
|
use Model\Training;
|
||||||
|
use Model\User;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
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['athleteid'])) {
|
||||||
|
$entrainement->setCoachId($entrainementData['athleteid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entrainementEntities[] = $entrainement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entrainementEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entrainementEntityToModel(EntrainementEntity $entrainementEntity): Training {
|
||||||
|
$date = new DateTime($entrainementEntity->getDate());
|
||||||
|
$idTraining = intval($entrainementEntity->getIdEntrainement());
|
||||||
|
$latitude = floatval($entrainementEntity->getLatitude());
|
||||||
|
$longitude = floatval($entrainementEntity->getLongitude());
|
||||||
|
|
||||||
|
return new Training(
|
||||||
|
$idTraining,
|
||||||
|
$date,
|
||||||
|
$latitude,
|
||||||
|
$longitude,
|
||||||
|
$entrainementEntity->getDescription(),
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class NotificationEntity
|
||||||
|
{
|
||||||
|
private $idNotif;
|
||||||
|
private $message;
|
||||||
|
private $date;
|
||||||
|
private $statut;
|
||||||
|
private $urgence;
|
||||||
|
private $idAthlete;
|
||||||
|
|
||||||
|
public function getIdNotif(): int
|
||||||
|
{
|
||||||
|
return $this->idNotif;
|
||||||
|
}
|
||||||
|
public function getMessage()
|
||||||
|
{
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
public function getDate()
|
||||||
|
{
|
||||||
|
return $this->date;
|
||||||
|
}
|
||||||
|
public function getStatut()
|
||||||
|
{
|
||||||
|
return $this->statut;
|
||||||
|
}
|
||||||
|
public function getUrgence()
|
||||||
|
{
|
||||||
|
return $this->urgence;
|
||||||
|
}
|
||||||
|
public function getIdAthlete()
|
||||||
|
{
|
||||||
|
return $this->idAthlete;
|
||||||
|
}
|
||||||
|
public function setIdNotif($idNotif)
|
||||||
|
{
|
||||||
|
$this->idNotif = $idNotif;
|
||||||
|
}
|
||||||
|
public function setMessage($message)
|
||||||
|
{
|
||||||
|
$this->message = $message;
|
||||||
|
}
|
||||||
|
public function setDate($date)
|
||||||
|
{
|
||||||
|
$this->date = $date;
|
||||||
|
}
|
||||||
|
public function setStatut($statut)
|
||||||
|
{
|
||||||
|
$this->statut = $statut;
|
||||||
|
}
|
||||||
|
public function setUrgence($urgence)
|
||||||
|
{
|
||||||
|
$this->urgence = $urgence;
|
||||||
|
}
|
||||||
|
public function setIdAthlete($idAthlete)
|
||||||
|
{
|
||||||
|
$this->idAthlete = $idAthlete;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class NotificationGateway
|
||||||
|
{
|
||||||
|
private Connexion $connection;
|
||||||
|
|
||||||
|
public function __construct(Connexion $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNotifications(): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Notification";
|
||||||
|
$res = $this->connection->executeWithErrorHandling($query);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNotification(NotificationEntity $notif){
|
||||||
|
$query = "INSERT INTO Notification (message, date, statut, urgence, athleteid) VALUES (:message, :date, :statut, :urgence, :idAthlete)";
|
||||||
|
$params = [':message'=>$notif->getMessage(), ':date'=>$notif->getDate(), ':statut'=>$notif->getStatut(), ':urgence'=>$notif->getUrgence(), ':idAthlete'=>$notif->getIdAthlete()];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use Model\Notification;
|
||||||
|
use Model\Training;
|
||||||
|
use Shared\Log;
|
||||||
|
|
||||||
|
class NotificationMapper
|
||||||
|
{
|
||||||
|
public function notificationSqlToEntity(array $data): array
|
||||||
|
{
|
||||||
|
$notificationEntities = [];
|
||||||
|
|
||||||
|
foreach ($data as $notificationData) {
|
||||||
|
$notification = new NotificationEntity();
|
||||||
|
|
||||||
|
if (isset($notificationData['idnotif'])) {
|
||||||
|
$notification->setIdNotif($notificationData['idnotif']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($notificationData['message'])) {
|
||||||
|
$notification->setMessage($notificationData['message']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($notificationData['date'])) {
|
||||||
|
$notification->setDate($notificationData['date']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($notificationData['statut'])) {
|
||||||
|
$notification->setStatut($notificationData['statut']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($notificationData['urgence'])) {
|
||||||
|
$notification->setUrgence($notificationData['urgence']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($notificationData['athleteid'])) {
|
||||||
|
$notification->setIdAthlete($notificationData['athleteid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$notificationEntities[] = $notification;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $notificationEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notificationEntityToModel(NotificationEntity $notificationEntity): Notification
|
||||||
|
{
|
||||||
|
$date = new DateTime($notificationEntity->getDate());
|
||||||
|
return new Notification(
|
||||||
|
$notificationEntity->getIdNotif(),
|
||||||
|
$notificationEntity->getMessage(),
|
||||||
|
$date,
|
||||||
|
$notificationEntity->getStatut(),
|
||||||
|
$notificationEntity->getUrgence(),
|
||||||
|
$notificationEntity->getIdAthlete()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notificationToEntity(Notification $notification): NotificationEntity
|
||||||
|
{
|
||||||
|
$notif = new NotificationEntity();
|
||||||
|
$notif->setIdNotif($notification->getId());
|
||||||
|
$notif->setMessage($notification->getMessage());
|
||||||
|
$notif->setDate($notification->getDate()->format('Y-m-d H:i:s'));
|
||||||
|
$notif->setStatut($notification->getStatut());
|
||||||
|
$notif->setUrgence($notification->getUrgence());
|
||||||
|
$notif->setIdAthlete($notification->getToUserId());
|
||||||
|
|
||||||
|
return $notif;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
class UserGateway
|
||||||
|
{
|
||||||
|
private Connexion $connection;
|
||||||
|
|
||||||
|
public function __construct(Connexion $connection) {
|
||||||
|
$this->connection = $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsers(): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete";
|
||||||
|
$res = $this->connection->executeWithErrorHandling($query);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserById(int $userId): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE idAthlete = :id";
|
||||||
|
$params = [':id' => $userId];
|
||||||
|
$res = $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByName(string $name): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE nom = :name";
|
||||||
|
$params = [':name' => $name];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByFirstName(string $firstName): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE prenom = :firstName";
|
||||||
|
$params = [':firstName' => $firstName];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByEmail(string $email): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE email = :email";
|
||||||
|
$params = [':email' => $email];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByGender(string $gender): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE sexe = :gender";
|
||||||
|
$params = [':gender' => $gender];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByHeight(int $height): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE taille = :height";
|
||||||
|
$params = [':height' => [$height, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByWeight(int $weight): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE poids = :weight";
|
||||||
|
$params = [':weight' => [$weight, PDO::PARAM_INT]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserByBirthDate(string $birthdate): array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Athlete WHERE dateNaissance = :birthdate";
|
||||||
|
$params = [':birthdate' => [$birthdate, PDO::PARAM_STR]];
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteUserById(int $idAthlete): array
|
||||||
|
{
|
||||||
|
$query = "DELETE FROM Athlete WHERE idAthlete = :idAthlete";
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
':idAthlete' => $idAthlete,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
public function deleteUserByEmail(string $email): array
|
||||||
|
{
|
||||||
|
$query = "DELETE FROM Athlete WHERE email = :email";
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
':email' => $email,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->connection->executeWithErrorHandling($query, $params);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
INSERT INTO Athlete (username, nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES
|
||||||
|
('johnD63', 'Doe', 'John', 'john.doe@example.com', 'M', 1.80, 75, '$2y$10$U59ioMTGZBM2FGQv.3lcbuL0IkO4Fx1jQU7f5hF7o/hvCX2t46mby', '1985-05-15', TRUE),
|
||||||
|
('janeS03', 'Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, '$2y$10$U59ioMTGZBM2FGQv.3lcbuL0IkO4Fx1jQU7f5hF7o/hvCX2t46mby', '1990-03-10', FALSE),
|
||||||
|
('bryanO', 'Martin', 'Paul', 'paul.martin@example.com', 'M', 1.75, 68, '$2y$10$U59ioMTGZBM2FGQv.3lcbuL0IkO4Fx1jQU7f5hF7o/hvCX2t46mby', '1988-08-20', TRUE),
|
||||||
|
('dominicT', 'Brown', 'Anna', 'anna.brown@example.com', 'F', 1.70, 58, '$2y$10$U59ioMTGZBM2FGQv.3lcbuL0IkO4Fx1jQU7f5hF7o/hvCX2t46mby', '1992-11-25', FALSE),
|
||||||
|
('miaT', 'Lee', 'Bruce', 'bruce.lee@example.com', 'M', 1.72, 70, '$2y$10$U59ioMTGZBM2FGQv.3lcbuL0IkO4Fx1jQU7f5hF7o/hvCX2t46mby', '1970-02-05', FALSE);
|
@ -0,0 +1,22 @@
|
|||||||
|
INSERT INTO FrequenceCardiaque
|
||||||
|
VALUES
|
||||||
|
(1, 100, '08:15:00', 15, 130, 45.75771709151474, 3.113484980409329, 1),
|
||||||
|
(2, ROUND(RAND() * 10 + 90), '08:16:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75772709151474, 3.113494980409329, 1),
|
||||||
|
(3, ROUND(RAND() * 10 + 90), '08:17:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75773709151474, 3.113504980409329, 1),
|
||||||
|
(4, ROUND(RAND() * 10 + 90), '08:18:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75774709151474, 3.113514980409329, 1),
|
||||||
|
(5, ROUND(RAND() * 10 + 90), '08:19:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75775709151474, 3.113524980409329, 1),
|
||||||
|
(6, ROUND(RAND() * 10 + 90), '08:20:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75776709151474, 3.113534980409329, 1),
|
||||||
|
(7, ROUND(RAND() * 10 + 90), '08:21:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75777709151474, 3.113544980409329, 1),
|
||||||
|
(8, ROUND(RAND() * 10 + 90), '08:22:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75778709151474, 3.113554980409329, 1),
|
||||||
|
(9, ROUND(RAND() * 10 + 90), '08:23:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75779709151474, 3.113564980409329, 1),
|
||||||
|
(10, ROUND(RAND() * 10 + 90), '08:24:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75780709151474, 3.113574980409329, 1),
|
||||||
|
(11, ROUND(RAND() * 10 + 90), '08:25:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75781709151474, 3.113584980409329, 1),
|
||||||
|
(12, ROUND(RAND() * 10 + 90), '08:26:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75782709151474, 3.113594980409329, 1),
|
||||||
|
(13, ROUND(RAND() * 10 + 90), '08:27:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75783709151474, 3.113604980409329, 1),
|
||||||
|
(14, ROUND(RAND() * 10 + 90), '08:28:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75784709151474, 3.113614980409329, 1),
|
||||||
|
(15, ROUND(RAND() * 10 + 90), '08:29:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75785709151474, 3.113624980409329, 1),
|
||||||
|
(16, ROUND(RAND() * 10 + 90), '08:30:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75786709151474, 3.113634980409329, 1),
|
||||||
|
(17, ROUND(RAND() * 10 + 90), '08:31:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75787709151474, 3.113644980409329, 1),
|
||||||
|
(18, ROUND(RAND() * 10 + 90), '08:32:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75788709151474, 3.113654980409329, 1),
|
||||||
|
(19, ROUND(RAND() * 10 + 90), '08:33:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75789709151474, 3.113664980409329, 1),
|
||||||
|
(20, ROUND(RAND() * 10 + 90), '08:34:00', ROUND(RAND() * 5 + 10), ROUND(RAND() * 20 + 110), 45.75790709151474, 3.113674980409329, 1);
|
@ -0,0 +1,26 @@
|
|||||||
|
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
|
||||||
|
(3, 4, '2023-01-01'),
|
||||||
|
(3, 5, '2023-01-12');
|
||||||
|
|
||||||
|
INSERT INTO Notification (idNotif, message, date, statut, urgence, athleteId) VALUES
|
||||||
|
(1, 'Training session at 10 AM', '2023-03-10', TRUE, 1, 1),
|
||||||
|
(2, 'Training session at 3 PM', '2023-05-10', TRUE, 1, 2);
|
||||||
|
|
||||||
|
INSERT INTO Statistique (idStatistique, poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
|
||||||
|
(1, 70, 80, 150, 500, '2023-03-10', 1),
|
||||||
|
(2, 86, 95, 170, 896, '2023-04-13', 3);
|
||||||
|
|
||||||
|
INSERT INTO Entrainement (idEntrainement, date, description, latitude, longitude, feedback, athleteId) VALUES
|
||||||
|
(1, '2023-03-10', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1),
|
||||||
|
(2, '2023-04-13', 'Long run in the forest', 44.7128, -70.0060, 'Pretty good effort', 3);
|
||||||
|
|
||||||
|
INSERT INTO Participe (athleteId, entrainementId) VALUES
|
||||||
|
(1, 1),
|
||||||
|
(3, 2);
|
||||||
|
|
||||||
|
INSERT INTO SourceDonnee (idSource, type, modele, precision2, athleteId) VALUES
|
||||||
|
(1, 'Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
|
||||||
|
|
||||||
|
INSERT INTO Activite (idActivite, type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
|
||||||
|
(1, 'Running', '2023-03-10', '08:00:00', '09:00:00', 3, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1),
|
||||||
|
(2, 'Running Forest', '2023-04-13', '10:00:00', '12:00:00', 5, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
|
@ -0,0 +1,107 @@
|
|||||||
|
DROP TABLE IF EXISTS Athlete, Friendship, Notification, Statistique, Entrainement, Participe, SourceDonnee, Activite, FrequenceCardiaque CASCADE;
|
||||||
|
|
||||||
|
CREATE TABLE Athlete (
|
||||||
|
idAthlete INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
username VARCHAR(255),
|
||||||
|
nom VARCHAR(255),
|
||||||
|
prenom VARCHAR(255),
|
||||||
|
email VARCHAR(255) UNIQUE,
|
||||||
|
sexe CHAR(1),
|
||||||
|
taille DECIMAL,
|
||||||
|
poids DECIMAL,
|
||||||
|
motDePasse VARCHAR(255),
|
||||||
|
dateNaissance DATE,
|
||||||
|
isCoach BOOLEAN
|
||||||
|
);
|
||||||
|
CREATE TABLE Friendship (
|
||||||
|
idAthlete1 INT,
|
||||||
|
idAthlete2 INT,
|
||||||
|
debut DATE,
|
||||||
|
PRIMARY KEY (idAthlete1, idAthlete2),
|
||||||
|
FOREIGN KEY (idAthlete1) REFERENCES Athlete(idAthlete),
|
||||||
|
FOREIGN KEY (idAthlete2) REFERENCES Athlete(idAthlete)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Notification (
|
||||||
|
idNotif INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
message TEXT,
|
||||||
|
date DATE,
|
||||||
|
statut BOOLEAN,
|
||||||
|
urgence INT,
|
||||||
|
athleteId INT,
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Statistique (
|
||||||
|
idStatistique INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
poids DECIMAL,
|
||||||
|
fcMoyenne DECIMAL,
|
||||||
|
fcMax DECIMAL,
|
||||||
|
caloriesBruleesMoy DECIMAL,
|
||||||
|
date DATE,
|
||||||
|
athleteId INT,
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Entrainement (
|
||||||
|
idEntrainement INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
date DATE,
|
||||||
|
description TEXT,
|
||||||
|
latitude DECIMAL,
|
||||||
|
longitude DECIMAL,
|
||||||
|
feedback TEXT,
|
||||||
|
athleteId INT,
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Participe (
|
||||||
|
athleteId INT,
|
||||||
|
entrainementId INT,
|
||||||
|
PRIMARY KEY (athleteId, entrainementId),
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
|
||||||
|
FOREIGN KEY (entrainementId) REFERENCES Entrainement(idEntrainement)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE SourceDonnee (
|
||||||
|
idSource INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
type VARCHAR(255),
|
||||||
|
modele VARCHAR(255),
|
||||||
|
precision DECIMAL,
|
||||||
|
athleteId INT,
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Activite (
|
||||||
|
idActivite INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
type VARCHAR(255),
|
||||||
|
date DATE,
|
||||||
|
heureDeDebut TIME,
|
||||||
|
heureDeFin TIME,
|
||||||
|
effortRessent DECIMAL,
|
||||||
|
variabilite DECIMAL,
|
||||||
|
variance DECIMAL,
|
||||||
|
ecartType DECIMAL,
|
||||||
|
moyenne DECIMAL,
|
||||||
|
maximum DECIMAL,
|
||||||
|
minimum DECIMAL,
|
||||||
|
temperatureMoyenne DECIMAL,
|
||||||
|
athleteId INT,
|
||||||
|
sourceId INT,
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
|
||||||
|
FOREIGN KEY (sourceId) REFERENCES SourceDonnee(idSource)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE FrequenceCardiaque (
|
||||||
|
idFc INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
altitude DECIMAL,
|
||||||
|
temps TIME,
|
||||||
|
temperature DECIMAL,
|
||||||
|
bpm INT,
|
||||||
|
longitude DECIMAL,
|
||||||
|
latitude DECIMAL,
|
||||||
|
activiteId INT,
|
||||||
|
FOREIGN KEY (activiteId) REFERENCES Activite(idActivite)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- \i athlete.sql
|
||||||
|
-- \i friendship.sql
|
@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
namespace Network;
|
||||||
|
|
||||||
|
use App\Router\Session;
|
||||||
|
use Database\AthleteGateway;
|
||||||
|
use Database\AthleteMapper;
|
||||||
|
use Database\CoachMapper;
|
||||||
|
use Database\Connexion;
|
||||||
|
use Database\UserGateway;
|
||||||
|
use Model\User;
|
||||||
|
use Model\Athlete;
|
||||||
|
use Model\CoachAthlete;
|
||||||
|
use Repository\IUserRepository;
|
||||||
|
use Shared\IHashPassword;
|
||||||
|
use Shared\Log;
|
||||||
|
const USER = 'USER';
|
||||||
|
class AuthService implements IAuthService
|
||||||
|
{
|
||||||
|
private IUserRepository $userRepository;
|
||||||
|
private IHashPassword $passwordHacher;
|
||||||
|
|
||||||
|
private ?User $currentUser = null;
|
||||||
|
|
||||||
|
public function __construct(IUserRepository $userRepository, IHashPassword $passwordHacher)
|
||||||
|
{
|
||||||
|
$this->userRepository = $userRepository;
|
||||||
|
$this->passwordHacher = $passwordHacher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(string $email, string $password): bool
|
||||||
|
{
|
||||||
|
// $user = $this->userRepository->getItemByEmail($email);
|
||||||
|
$userGateway = new UserGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
|
||||||
|
$userRepository = $userGateway->getUserByEmail($email);
|
||||||
|
// Log::dd($userRepository[0]['isCoach']);
|
||||||
|
if($userRepository[0]['isCoach']) {
|
||||||
|
$map = new CoachMapper();
|
||||||
|
$coachEntity = $map->coachSqlToEntity($userRepository);
|
||||||
|
// $user = [];
|
||||||
|
foreach($coachEntity as $coachs) {
|
||||||
|
$user = $map->CoachEntityToModel($coachs);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$map = new AthleteMapper();
|
||||||
|
$athleteEntity = $map->athleteSqlToEntity($userRepository);
|
||||||
|
foreach($athleteEntity as $coachs) {
|
||||||
|
$user = $map->AthleteEntityToModel($coachs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log::dd($user);
|
||||||
|
// $map->athleteEntityToModel($userRepository)
|
||||||
|
|
||||||
|
// $user = ['username' => $userEntity[0]->getUsername(), 'nom' => $userEntity[0]->getNom(),
|
||||||
|
// 'prenom' => $userEntity[0]->getPrenom(),'email' => $userEntity[0]->getEmail(), 'sexe' => $userEntity[0]->getSexe(),
|
||||||
|
// 'taille' => $userEntity[0]->getTaille(), 'poids' => $userEntity[0]->getPoids(), 'motdepasse' => $userEntity[0]->getMotDePasse(),
|
||||||
|
// 'datenaissance' => $userEntity[0]->getDateNaissance(), 'iscoach' => $userEntity[0]->getIsCoach(), 'img' => 'test'];
|
||||||
|
// Log::dd($this->passwordHacher->isPasswordValid($user->getMotDePasse(),$password));
|
||||||
|
if ($user === null || !$this->passwordHacher->isPasswordValid($user->getMotDePasse(),$password)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$this->currentUser = $user;
|
||||||
|
// Log::dd(Session::getInstance()->__get(USER));
|
||||||
|
Session::getInstance()->__set(USER, $this->currentUser->getId());
|
||||||
|
// Log::dd(Session::getInstance()->__set(USER, $this->currentUser->getId()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function register(string $email, string $password, $data): bool
|
||||||
|
{
|
||||||
|
if ($this->userRepository->getItemByEmail($email)) {
|
||||||
|
throw new \Exception('User already exists');
|
||||||
|
}
|
||||||
|
|
||||||
|
$hashedPassword = $this->passwordHacher->hashPassword($password);
|
||||||
|
$prenom = $data['prenom'];
|
||||||
|
$username = $data['username'];
|
||||||
|
$nom = $data['nom'];
|
||||||
|
$sexe = $data['sexe'];
|
||||||
|
$taille = $data['taille'];
|
||||||
|
$poids = $data['poids'];
|
||||||
|
$dateNaissance = $data['dateNaissance'];
|
||||||
|
$roleName = $data['roleName'];
|
||||||
|
$role = null;
|
||||||
|
if ($roleName == "Coach") {
|
||||||
|
$role = new CoachAthlete();
|
||||||
|
} else if ($roleName == "Athlete") {
|
||||||
|
$role = new Athlete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = new User(
|
||||||
|
$nom,
|
||||||
|
$prenom,
|
||||||
|
$username,
|
||||||
|
$email,
|
||||||
|
$hashedPassword,
|
||||||
|
$sexe,
|
||||||
|
$taille,
|
||||||
|
$poids,
|
||||||
|
$dateNaissance,
|
||||||
|
$role
|
||||||
|
);
|
||||||
|
$this->userRepository->addItem($user);
|
||||||
|
$this->currentUser = $user;
|
||||||
|
Session::getInstance()->__set(USER,$this->currentUser->getId());
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logoutUser(): bool
|
||||||
|
{
|
||||||
|
$this->currentUser = null;
|
||||||
|
Session::getInstance()->destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCurrentUser(): ?User
|
||||||
|
{
|
||||||
|
if (!empty(Session::getInstance()->__get(USER)) && $this->currentUser === null) {
|
||||||
|
$this->currentUser = $this->userRepository->getItemById(Session::getInstance()->__get(USER));
|
||||||
|
}
|
||||||
|
return $this->currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Repository;
|
namespace Repository;
|
||||||
|
use Model\User;
|
||||||
|
|
||||||
interface IUserRepository extends IGenericRepository {
|
interface IUserRepository extends IGenericRepository {
|
||||||
public function addFriend(int $user1,int $user2);
|
public function addFriend(User $user1,user $user2);
|
||||||
public function deleteFriend(int $user1,int $user2);
|
public function deleteFriend(User $user1,User $user2);
|
||||||
|
|
||||||
|
public function getItemByEmail(string $email);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,215 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
|
||||||
|
//use Database\{Connexion, AthleteGateway,AthleteEntity};
|
||||||
|
use Database\AthleteEntity;
|
||||||
|
use Database\AthleteGateway;
|
||||||
|
use Database\Connexion;
|
||||||
|
use Database\AthleteMapper;
|
||||||
|
use Database\CoachGateway;
|
||||||
|
use Database\CoachEntity;
|
||||||
|
use Database\CoachMapper;
|
||||||
|
|
||||||
|
class GatewayTest extends TestCase {
|
||||||
|
|
||||||
|
//Partie concernant les Athlètes
|
||||||
|
|
||||||
|
public function testGetAthlete() {
|
||||||
|
|
||||||
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
||||||
|
|
||||||
|
require "loginDatabase.php";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->getAthlete();
|
||||||
|
//var_dump($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fonctionne mais en commentaire pour pas add et del a chaque fois
|
||||||
|
public function testAddAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2023-11-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$athleteEntity = new AthleteEntity();
|
||||||
|
$athleteEntity->setNom('John');
|
||||||
|
$athleteEntity->setPrenom('Doe');
|
||||||
|
$athleteEntity->setIdAthlete(1234);
|
||||||
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity->setSexe('H');
|
||||||
|
$athleteEntity->setTaille(169);
|
||||||
|
$athleteEntity->setPoids(69);
|
||||||
|
$athleteEntity->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$result2 = $athleteGateway->addAthlete($athleteEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testDeleteAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
||||||
|
var_dump($result);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public function testUpdateAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2004-08-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$athleteEntity = new AthleteEntity();
|
||||||
|
$athleteEntity->setNom('John');
|
||||||
|
$athleteEntity->setPrenom('Doe');
|
||||||
|
$athleteEntity->setIdAthlete(13);
|
||||||
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity->setSexe('H');
|
||||||
|
$athleteEntity->setTaille(169);
|
||||||
|
$athleteEntity->setPoids(69);
|
||||||
|
$athleteEntity->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity->setDateNaissance($dateSQL);
|
||||||
|
$athleteEntity->setIsCoach(FALSE);
|
||||||
|
$athleteEntity->setCoachId(NULL);
|
||||||
|
|
||||||
|
$athleteEntity2 = new AthleteEntity();
|
||||||
|
$athleteEntity2->setNom('Monteiro');
|
||||||
|
$athleteEntity2->setPrenom('Kevin');
|
||||||
|
$athleteEntity2->setIdAthlete(13);
|
||||||
|
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity2->setSexe('H');
|
||||||
|
$athleteEntity2->setTaille(169);
|
||||||
|
$athleteEntity2->setPoids(69);
|
||||||
|
$athleteEntity2->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity2->setDateNaissance($dateSQL);
|
||||||
|
$athleteEntity2->setIsCoach(TRUE);
|
||||||
|
$athleteEntity2->setCoachId(1);
|
||||||
|
|
||||||
|
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Partie concernant les Coachs
|
||||||
|
|
||||||
|
public function testGetCoach() {
|
||||||
|
|
||||||
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
||||||
|
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$coachGateway = new CoachGateway($connexion);
|
||||||
|
$result = $coachGateway->getCoach();
|
||||||
|
var_dump($result);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//Fonctionne PAS A PARTIR DE LA
|
||||||
|
public function testAddCoach(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$coachGateway = new CoachGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2023-11-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$coachEntity = new CoachEntity();
|
||||||
|
$coachEntity->setNom('John');
|
||||||
|
$coachEntity->setPrenom('Doe');
|
||||||
|
$coachEntity->setIdCoach(1234);
|
||||||
|
$coachEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$coachEntity->setSexe('H');
|
||||||
|
$coachEntity->setTaille(169);
|
||||||
|
$coachEntity->setPoids(69);
|
||||||
|
$coachEntity->setMotDePasse('motdepasse');
|
||||||
|
$coachEntity->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$result2 = $coachGateway->addCoach($coachEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testDeleteAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
||||||
|
var_dump($result);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
/*
|
||||||
|
public function testUpdateAthlete(){
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
|
||||||
|
$dateSpecifique = "2004-08-26";
|
||||||
|
$timestamp = strtotime($dateSpecifique);
|
||||||
|
$dateSQL = date("Y-m-d", $timestamp);
|
||||||
|
|
||||||
|
$athleteEntity = new AthleteEntity();
|
||||||
|
$athleteEntity->setNom('John');
|
||||||
|
$athleteEntity->setPrenom('Doe');
|
||||||
|
$athleteEntity->setIdAthlete(13);
|
||||||
|
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity->setSexe('H');
|
||||||
|
$athleteEntity->setTaille(169);
|
||||||
|
$athleteEntity->setPoids(69);
|
||||||
|
$athleteEntity->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$athleteEntity2 = new AthleteEntity();
|
||||||
|
$athleteEntity2->setNom('Monteiro');
|
||||||
|
$athleteEntity2->setPrenom('Kevin');
|
||||||
|
$athleteEntity2->setIdAthlete(13);
|
||||||
|
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
||||||
|
$athleteEntity2->setSexe('H');
|
||||||
|
$athleteEntity2->setTaille(169);
|
||||||
|
$athleteEntity2->setPoids(69);
|
||||||
|
$athleteEntity2->setMotDePasse('motdepasse');
|
||||||
|
$athleteEntity2->setDateNaissance($dateSQL);
|
||||||
|
|
||||||
|
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
||||||
|
}*/
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
use Model\User;
|
||||||
|
use Database\AthleteEntity;
|
||||||
|
use Database\AthleteGateway;
|
||||||
|
use Database\Connexion;
|
||||||
|
use Database\AthleteMapper;
|
||||||
|
|
||||||
|
class MapperTest extends TestCase {
|
||||||
|
|
||||||
|
public function testMapperAthlete() {
|
||||||
|
|
||||||
|
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
||||||
|
|
||||||
|
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
||||||
|
$username = "kemonteiro2";
|
||||||
|
$password = "#Phpmyadmin63";
|
||||||
|
|
||||||
|
$connexion = new Connexion($dsn,$username,$password);
|
||||||
|
|
||||||
|
|
||||||
|
$athleteGateway = new AthleteGateway($connexion);
|
||||||
|
$result = $athleteGateway->getAthlete();
|
||||||
|
|
||||||
|
$map = new AthleteMapper ();
|
||||||
|
//SQL To AthleteEntity
|
||||||
|
$athleteEntity = $map->athleteSqlToEntity($result);
|
||||||
|
|
||||||
|
|
||||||
|
foreach($athleteEntity as $ath){
|
||||||
|
|
||||||
|
$result = $ath->getNom();
|
||||||
|
var_dump($result);
|
||||||
|
//Pour chaque AthleteEntity : Athlete Entity To User avec Role Athlete(Model)
|
||||||
|
$user = $map->athleteEntityToModel($ath);
|
||||||
|
var_dump($user->getId());
|
||||||
|
//Pour chaque Athlete du Model -> Athlete Entity
|
||||||
|
$res = $map->athleteToEntity($user);
|
||||||
|
var_dump($res->getIdAthlete());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$dsn = "psql:host=localhost;dbname=sae_3;";
|
||||||
|
$username = "Perederii";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "Web",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"dependencies": {
|
||||||
|
"chart.js": "^4.4.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@kurkle/color": {
|
||||||
|
"version": "0.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz",
|
||||||
|
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
|
||||||
|
},
|
||||||
|
"node_modules/chart.js": {
|
||||||
|
"version": "4.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.1.tgz",
|
||||||
|
"integrity": "sha512-C74QN1bxwV1v2PEujhmKjOZ7iUM4w6BWs23Md/6aOZZSlwMzeCIDGuZay++rBgChYru7/+QFeoQW0fQoP534Dg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@kurkle/color": "^0.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"pnpm": ">=7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"chart.js": "^4.4.1"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue