forked from aws-samples/eb-java-scorekeep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveController.java
More file actions
38 lines (36 loc) · 1.94 KB
/
Copy pathMoveController.java
File metadata and controls
38 lines (36 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package scorekeep;
import java.util.concurrent.atomic.AtomicLong;
import java.util.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.lang.Long;
import java.lang.NumberFormatException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
@RestController
@RequestMapping(value="/api/move/{sessionId}/{gameId}")
public class MoveController {
private final MoveFactory moveFactory = new MoveFactory();
private final MoveModel model = new MoveModel();
private final GameController gameController = new GameController();
/* GET /move/SESSION/GAME */
@RequestMapping(method=RequestMethod.GET)
public List<Move> getMoves(@PathVariable String sessionId, @PathVariable String gameId) throws SessionNotFoundException, GameNotFoundException {
return moveFactory.getMoves(sessionId, gameId);
}
/* POST /move/SESSION/GAME/USER ; move string */
@RequestMapping(value="/{userId}", method=RequestMethod.POST)
public Move newMove(@PathVariable String sessionId, @PathVariable String gameId, @PathVariable String userId, @RequestBody String move) throws SessionNotFoundException, GameNotFoundException, StateNotFoundException, RulesException {
return moveFactory.newMove(sessionId, gameId, userId, move);
}
/** GET /move/SESSION/GAME/MOVE **/
@RequestMapping(value="/{moveId}", method=RequestMethod.GET)
public Move getMove(@PathVariable String sessionId, @PathVariable String gameId, @PathVariable String moveId) throws SessionNotFoundException, GameNotFoundException, MoveNotFoundException {
return moveFactory.getMove(sessionId, gameId, moveId);
}
}