Added basic CRUD operations

This commit is contained in:
2025-12-11 19:07:30 +01:00
parent 7c93577132
commit 46f2cf2d55
30 changed files with 615 additions and 139 deletions

View File

@@ -1,8 +1,8 @@
package be.naaturel.boardmateapi.controllers;
import be.naaturel.boardmateapi.models.Move;
import be.naaturel.boardmateapi.models.Party;
import be.naaturel.boardmateapi.services.PartyService;
import be.naaturel.boardmateapi.common.models.Move;
import be.naaturel.boardmateapi.common.models.Game;
import be.naaturel.boardmateapi.services.GameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -11,18 +11,16 @@ import org.springframework.web.bind.annotation.*;
@RestController
public class PartyController {
private final PartyService service;
private final GameService service;
@Autowired
public PartyController(PartyService service){
public PartyController(GameService service){
this.service = service;
}
@GetMapping("/party/{id}")
public ResponseEntity<?> RetrieveParty(@PathVariable String id){
@GetMapping("/games/")
public ResponseEntity<?> retrieveAllGames(){
try{
service.retrieveParty(id);
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.build();
@@ -31,10 +29,23 @@ public class PartyController {
}
}
@PostMapping("/create")
public ResponseEntity<?> CreateParty(@RequestBody Party party){
@GetMapping("/games/{id}")
public ResponseEntity<Game> retrieveGames(@PathVariable String id){
try{
service.create();
Game g = service.retrieveGame(id);
return ResponseEntity
.status(HttpStatus.OK)
.body(g);
} catch (Exception e){
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
@PostMapping("/create")
public ResponseEntity<?> CreateParty(@RequestBody Game game){
try{
service.create(game);
return ResponseEntity.
status(HttpStatus.INTERNAL_SERVER_ERROR)
@@ -45,9 +56,9 @@ public class PartyController {
}
@PostMapping("/moves/add")
public ResponseEntity<?> AddMove(@RequestBody Move move){
public ResponseEntity<?> AddMove(@RequestBody String gameId, @RequestBody Move move){
try{
service.addMove();
service.addMove(gameId, move);
return ResponseEntity
.status(HttpStatus.OK)