|
|
@@ -0,0 +1,30 @@
|
|
|
+package pl.dmss.vmaneliuk.database.controllers;
|
|
|
+
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import pl.dmss.vmaneliuk.database.model.Game;
|
|
|
+import pl.dmss.vmaneliuk.database.services.GameService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/games")
|
|
|
+public class GameController {
|
|
|
+
|
|
|
+ private final GameService gameService;
|
|
|
+
|
|
|
+ public GameController(GameService gameService) {
|
|
|
+ this.gameService = gameService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping
|
|
|
+ public ResponseEntity<List<Game>> getAllGames() {
|
|
|
+ return ResponseEntity.ok(gameService.getAllGames());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ public ResponseEntity<Game> createGame(@RequestBody Game game) {
|
|
|
+ Game savedGame = gameService.createGame(game);
|
|
|
+ return ResponseEntity.ok(savedGame);
|
|
|
+ }
|
|
|
+}
|