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
08e3e181
Commit
08e3e181
authored
Nov 30, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can add round
parent
a92a0e42
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
RoundController.class.php
BackEnd/src/controller/RoundController.class.php
+20
-0
Round.class.php
BackEnd/src/model/Round.class.php
+8
-0
Round.sql.php
BackEnd/src/sql/Round.sql.php
+6
-0
No files found.
BackEnd/src/controller/RoundController.class.php
View file @
08e3e181
...
@@ -32,6 +32,10 @@ class RoundController extends Controller
...
@@ -32,6 +32,10 @@ class RoundController extends Controller
// If there is no uriParams, it is the /round endpoint
// If there is no uriParams, it is the /round endpoint
return
$this
->
getAllRounds
();
return
$this
->
getAllRounds
();
break
;
break
;
case
'POST'
:
$body
=
$this
->
request
->
getData
();
return
$this
->
newRound
(
$body
);
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
);
...
@@ -72,4 +76,20 @@ class RoundController extends Controller
...
@@ -72,4 +76,20 @@ class RoundController extends Controller
$response
=
Response
::
okResponse
(
json_encode
(
$rounds
,
JSON_PRETTY_PRINT
));
$response
=
Response
::
okResponse
(
json_encode
(
$rounds
,
JSON_PRETTY_PRINT
));
return
$response
;
return
$response
;
}
}
/**
* (POST) Add a new round in Round table
*
* @param array $array array containing ID_GAME, PREVAILING_WIND ,SEED
* @return Response
*/
protected
function
newRound
(
$array
)
{
Round
::
createRound
(
$array
);
$message
=
json_encode
([
"message"
=>
'Round succesfully created!'
]);
$response
=
Response
::
createdResponse
(
$message
);
return
$response
;
}
}
}
\ No newline at end of file
BackEnd/src/model/Round.class.php
View file @
08e3e181
...
@@ -26,4 +26,12 @@ class Round extends Model
...
@@ -26,4 +26,12 @@ class Round extends Model
$stm
=
parent
::
exec
(
'ROUND_GET_USERS'
,
[
'id'
=>
$id
]);
$stm
=
parent
::
exec
(
'ROUND_GET_USERS'
,
[
'id'
=>
$id
]);
return
$stm
->
fetchAll
();
return
$stm
->
fetchAll
();
}
}
public
static
function
createRound
(
$array
)
{
$begin_date
=
date
(
'Y-m-d H:i:s'
);
$pimped_array
=
array_merge
(
$array
,
[
'begin_date'
=>
$begin_date
]);
$stm
=
parent
::
exec
(
'ROUND_CREATE'
,
$pimped_array
);
}
}
}
\ No newline at end of file
BackEnd/src/sql/Round.sql.php
View file @
08e3e181
...
@@ -25,4 +25,10 @@ Game::addSqlQuery(
...
@@ -25,4 +25,10 @@ Game::addSqlQuery(
JOIN MJ_PLAY as p on p.ID_USER = usr.ID_USER
JOIN MJ_PLAY as p on p.ID_USER = usr.ID_USER
JOIN MJ_ROUND as r on r.ID_ROUND = p.ID_ROUND
JOIN MJ_ROUND as r on r.ID_ROUND = p.ID_ROUND
WHERE r.ID_ROUND=:id'
WHERE r.ID_ROUND=:id'
);
User
::
addSqlQuery
(
'ROUND_CREATE'
,
'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)'
);
);
\ 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