initial commit

This commit is contained in:
Lee
2024-04-06 04:10:15 +01:00
commit f68d941dc8
19 changed files with 748 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package cc.fascinated.api.controller;
import cc.fascinated.player.PlayerManagerService;
import cc.fascinated.player.impl.Player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public class PlayerController {
private final PlayerManagerService playerManagerService;
@Autowired
public PlayerController(PlayerManagerService playerManagerService) {
this.playerManagerService = playerManagerService;
}
@GetMapping("/{id}") @ResponseBody
public ResponseEntity<Player> getPlayer(@PathVariable String id) {
Player player = playerManagerService.getPlayer(id);
if (player == null) {
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(player);
}
}