Commit 3519cc8d authored by quentin.vrel's avatar quentin.vrel
parents 206d4e6f 7f257120
...@@ -36,6 +36,16 @@ class RoundController extends Controller ...@@ -36,6 +36,16 @@ class RoundController extends Controller
$body = $this->request->getData(); $body = $this->request->getData();
return $this->newRound($body); return $this->newRound($body);
break; break;
case 'PUT':
// If there is a uriParams, it is the /round/{id}/action endpoint
if ($uriParams) {
$lenUriParams = count($uriParams);
if (($lenUriParams == 2) && ($uriParams[1]=='action')) {
$body = $this->request->getData();
return $this->updateActions(array_merge($body, ['id'=>$uriParams[0]]));
}
}
break;
} }
$message = json_encode(["message" => "unsupported parameters or method in round"]); $message = json_encode(["message" => "unsupported parameters or method in round"]);
return Response::errorResponse($message); return Response::errorResponse($message);
...@@ -91,5 +101,18 @@ class RoundController extends Controller ...@@ -91,5 +101,18 @@ class RoundController extends Controller
return $response; return $response;
} }
/**
* (PUT) Add action of the round in Round table
* TODO : ADD MAIN LOGIC FOR THE GAME
*
* @param string $action string containing all actions
* @return Response
*/
protected function updateActions($action)
{
Round::updateActions($action);
$message = json_encode(["message" => 'Actions updated!']);
$response = Response::createdResponse($message);
return $response;
}
} }
\ No newline at end of file
...@@ -119,7 +119,7 @@ class UserController extends Controller ...@@ -119,7 +119,7 @@ class UserController extends Controller
protected function updateUser($array) protected function updateUser($array)
{ {
// Auth with token phase // Auth with token phase
$authResponse = $this->authUser($id); $authResponse = $this->authUser($array['id']);
if($authResponse->getCode()!=200){ if($authResponse->getCode()!=200){
return $authResponse; return $authResponse;
} }
......
...@@ -34,4 +34,9 @@ class Round extends Model ...@@ -34,4 +34,9 @@ class Round extends Model
$stm = parent::exec('ROUND_CREATE', $pimped_array); $stm = parent::exec('ROUND_CREATE', $pimped_array);
} }
public static function updateActions($array)
{
$stm = parent::exec('ACTION_UPDATE', $array);
}
} }
\ No newline at end of file
...@@ -27,8 +27,14 @@ Game::addSqlQuery( ...@@ -27,8 +27,14 @@ Game::addSqlQuery(
WHERE r.ID_ROUND=:id' WHERE r.ID_ROUND=:id'
); );
User::addSqlQuery( Game::addSqlQuery(
'ROUND_CREATE', 'ROUND_CREATE',
'INSERT INTO MJ_ROUND (ID_ROUND ,ID_GAME ,PREVAILING_WIND ,SEED ,BEGINING ,ENDING ,ACTIONS) 'INSERT INTO MJ_ROUND (ID_ROUND ,ID_GAME ,PREVAILING_WIND ,SEED ,BEGINING ,ENDING ,ACTIONS)
VALUES (NULL, :id_game, :prevailing_wind, :seed, :begin_date, NULL, NULL)' VALUES (NULL, :id_game, :prevailing_wind, :seed, :begin_date, NULL, NULL)'
); );
Game::addSqlQuery(
'ACTION_UPDATE',
'UPDATE MJ_ROUND
SET ACTIONS = :actions WHERE ID_ROUND = :id'
);
\ No newline at end of file
### Récupérer toutes les games
GET http://localhost/index.php/game
### Récupérer la game avec id 3
GET http://localhost/index.php/game/3
\ No newline at end of file
...@@ -17,3 +17,8 @@ POST http://localhost/index.php/round ...@@ -17,3 +17,8 @@ POST http://localhost/index.php/round
} }
### ###
PUT http://localhost/index.php/round/1/action
{
"actions": "test"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment