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
d186a97c
Commit
d186a97c
authored
Nov 25, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added post
parent
0aaf1c25
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
UserController.class.php
BackEnd/src/controller/UserController.class.php
+22
-4
User.class.php
BackEnd/src/model/User.class.php
+6
-0
User.sql.php
BackEnd/src/sql/User.sql.php
+2
-1
No files found.
BackEnd/src/controller/UserController.class.php
View file @
d186a97c
...
...
@@ -33,6 +33,10 @@ class UserController extends Controller
return
$this
->
updateUser
(
array_merge
(
$body
,
[
'id'
=>
$uriParams
[
0
]]));
}
break
;
case
'POST'
:
$body
=
$this
->
request
->
getData
();
return
$this
->
addUser
(
$body
);
break
;
}
$message
=
json_encode
([
"message"
=>
"unsupported parameters or method in users"
]);
return
Response
::
errorResponse
(
$message
);
...
...
@@ -63,7 +67,7 @@ class UserController extends Controller
}
/**
*
GET
all users in USER table
*
(GET) Get
all users in USER table
*
* @return Response
*/
...
...
@@ -75,7 +79,7 @@ class UserController extends Controller
}
/**
*
GET
a specific user in USER table based on id
*
(GET) Get
a specific user in USER table based on id
*
* @param int $id id of the User
* @return Response
...
...
@@ -88,7 +92,21 @@ class UserController extends Controller
}
/**
* Update a specific user in USER table based on id
* (POST) Add a specific user in USER table
*
* @param array $array array containing
* @return Response
*/
protected
function
addUser
(
$array
)
{
User
::
addRow
(
$array
);
$message
=
json_encode
([
"message"
=>
'User succesfully added!'
]);
$response
=
Response
::
okResponse
(
json_encode
(
$message
));
return
$response
;
}
/**
* (PUT) Update a specific user in USER table based on id
*
* @param array $array array containing id + fields to modify
* @return Response
...
...
@@ -103,7 +121,7 @@ class UserController extends Controller
// Update phase
User
::
updateUser
(
$array
);
$message
=
json_encode
([
"message"
=>
'User succesfully updated
!'
]);
$message
=
json_encode
([
"message"
=>
'User succesfully updated!'
]);
$response
=
Response
::
okResponse
(
$message
);
return
$response
;
...
...
BackEnd/src/model/User.class.php
View file @
d186a97c
...
...
@@ -20,6 +20,12 @@ class User extends Model
return
$stm
->
fetchAll
();
}
public
static
function
addRow
(
$array
)
{
//print_r($array); die();
$stm
=
parent
::
exec
(
'USER_CREATE'
,
$array
);
}
public
static
function
updateUser
(
$array
)
{
$stm
=
parent
::
exec
(
'USER_UPDATE'
,
$array
);
...
...
BackEnd/src/sql/User.sql.php
View file @
d186a97c
...
...
@@ -18,7 +18,8 @@ User::addSqlQuery(
//TODO
User
::
addSqlQuery
(
'USER_CREATE'
,
'INSERT INTO MJ_USER (USER_ID, USER_LOGIN, USER_EMAIL, USER_ROLE, USER_PASSWORD, USER_NAME, USER_SURNAME) VALUES (NULL, :login, :email, :role, :pwd, :name, :surname)'
'INSERT INTO MJ_USER (ID_USER ,ID_ROLE ,LOGIN ,PASWORD ,AVATAR ,LASTNAME ,FIRSTNAME ,MAIL ,BAN_ACCOUNT ,LAST_IP)
VALUES (NULL, 1, :login, :pwd, :avatar, :lastname, :firstname, :mail, false, NULL)'
);
User
::
addSqlQuery
(
...
...
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