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
d52161c9
Commit
d52161c9
authored
Nov 30, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added methods for rounds
parent
86a384c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
0 deletions
+118
-0
RoundController.class.php
BackEnd/src/controller/RoundController.class.php
+69
-0
Round.class.php
BackEnd/src/model/Round.class.php
+29
-0
Round.sql.php
BackEnd/src/sql/Round.sql.php
+20
-0
No files found.
BackEnd/src/controller/RoundController.class.php
0 → 100644
View file @
d52161c9
<?php
class
RoundController
extends
Controller
{
public
function
__construct
(
$name
,
$request
)
{
parent
::
__construct
(
$name
,
$request
);
}
/**
* Process incoming request for the /round endpoint
*
* @return Response
*/
public
function
processRequest
()
{
$httpMethod
=
$this
->
request
->
getHttpMethod
();
$uriParams
=
$this
->
request
->
getUriParams
();
switch
(
$httpMethod
)
{
case
'GET'
:
// If there is a uriParams, it is the /round/{id} endpoint
if
(
$uriParams
)
{
return
$this
->
getUsersInRound
(
$uriParams
[
0
]);
}
// Else, it is the /round endpoint
return
$this
->
getAllRounds
();
break
;
}
$message
=
json_encode
([
"message"
=>
"unsupported parameters or method in round"
]);
return
Response
::
errorResponse
(
$message
);
}
/**
* (GET) Get all rounds in Round table
*
* @return Response
*/
protected
function
getAllRounds
()
{
$rounds
=
Round
::
getList
();
$response
=
Response
::
okResponse
(
json_encode
(
$rounds
,
JSON_PRETTY_PRINT
));
return
$response
;
}
/**
* (GET) Get a specific round in Round table based
*
* @return Response
*/
protected
function
getRound
(
$id
)
{
$rounds
=
Round
::
getRow
(
$id
);
$response
=
Response
::
okResponse
(
json_encode
(
$rounds
,
JSON_PRETTY_PRINT
));
return
$response
;
}
/**
* (GET) Get Users of the round $id
*
* @return Response
*/
protected
function
getUsersInRound
(
$id
)
{
$rounds
=
Round
::
getUsersInRound
(
$id
);
$response
=
Response
::
okResponse
(
json_encode
(
$rounds
,
JSON_PRETTY_PRINT
));
return
$response
;
}
}
\ No newline at end of file
BackEnd/src/model/Round.class.php
0 → 100644
View file @
d52161c9
<?php
class
Round
extends
Model
{
// ===========
// = Statics =
// ===========
protected
static
$table_name
=
'MJ_ROUND'
;
public
static
function
getList
()
{
$stm
=
parent
::
exec
(
'ROUND_LIST'
);
return
$stm
->
fetchAll
();
}
public
static
function
getRow
(
$id
)
{
$stm
=
parent
::
exec
(
'ROUND_GET_WITH_ID'
,
[
'id'
=>
$id
]);
return
$stm
->
fetchAll
();
}
public
static
function
getUsersInRound
(
$id
)
{
$stm
=
parent
::
exec
(
'ROUND_GET_USERS'
,
[
'id'
=>
$id
]);
return
$stm
->
fetchAll
();
}
}
\ No newline at end of file
BackEnd/src/sql/Round.sql.php
0 → 100644
View file @
d52161c9
<?php
Game
::
addSqlQuery
(
'ROUND_LIST'
,
'SELECT * FROM MJ_ROUND'
);
Game
::
addSqlQuery
(
'ROUND_GET_WITH_ID'
,
'SELECT * FROM MJ_ROUND WHERE ID_ROUND=:id'
);
Game
::
addSqlQuery
(
'ROUND_GET_USERS'
,
'SELECT *
FROM MJ_USER as usr
JOIN MJ_PLAY as p on p.ID_USER = usr.ID_USER
JOIN MJ_ROUND as r on r.ID_ROUND = p.ID_ROUND
WHERE r.ID_ROUND=:id'
);
\ 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