DELETE api.module.admin (added delete)
This commit is contained in:
parent
9f5279fb79
commit
757eea8f47
|
@ -50,7 +50,7 @@
|
|||
* @mail<string> Adresse mail de l'administrateur
|
||||
* @password<string> Mot de passe de l'administrateur
|
||||
*
|
||||
* @return id_admin<id> UID de l'administrateur crée
|
||||
* @return admin<array> Données de l'administrateur crée
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function post($args){
|
||||
|
@ -64,13 +64,13 @@
|
|||
return [ 'error' => new Error(Err::RepoError) ];
|
||||
|
||||
/* (3) Renvoi @id_admin */
|
||||
return [ 'id_admin' => $id_created ];
|
||||
return [ 'id_admin' => Repo::request('admin', 'getById', $id_created) ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (3) Updates an existing new administrator
|
||||
/* (3) Updates an existing administrator
|
||||
*
|
||||
* @id_admin<id> UID de l'administrateur
|
||||
* @mail<string> [OPT] Adresse mail de l'administrateur
|
||||
|
@ -81,7 +81,6 @@
|
|||
---------------------------------------------------------*/
|
||||
public static function put($args){
|
||||
extract($args);
|
||||
debug();
|
||||
|
||||
/* (1) If @mail given
|
||||
---------------------------------------------------------*/
|
||||
|
@ -114,4 +113,21 @@
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (4) Deletes an existing administrator
|
||||
*
|
||||
* @id_admin<id> UID de l'administrateur
|
||||
*
|
||||
* @return removed<bool> Whether the admin has been removed
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function delete($args){
|
||||
extract($args);
|
||||
|
||||
/* (1) Dispatch du status */
|
||||
return [ 'removed' => Repo::request('admin', 'delete', $id_admin) ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -278,6 +278,29 @@
|
|||
}
|
||||
|
||||
|
||||
/* (9) Deletes an admin
|
||||
*
|
||||
* @id_admin<String> The admin UID
|
||||
*
|
||||
* @return removed<bool> Whether the admin has been removed or not
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public function delete(int $id_admin){
|
||||
|
||||
/* (1) Deletes the admin
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Prepare Statement */
|
||||
$pst = $this->pdo->prepare("DELETE FROM `admin` WHERE `id_admin` = :id_admin");
|
||||
|
||||
/* (3) Bind variables */
|
||||
$pst->bindParam(':id_admin', $id_admin, \PDO::PARAM_INT);
|
||||
|
||||
/* (4) Execute -> dispatch status */
|
||||
return $pst->execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue