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
7c262950
Commit
7c262950
authored
Dec 02, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added public game endpoint
parent
c1bd8146
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
0 deletions
+32
-0
GameController.class.php
BackEnd/src/controller/GameController.class.php
+16
-0
Game.class.php
BackEnd/src/model/Game.class.php
+6
-0
Game.sql.php
BackEnd/src/sql/Game.sql.php
+7
-0
gameRequest.http
BackEnd/src/testRequests/gameRequest.http
+3
-0
No files found.
BackEnd/src/controller/GameController.class.php
View file @
7c262950
<?php
// TODO : ID partie, Nom de la partie, nombres de joueurs déjà connectés
class
GameController
extends
Controller
{
...
...
@@ -21,6 +22,9 @@ class GameController extends Controller
case
'GET'
:
// If there is a uriParams, it is the /game/{id} endpoint
if
(
$uriParams
)
{
if
(
$uriParams
[
0
]
==
'public'
){
return
$this
->
getAllPublicGames
(
$uriParams
[
0
]);
}
return
$this
->
getGame
(
$uriParams
[
0
]);
}
// Else, it is the /game endpoint
...
...
@@ -59,6 +63,18 @@ class GameController extends Controller
return
$response
;
}
/**
* (GET) Get all games in Game table
*
* @return Response
*/
protected
function
getAllPublicGames
()
{
$games
=
Game
::
getListPublic
();
$response
=
Response
::
okResponse
(
json_encode
(
$games
,
JSON_PRETTY_PRINT
));
return
$response
;
}
/**
* (POST) Add a new game in Game table
*
...
...
BackEnd/src/model/Game.class.php
View file @
7c262950
...
...
@@ -15,6 +15,12 @@ class Game extends Model
return
$stm
->
fetchAll
();
}
public
static
function
getListPublic
()
{
$stm
=
parent
::
exec
(
'GAME_LIST_PUBLIC'
);
return
$stm
->
fetchAll
();
}
public
static
function
getRow
(
$id
)
{
$stm
=
parent
::
exec
(
'GAME_GET_WITH_ID'
,
[
'id'
=>
$id
]);
...
...
BackEnd/src/sql/Game.sql.php
View file @
7c262950
...
...
@@ -5,6 +5,13 @@ Game::addSqlQuery(
'SELECT * FROM MJ_GAME'
);
Game
::
addSqlQuery
(
'GAME_LIST_PUBLIC'
,
'SELECT g.ID_GAME
FROM MJ_GAME as g
WHERE g.PRIVATE=0'
);
Game
::
addSqlQuery
(
'GAME_GET_WITH_ID'
,
'SELECT * FROM MJ_GAME WHERE ID_GAME=:id'
...
...
BackEnd/src/testRequests/gameRequest.http
View file @
7c262950
...
...
@@ -4,6 +4,9 @@ GET http://localhost/index.php/game
### Récupérer la game avec id 3
GET http://localhost/index.php/game/3
### Récupérer toutes les games publiques
GET http://localhost/index.php/game/public
### Ouverture d'une game
POST http://localhost/index.php/game
...
...
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