Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Matúš Valko
Online Gaming Management System
Commits
1dd21c4d
Commit
1dd21c4d
authored
May 24, 2022
by
Marek Kadlečík
Browse files
Added edit operation to rest api
parent
48eff7cf
Pipeline
#142469
passed with stage
in 1 minute and 30 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
1dd21c4d
...
@@ -42,6 +42,11 @@ Find all players:
...
@@ -42,6 +42,11 @@ Find all players:
$
curl
-X
GET http://localhost:8080/pa165/rest/players
$
curl
-X
GET http://localhost:8080/pa165/rest/players
```
```
Update player:
```
bash
$
curl
-X
PUT
-i
-H
"Content-Type: application/json"
--data
'{"killStat":5, "deathStat":6, "assistStat":7}'
http://localhost:8080/pa165/rest/players/9384b466-badf-40ca-bbeb-4d8f6eb98042
```
Delete player:
Delete player:
```
bash
```
bash
$
curl
-X
DELETE http://localhost:8080/pa165/rest/players/9384b466-badf-40ca-bbeb-4d8f6eb98042
$
curl
-X
DELETE http://localhost:8080/pa165/rest/players/9384b466-badf-40ca-bbeb-4d8f6eb98042
...
...
gaming-rest/src/main/java/cz/muni/fi/pa165/rest/controllers/PlayerController.java
View file @
1dd21c4d
...
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
import
java.util.List
;
@RestController
@RestController
...
@@ -48,6 +49,16 @@ public class PlayerController {
...
@@ -48,6 +49,16 @@ public class PlayerController {
}
}
}
}
@RequestMapping
(
value
=
"/{uuid}"
,
method
=
RequestMethod
.
PUT
)
public
void
updateSteward
(
@PathVariable
(
"uuid"
)
String
uuid
,
@RequestBody
PlayerDTO
playerDTO
)
throws
ResourceNotFoundException
{
try
{
playerDTO
.
setId
(
uuid
);
playerFacade
.
editPlayer
(
playerDTO
);
}
catch
(
Exception
exception
)
{
throw
new
ResourceNotFoundException
();
}
}
@RequestMapping
(
value
=
"/{uuid}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
value
=
"/{uuid}"
,
method
=
RequestMethod
.
DELETE
)
public
final
void
delete
(
@PathVariable
(
"uuid"
)
String
uuid
)
throws
ResourceNotFoundException
{
public
final
void
delete
(
@PathVariable
(
"uuid"
)
String
uuid
)
throws
ResourceNotFoundException
{
try
{
try
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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