Commit 1dd21c4d authored by Marek Kadlečík's avatar Marek Kadlečík
Browse files

Added edit operation to rest api

parent 48eff7cf
Pipeline #142469 passed with stage
in 1 minute and 30 seconds
...@@ -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
......
...@@ -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 {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment