Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-cdaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Quentin Vrel
projet-cdaw
Commits
7573ddfb
Commit
7573ddfb
authored
Dec 01, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
we can now add games
parent
7f257120
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
1 deletion
+39
-1
GameController.class.php
BackEnd/src/controller/GameController.class.php
+18
-0
Game.class.php
BackEnd/src/model/Game.class.php
+7
-0
Game.sql.php
BackEnd/src/sql/Game.sql.php
+6
-0
gameRequest.http
BackEnd/src/testRequests/gameRequest.http
+8
-1
No files found.
BackEnd/src/controller/GameController.class.php
View file @
7573ddfb
...
...
@@ -26,6 +26,10 @@ class GameController extends Controller
// Else, it is the /game endpoint
return
$this
->
getAllGames
();
break
;
case
'POST'
:
$body
=
$this
->
request
->
getData
();
return
$this
->
newGame
(
$body
);
break
;
}
$message
=
json_encode
([
"message"
=>
"unsupported parameters or method in game"
]);
return
Response
::
errorResponse
(
$message
);
...
...
@@ -54,4 +58,18 @@ class GameController extends Controller
$response
=
Response
::
okResponse
(
json_encode
(
$games
,
JSON_PRETTY_PRINT
));
return
$response
;
}
/**
* (POST) Add a new round in Round table
*
* @param array $array array containing ID_GAME, PREVAILING_WIND ,SEED
* @return Response
*/
protected
function
newGame
(
$array
)
{
Game
::
createGame
(
$array
);
$message
=
json_encode
([
"message"
=>
'Game succesfully created!'
]);
$response
=
Response
::
createdResponse
(
$message
);
return
$response
;
}
}
\ No newline at end of file
BackEnd/src/model/Game.class.php
View file @
7573ddfb
...
...
@@ -21,4 +21,11 @@ class Game extends Model
return
$stm
->
fetchAll
();
}
public
static
function
createGame
(
$array
)
{
$begin_date
=
date
(
'Y-m-d H:i:s'
);
$pimped_array
=
array_merge
(
$array
,
[
'creation_time'
=>
$begin_date
]);
$stm
=
parent
::
exec
(
'GAME_CREATE'
,
$pimped_array
);
}
}
\ No newline at end of file
BackEnd/src/sql/Game.sql.php
View file @
7573ddfb
...
...
@@ -8,4 +8,10 @@ Game::addSqlQuery(
Game
::
addSqlQuery
(
'GAME_GET_WITH_ID'
,
'SELECT * FROM MJ_GAME WHERE ID_GAME=:id'
);
Game
::
addSqlQuery
(
'GAME_CREATE'
,
'INSERT INTO MJ_GAME (ID_GAME, PRIVATE, CREATION_TIME)
VALUES (NULL, :is_private, :creation_time)'
);
\ No newline at end of file
BackEnd/src/testRequests/gameRequest.http
View file @
7573ddfb
...
...
@@ -2,4 +2,11 @@
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
GET http://localhost/index.php/game/3
### Ouverture d'une game
POST http://localhost/index.php/game
{
"is_private": "1"
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment