[module.professor] implemented PUT
This commit is contained in:
parent
ad3626d64c
commit
2b71469530
|
@ -134,4 +134,48 @@ class ProfessorController{
|
|||
|
||||
}
|
||||
|
||||
|
||||
/* (4) Edits an existing professor
|
||||
*
|
||||
* @prof_id<int> The professor UID
|
||||
* @lastName<String> [OPT] The professor's lastName
|
||||
* @firstName<String> [OPT] The professor's firstName
|
||||
* @category<int> [OPT] The professor's category ID
|
||||
* @hoursToDo<int> [OPT] The professor's number of hours to do
|
||||
* @initials<int> [OPT] The professor's initials
|
||||
* @isAdmin<bool> [OPT] Whether the professor is an admin
|
||||
* @casLogin<String> [OPT] The professor's CAS username
|
||||
*
|
||||
* @return updated<bool> Whether it has been updated
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public static function put($args){
|
||||
$prof_id = 0;
|
||||
$lastName = null;
|
||||
$firstName = null;
|
||||
$category = null;
|
||||
$hoursToDo = null;
|
||||
$initials = null;
|
||||
$isAdmin = null;
|
||||
$casLogin = null;
|
||||
extract($args);
|
||||
|
||||
/* Get the professor repo */
|
||||
/** @var professor $prof_repo */
|
||||
$prof_repo = Repo::getRepo('professor');
|
||||
|
||||
/* (1) Try to update */
|
||||
return ['updated' => $prof_repo->update(
|
||||
$prof_id,
|
||||
$lastName,
|
||||
$firstName,
|
||||
$category,
|
||||
$hoursToDo,
|
||||
$initials,
|
||||
$isAdmin,
|
||||
$casLogin
|
||||
)];
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -111,13 +111,13 @@ class professor extends Repo_i {
|
|||
$build_rq = [];
|
||||
$bind_param = [ ':idProfesseur' => $id ];
|
||||
|
||||
if( !is_null($lastName) ){ $build_rq[] = '`lastName` = :lastName'; $bind_param[':lastName'] = $lastName; }
|
||||
if( !is_null($firstName) ){ $build_rq[] = '`firstName` = :firstName'; $bind_param[':firstName'] = $firstName; }
|
||||
if( !is_null($category) ){ $build_rq[] = '`category` = :category'; $bind_param[':category'] = $category; }
|
||||
if( !is_null($hoursToDo) ){ $build_rq[] = '`hoursToDo` = :hoursToDo'; $bind_param[':hoursToDo'] = $hoursToDo; }
|
||||
if( !is_null($initials) ){ $build_rq[] = '`initials` = :initials'; $bind_param[':initials'] = $initials; }
|
||||
if( !is_null($isAdmin) ){ $build_rq[] = '`isAdmin` = :isAdmin'; $bind_param[':isAdmin'] = $isAdmin; }
|
||||
if( !is_null($casLogin) ){ $build_rq[] = '`casLogin` = :casLogin'; $bind_param[':casLogin'] = $casLogin; }
|
||||
if( !is_null($lastName) ){ $build_rq[] = '`lastName` = :lastName'; $bind_param[':lastName'] = $lastName; }
|
||||
if( !is_null($firstName) ){ $build_rq[] = '`firstName` = :firstName'; $bind_param[':firstName'] = $firstName; }
|
||||
if( !is_null($category) ){ $build_rq[] = '`Categorie_idCategorie` = :category'; $bind_param[':category'] = $category; }
|
||||
if( !is_null($hoursToDo) ){ $build_rq[] = '`hoursToDo` = :hoursToDo'; $bind_param[':hoursToDo'] = $hoursToDo; }
|
||||
if( !is_null($initials) ){ $build_rq[] = '`abreviation` = :initials'; $bind_param[':initials'] = $initials; }
|
||||
if( !is_null($isAdmin) ){ $build_rq[] = '`admin` = :isAdmin'; $bind_param[':isAdmin'] = $isAdmin; }
|
||||
if( !is_null($casLogin) ){ $build_rq[] = '`casLogin` = :casLogin'; $bind_param[':casLogin'] = $casLogin; }
|
||||
|
||||
/* (2) ERROR if no updated field */
|
||||
if( count($build_rq) <= 0 || count($bind_param) <= 1 )
|
||||
|
|
|
@ -71,6 +71,24 @@
|
|||
}
|
||||
},
|
||||
|
||||
"PUT": {
|
||||
"des": "Edits an existing professor",
|
||||
"per": [],
|
||||
"par": {
|
||||
"URL0": { "des": "Optional professor UID.", "typ": "id", "ren": "prof_id" },
|
||||
"firstName": { "des": "Professor last name.", "typ": "varchar(2,30,alphanumeric)", "opt": true },
|
||||
"lastName": { "des": "Professor first name.", "typ": "varchar(2,30,alphanumeric)", "opt": true },
|
||||
"category": { "des": "Professor category UID.", "typ": "id", "opt": true },
|
||||
"hoursToDo": { "des": "Number of hours professor have to do", "typ": "id", "opt": true },
|
||||
"initials": { "des": "Professor initials", "typ": "varchar(2,2,letters)", "opt": true },
|
||||
"isAdmin": { "des": "Whether professor is an admin", "typ": "boolean", "opt": true },
|
||||
"casLogin": { "des": "Optional CAS username", "typ": "varchar(6,10,letters)", "opt": true }
|
||||
},
|
||||
"out": {
|
||||
"updated": { "des": "Whether the professor has been updated", "typ": "boolean" }
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"Stats": {
|
||||
"GET":{
|
||||
|
|
Loading…
Reference in New Issue