From bcc75fb840f617fe0aac07b588af6305493b5afe Mon Sep 17 00:00:00 2001 From: Alexis Feron Date: Thu, 2 Nov 2023 11:06:39 +0100 Subject: [PATCH] Ajout classes metier --- php/dal/gateway/AlumniGateway.php | 83 +++++++++++ php/dal/gateway/CompteGateway.php | 82 ----------- php/metier/{Compte.php => Alumni.php} | 37 +++-- php/metier/Article.php | 58 ++++++++ php/metier/Evenement.php | 66 +++++++-- php/metier/Experience.php | 94 ++++++++++++ php/metier/Formation.php | 94 ++++++++++++ php/metier/Offre.php | 200 ++++++++++++++++++++++---- php/metier/Profil.php | 105 ++++++++++++++ php/modeles/AdminModele.php | 4 +- php/modeles/UtilisateurModele.php | 10 +- 11 files changed, 693 insertions(+), 140 deletions(-) create mode 100644 php/dal/gateway/AlumniGateway.php delete mode 100755 php/dal/gateway/CompteGateway.php rename php/metier/{Compte.php => Alumni.php} (54%) mode change 100755 => 100644 create mode 100644 php/metier/Article.php create mode 100644 php/metier/Experience.php create mode 100644 php/metier/Formation.php create mode 100644 php/metier/Profil.php diff --git a/php/dal/gateway/AlumniGateway.php b/php/dal/gateway/AlumniGateway.php new file mode 100644 index 0000000..122418f --- /dev/null +++ b/php/dal/gateway/AlumniGateway.php @@ -0,0 +1,83 @@ +con = $con; + } + + public function insert(string $email, int $id, string $motDePasse, Role $role){ + $query='INSERT INTO Alumni VALUES (:i, :e, :m, :r)'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT), + ':e' => array($email, PDO::PARAM_STR), + ':m' => array($motDePasse, PDO::PARAM_STR), + ':r' => array($role, PDO::PARAM_STR) + )); + } + + public function updateEmail(int $id, string $newEmail){ + $query='UPDATE Alumni SET email=:new WHERE id=:i'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT), + ':new' => array($newEmail, PDO::PARAM_STR) + )); + } + + public function updateMotDePasse(int $id, string $password){ + $query='UPDATE Alumni SET motDePasse=:new WHERE id=:i'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT), + ':new' => array($password, PDO::PARAM_STR) + )); + } + + public function updateRole(int $id, Role $newRole){ + $query='UPDATE Alumni SET role=:new WHERE id=:i'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT), + ':new' => array($newRole, PDO::PARAM_STR) + )); + } + + public function delete(int $id){ + $query='DELETE FROM Alumni WHERE id=:i'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT) + )); + } + + public function findById(int $id){ + $query = 'SELECT * FROM Alumni WHERE id=:i'; + $this->con->executeQuery($query, array( + ':i' => array($id, PDO::PARAM_INT) + )); + $res=$this->con->getResults(); + return new Alumni($res[0]['email'],$res[0]['id'],$res[0]['motDePasse'],$res[0]['role']); + } + + public function findByEmail(string $email){ + $query='SELECT * FROM Alumni WHERE email=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + )); + $res=$this->con->getResults(); + return new Alumni($res[0]['email'],$res[0]['id'],$res[0]['motDePasse'],$res[0]['role']); + } + + public function getAll(){ + $query='SELECT * FROM Alumni'; + $this->con->executeQuery($query); + $res=$this->con->getResults(); + $array=[]; + foreach($res as $r){ + $array[]=new Alumni($r['email'],$r['id'],$r['motDePasse'],$r['role']); + } + return $array; + } +} \ No newline at end of file diff --git a/php/dal/gateway/CompteGateway.php b/php/dal/gateway/CompteGateway.php deleted file mode 100755 index b54023c..0000000 --- a/php/dal/gateway/CompteGateway.php +++ /dev/null @@ -1,82 +0,0 @@ -con = $con; - } - - public function insert(string $email, string $pseudo, string $motDePasse){ - $query='INSERT INTO Compte VALUES (:e, :p, :m)'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR), - ':p' => array($pseudo, PDO::PARAM_STR), - ':m' => array($motDePasse, PDO::PARAM_STR) - )); - } - - public function updateEmail(string $email, string $newEmail){ - $query='UPDATE Compte SET email=:new WHERE email=:e'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR), - ':new' => array($newEmail, PDO::PARAM_STR) - )); - } - - public function updatePseudo(string $email, string $pseudo){ - $query='UPDATE Compte SET pseudo=:new WHERE email=:e'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR), - ':new' => array($pseudo, PDO::PARAM_STR) - )); - } - - public function updateMotDePasse(string $email, string $password){ - $query='UPDATE Compte SET motDePasse=:new WHERE email=:e'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR), - ':new' => array($password, PDO::PARAM_STR) - )); - } - - public function delete(string $email){ - $query='DELETE FROM Compte WHERE email=:e'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR) - )); - } - - public function findByPseudo(string $pseudo){ - $query = 'SELECT * FROM Compte WHERE pseudo=:p'; - $this->con->executeQuery($query, array( - ':p' => array($pseudo, PDO::PARAM_STR) - )); - $res=$this->con->getResults(); - return new Compte($res[0]['email'],$res[0]['pseudo'],$res[0]['motDePasse']); - } - - public function findByEmail(string $email){ - $query='SELECT * FROM Compte WHERE email=:e'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR), - )); - $res=$this->con->getResults(); - return new Compte($res[0]['email'],$res[0]['pseudo'],$res[0]['motDePasse']); - } - - public function getAll(){ - $query='SELECT * FROM Compte'; - $this->con->executeQuery($query); - $res=$this->con->getResults(); - $array=[]; - foreach($res as $r){ - $array[]=new Compte($r['email'],$r['pseudo'],$r['motDePasse']); - } - return $array; - } -} \ No newline at end of file diff --git a/php/metier/Compte.php b/php/metier/Alumni.php old mode 100755 new mode 100644 similarity index 54% rename from php/metier/Compte.php rename to php/metier/Alumni.php index 2ed68b3..d7455c5 --- a/php/metier/Compte.php +++ b/php/metier/Alumni.php @@ -1,38 +1,54 @@ pseudo = $pseudo; + $this->id = $id; $this->email = $email; $this->motDePasse = $motDePasse; + $this->role = $role; } /** * @return string */ - public function getPseudonyme() : string + public function getId() : string { - return $this->pseudo; + return $this->id; } /** @@ -50,4 +66,9 @@ class Compte{ { return $this->motDePasse; } + + public function getRole(): Role + { + return $this->role; + } } \ No newline at end of file diff --git a/php/metier/Article.php b/php/metier/Article.php new file mode 100644 index 0000000..d09a3c6 --- /dev/null +++ b/php/metier/Article.php @@ -0,0 +1,58 @@ +id = $id; + $this->auteur = $auteur; + $this->sousTitre = $sousTitre; + $this->description = $description; + } + + public function getId(): int + { + return $this->id; + } + + public function getAuteur(): Alumni + { + return $this->auteur; + } + + public function getSousTitre(): string + { + return $this->sousTitre; + } + + public function getDescription(): string + { + return $this->description; + } +} \ No newline at end of file diff --git a/php/metier/Evenement.php b/php/metier/Evenement.php index ec8782c..5feefe6 100755 --- a/php/metier/Evenement.php +++ b/php/metier/Evenement.php @@ -3,19 +3,24 @@ class Evenement { /** - * @var string Nom Evènement + * @var int Identifiant */ - private string $nameEvent; + private int $id; /** - * @var string date Evenement + * @var string Nom Evenement + */ + private string $nom; + + /** + * @var string Date de l'evenement */ private string $date; /** - * @var Compte Organisateur + * @var Alumni Organisateur */ - private Compte $organisator; + private Alumni $organisateur; /** * @var array Liste des Participants @@ -23,26 +28,46 @@ class Evenement private array $participants; /** - * @param string $nameEvent + * @var int Nombre maximal d'inscrits + */ + private int $nbInscriptionMax; + + /** + * @var string Url de l'image + */ + private string $imageUrl; + + /** + * @param int $id + * @param string $nom * @param string $date - * @param Compte $organisator + * @param Alumni $organisateur * @param array $participants + * @param int $nbInscriptionMax + * @param string $imageUrl */ - public function __construct(string $nameEvent,string $date,Compte $organisator, - array $participants) + public function __construct(int $id, string $nom, string $date, Alumni $organisateur, array $participants, int $nbInscriptionMax, string $imageUrl) { - $this->nameEvent = $nameEvent; + $this->id = $id; + $this->nom = $nom; $this->date = $date; - $this->organisator = $organisator; + $this->organisateur = $organisateur; $this->participants = $participants; + $this->nbInscriptionMax = $nbInscriptionMax; + $this->imageUrl = $imageUrl; } - public function getNameEvent() : string + public function getId(): int { - return $this->nameEvent; + return $this->id; } - public function getDateEvent() : string + public function getNom() : string + { + return $this->nom; + } + + public function getDate() : string { return $this->date; } @@ -52,5 +77,18 @@ class Evenement return $this->participants; } + public function getOrganisateur(): Alumni + { + return $this->organisateur; + } + public function getNbInscriptionMax(): int + { + return $this->nbInscriptionMax; + } + + public function getImageUrl(): string + { + return $this->imageUrl; + } } \ No newline at end of file diff --git a/php/metier/Experience.php b/php/metier/Experience.php new file mode 100644 index 0000000..c0d89a2 --- /dev/null +++ b/php/metier/Experience.php @@ -0,0 +1,94 @@ +id = $id; + $this->profil = $profil; + $this->intitule = $intitule; + $this->dateDebut = $dateDebut; + $this->dateFin = $dateFin; + $this->nomEntreprise = $nomEntreprise; + $this->travailActuel = $travailActuel; + } + + public function getId(): int + { + return $this->id; + } + + public function getProfil(): Profil + { + return $this->profil; + } + + public function getIntitule(): string + { + return $this->intitule; + } + + public function getDateDebut(): string + { + return $this->dateDebut; + } + + public function getDateFin(): string + { + return $this->dateFin; + } + + public function getNomEntreprise(): string + { + return $this->nomEntreprise; + } + + public function isTravailActuel(): bool + { + return $this->travailActuel; + } +} \ No newline at end of file diff --git a/php/metier/Formation.php b/php/metier/Formation.php new file mode 100644 index 0000000..22cd70b --- /dev/null +++ b/php/metier/Formation.php @@ -0,0 +1,94 @@ +id = $id; + $this->profil = $profil; + $this->nom = $nom; + $this->ville = $ville; + $this->dateDebut = $dateDebut; + $this->dateFin = $dateFin; + $this->formationActuelle = $formationActuelle; + } + + public function getId(): int + { + return $this->id; + } + + public function getProfil(): Profil + { + return $this->profil; + } + + public function getNom(): string + { + return $this->nom; + } + + public function getVille(): string + { + return $this->ville; + } + + public function getDateDebut(): string + { + return $this->dateDebut; + } + + public function getDateFin(): string + { + return $this->dateFin; + } + + public function isFormationActuelle(): bool + { + return $this->formationActuelle; + } +} \ No newline at end of file diff --git a/php/metier/Offre.php b/php/metier/Offre.php index 2a79b64..f412345 100755 --- a/php/metier/Offre.php +++ b/php/metier/Offre.php @@ -1,71 +1,213 @@ name = $offername; - $this->company = $offercompany; - $this->recruiter = $offermanager; + $this->id = $id; + $this->offreur = $offreur; + $this->nom = $nom; $this->description = $description; + $this->imageUrl = $imageUrl; + $this->typeContrat = $typeContrat; + $this->ville = $ville; + $this->entreprise = $entreprise; + $this->descriptifPoste = $descriptifPoste; + $this->profil = $profil; + $this->experience = $experience; + $this->niveauEtudes = $niveauEtudes; + $this->mailContact = $mailContact; + $this->numero = $numero; + $this->siteUrl = $siteUrl; } - /** - * @return string - */ - public function getName(): string + public function getId(): int { - return $this->name; + return $this->id; } - /** - * @return string - */ - public function getCompany(): string + public function getOffreur(): Alumni { - return $this->company; + return $this->offreur; } - /** - * @return Compte|string - */ - public function getRecruiter(): Compte|string + public function getNom(): string { - return $this->recruiter; + return $this->nom; } - /** - * @return string - */ public function getDescription(): string { return $this->description; } + public function getImageUrl(): string + { + return $this->imageUrl; + } + public function getTypeContrat(): TypeContrat + { + return $this->typeContrat; + } + public function getVille(): string + { + return $this->ville; + } + public function getEntreprise(): string + { + return $this->entreprise; + } + public function getDescriptifPoste(): string + { + return $this->descriptifPoste; + } + + public function getProfil(): Profil + { + return $this->profil; + } + + public function getExperience(): string + { + return $this->experience; + } + + public function getNiveauEtudes(): NiveauEtudes + { + return $this->niveauEtudes; + } + + public function getMailContact(): string + { + return $this->mailContact; + } + + public function getNumero(): string + { + return $this->numero; + } + + public function getSiteUrl(): string + { + return $this->siteUrl; + } } \ No newline at end of file diff --git a/php/metier/Profil.php b/php/metier/Profil.php new file mode 100644 index 0000000..f5cad7d --- /dev/null +++ b/php/metier/Profil.php @@ -0,0 +1,105 @@ +id = $id; + $this->alumni = $alumni; + $this->cv = $cv; + $this->nom = $nom; + $this->prenom = $prenom; + $this->linkedinUrl = $linkedinUrl; + $this->githubUrl = $githubUrl; + $this->portfolioUrl = $portfolioUrl; + } + + public function getId(): int + { + return $this->id; + } + + public function getAlumni(): Alumni + { + return $this->alumni; + } + + public function getCv(): string + { + return $this->cv; + } + + public function getNom(): string + { + return $this->nom; + } + + public function getPrenom(): string + { + return $this->prenom; + } + + public function getLinkedinUrl(): string + { + return $this->linkedinUrl; + } + + public function getGithubUrl(): string + { + return $this->githubUrl; + } + + public function getPortfolioUrl(): string + { + return $this->portfolioUrl; + } +} \ No newline at end of file diff --git a/php/modeles/AdminModele.php b/php/modeles/AdminModele.php index a4031a1..4103f26 100755 --- a/php/modeles/AdminModele.php +++ b/php/modeles/AdminModele.php @@ -6,9 +6,9 @@ class AdminModele extends MembreModele { /** * @description supprimer un compte - * @param \Compte $account compte à supprimer + * @param \Alumni $account compte à supprimer */ - public function deleteAccount(\Compte $account) + public function deleteAccount(\Alumni $account) { // TO DO } diff --git a/php/modeles/UtilisateurModele.php b/php/modeles/UtilisateurModele.php index e60ee58..f66b0c0 100755 --- a/php/modeles/UtilisateurModele.php +++ b/php/modeles/UtilisateurModele.php @@ -17,12 +17,12 @@ class UtilisateurModele * @description se connecter * @param string email * @param string hash - * @return \Compte + * @return \Alumni */ - public function Login(string $email,string $hash) : \Compte + public function Login(string $email,string $hash) : \Alumni { // TO DO - return new \Compte(null,null,null); + return new \Alumni(null,null,null); } /** @@ -30,9 +30,9 @@ class UtilisateurModele * @param string email * @param string hash * @param string $pseudo - * @return \Compte chargé + * @return \Alumni chargé */ - public function signIn(string $email,string $pseudo,string $hash) : \Compte + public function signIn(string $email,string $pseudo,string $hash) : \Alumni { // TO DO return new Compte(null,null,null);