Ajout classes metier

gateway
Alexis Feron 1 year ago
parent 8106ddd9e4
commit bcc75fb840

@ -0,0 +1,83 @@
<?php
class AlumniGateway
{
private Connection $con;
/**
* @param $con
*/
public function __construct(Connection $con){
$this->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;
}
}

@ -1,82 +0,0 @@
<?php
class CompteGateway
{
private Connection $con;
/**
* @param $con
*/
public function __construct(Connection $con){
$this->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;
}
}

@ -1,38 +1,54 @@
<?php
class Compte{
enum Role
{
case Admin;
case Moderateur;
case Utilisateur;
}
class Alumni{
/**
* @var string Pseudo
* @var int Identifiant
*/
private string $pseudo;
private int $id;
/**
* @var string Email
*/
private string $email;
/**
* @var string Mot de passe
*/
private string $motDePasse;
/**
* @param string $pseudo
* @var Role Role
*/
private Role $role;
/**
* @param int $id
* @param string $email
* @param string $motDePasse
* @param Role $role
*/
public function __construct(string $pseudo, string $email, string $motDePasse)
public function __construct(int $id, string $email, string $motDePasse, Role $role)
{
$this->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;
}
}

@ -0,0 +1,58 @@
<?php
class Article
{
/**
* @var int Identifiant
*/
private int $id;
/**
* @var Alumni Auteur
*/
private Alumni $auteur;
/**
* @var string Sous titre de l'article
*/
private string $sousTitre;
/**
* @var string Description de l'article
*/
private string $description;
/**
* @param int $id
* @param Alumni $auteur
* @param string $sousTitre
* @param string $description
*/
public function __construct(int $id, Alumni $auteur, string $sousTitre, string $description)
{
$this->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;
}
}

@ -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;
}
}

@ -0,0 +1,94 @@
<?php
class Experience
{
/**
* @var int Identifiant
*/
private int $id;
/**
* @var Profil profil
*/
private Profil $profil;
/**
* @var string Intitule
*/
private string $intitule;
/**
* @var string Date début
*/
private string $dateDebut;
/**
* @var string Date fin
*/
private string $dateFin;
/**
* @var string Nom entreprise
*/
private string $nomEntreprise;
/**
* @var bool Travail Actuel
*/
private bool $travailActuel;
/**
* @param int $id
* @param Profil $profil
* @param string $intitule
* @param string $dateDebut
* @param string $dateFin
* @param string $nomEntreprise
* @param bool $travailActuel
*/
public function __construct(int $id, Profil $profil, string $intitule, string $dateDebut, string $dateFin, string $nomEntreprise, bool $travailActuel)
{
$this->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;
}
}

@ -0,0 +1,94 @@
<?php
class Formation
{
/**
* @var int Identifiant
*/
private int $id;
/**
* @var Profil profil
*/
private Profil $profil;
/**
* @var string Nom
*/
private string $nom;
/**
* @var string Ville
*/
private string $ville;
/**
* @var string Date début
*/
private string $dateDebut;
/**
* @var string Date fin
*/
private string $dateFin;
/**
* @var bool Formation Actuelle
*/
private bool $formationActuelle;
/**
* @param int $id
* @param Profil $profil
* @param string $nom
* @param string $ville
* @param string $dateDebut
* @param string $dateFin
* @param bool $formationActuelle
*/
public function __construct(int $id, Profil $profil, string $nom, string $ville, string $dateDebut, string $dateFin, bool $formationActuelle)
{
$this->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;
}
}

@ -1,71 +1,213 @@
<?php
enum TypeContrat
{
case CDI;
case CDD;
case Alternance;
case Stage;
}
enum ProfilRecherche
{
case Junior;
case Senior;
case Indifferent;
}
enum NiveauEtudes: string
{
case Bac2 = "Bac+2";
case Bac3 = "Bac+3";
case Bac5 = "Bac+5";
case Indifferent = "Indifferent";
}
class Offre
{
/**
* @var int Identifiant
*/
private int $id;
/**
* @var Alumni Offreur
*/
private Alumni $offreur;
/**
* @var string intitulé de l'offre
*/
private string $name;
private string $nom;
/**
* @var string Description de l'offre
*/
private string $description;
/**
* @var string Url de l'image
*/
private string $imageUrl;
/**
* @var TypeContrat Type de contrat
*/
private TypeContrat $typeContrat;
/**
* @var string Ville
*/
private string $ville;
/**
* @var string Entreprise de l'offre
*/
private string $company;
private string $entreprise;
/**
* @var Compte recruteur
* @var string Descriptif du poste
*/
private Compte $recruiter;
private string $descriptifPoste;
/**
* @var string description de l'offre
* @var ProfilRecherche Profil recherché
*/
private string $description;
private ProfilRecherche $profil;
/**
* @var string Experience
*/
private string $experience;
public function __construct(string $offername,string $offercompany,
string $offermanager,string $description)
/**
* @var NiveauEtudes Niveau d'études
*/
private NiveauEtudes $niveauEtudes;
/**
* @var string Email de contact
*/
private string $mailContact;
/**
* @var string Numero
*/
private string $numero;
/**
* @var string Url du site
*/
private string $siteUrl;
/**
* @param int $id
* @param Alumni $offreur
* @param string $nom
* @param string $description
* @param string $imageUrl
* @param TypeContrat $typeContrat
* @param string $ville
* @param string $entreprise
* @param string $descriptifPoste
* @param Profil $profil
* @param string $experience
* @param NiveauEtudes $niveauEtudes
* @param string $mailContact
* @param string $numero
* @param string $siteUrl
*/
public function __construct(int $id, Alumni $offreur, string $nom, string $description, string $imageUrl, TypeContrat $typeContrat, string $ville, string $entreprise, string $descriptifPoste, Profil $profil, string $experience, NiveauEtudes $niveauEtudes, string $mailContact, string $numero, string $siteUrl)
{
$this->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;
}
}

@ -0,0 +1,105 @@
<?php
class Profil
{
/**
* @var int Identifiant
*/
private int $id;
/**
* @var Alumni Compte
*/
private Alumni $alumni;
/**
* @var string CV
*/
private string $cv;
/**
* @var string Nom
*/
private string $nom;
/**
* @var string Prenom
*/
private string $prenom;
/**
* @var string Url linkedin
*/
private string $linkedinUrl;
/**
* @var string Url github
*/
private string $githubUrl;
/**
* @var string Url du portfolio
*/
private string $portfolioUrl;
/**
* @param int $id
* @param Alumni $alumni
* @param string $cv
* @param string $nom
* @param string $prenom
* @param string $linkedinUrl
* @param string $githubUrl
* @param string $portfolioUrl
*/
public function __construct(int $id, Alumni $alumni, string $cv, string $nom, string $prenom, string $linkedinUrl, string $githubUrl, string $portfolioUrl)
{
$this->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;
}
}

@ -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
}

@ -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);

Loading…
Cancel
Save