Class GameController

java.lang.Object
com.fyp.tauceti.controller.GameController

@RestController public class GameController extends Object
Spring Controller for interacting with the GAME database table through web APIs
See Also:
  • Constructor Details

    • GameController

      public GameController(GameRepository repository)
      Parameterised Constructor
      Parameters:
      repository - GameRepository object for CRUD operations on GAME database table
  • Method Details

    • allGames

      @CrossOrigin(origins="http://localhost:4200") @GetMapping("/games") public List<Game> allGames()
      "/games" endpoint: Accepts GET requests
      Returns:
      A list of all Game records in database
    • newGame

      @CrossOrigin(origins="http://localhost:4200") @PostMapping("/games/new") public Game newGame(@RequestBody Game newGame)
      "/games/new" endpoint: Accepts POST request containing a Game object in body and saves it to the database
      Parameters:
      newGame - A Game object retrieved from the HTTP request body
      Returns:
      The saved Game object
    • deleteGame

      @DeleteMapping("/games/delete-game") public void deleteGame(@RequestBody Game game)
      "/games/delete-game" endpoint: Accepts DELETE request and removes a Game object from the database
      Parameters:
      game - The Game object to be deleted