Package com.fyp.tauceti.controller
Class PlayerStatController
java.lang.Object
com.fyp.tauceti.controller.PlayerStatController
Spring Controller for interacting with the PLAYER_STAT database table through web APIs
-
Constructor Summary
ConstructorDescriptionPlayerStatController
(PlayerStatRepository repository, PlayerRepository playerRepository, GameRepository gameRepository) Paramterised Constructor -
Method Summary
Modifier and TypeMethodDescription"/player-stats" endpoint: Accepts GET requestsnewPlayerStat
(PlayerStat updatePlayerStat, UUID gameId, String playerTag) "/player-stats/update/{gameId}/{playerTag}" endpoint: Accepts POST requests to update an existing PlayerStat recordplayerStats
(UUID gameId, String playerTag) "/player-stats/{gameId}/{playerTag}" endpoing: Accepts GET requests for a single PlayerStat record
-
Constructor Details
-
PlayerStatController
public PlayerStatController(PlayerStatRepository repository, PlayerRepository playerRepository, GameRepository gameRepository) Paramterised Constructor- Parameters:
repository
- PlayerStatRepository object for CRUD operations on PLAYER_STAT database tableplayerRepository
- PlayerRepository object for CRUD operations on PLAYER database tablegameRepository
- GameRepository object for CRUD operations on GAME database table
-
-
Method Details
-
allPlayerStats
@CrossOrigin(origins="http://localhost:4200") @GetMapping("/player-stats") public List<PlayerStat> allPlayerStats()"/player-stats" endpoint: Accepts GET requests- Returns:
- List of all PlayerStat records in the database
-
playerStats
@CrossOrigin(origins="http://localhost:4200") @GetMapping("/player-stats/{gameId}/{playerTag}") public PlayerStat playerStats(@PathVariable UUID gameId, @PathVariable String playerTag) "/player-stats/{gameId}/{playerTag}" endpoing: Accepts GET requests for a single PlayerStat record- Parameters:
gameId
- The ID for a specific GameplayerTag
- The playerTag for a specific Player- Returns:
- A PlayerStat record for a single Player for a single Game
-
newPlayerStat
@CrossOrigin(origins="http://localhost:4200") @PostMapping("/player-stats/update/{gameId}/{playerTag}") public PlayerStat newPlayerStat(@RequestBody PlayerStat updatePlayerStat, @PathVariable UUID gameId, @PathVariable String playerTag) "/player-stats/update/{gameId}/{playerTag}" endpoint: Accepts POST requests to update an existing PlayerStat record- Parameters:
updatePlayerStat
- new PlayerStat values to be updatedgameId
- The ID for a specific gameplayerTag
- The playerTag for a specific Player- Returns:
- PlayerStat record that was updated or created in database
-