forked from aws-samples/eb-java-scorekeep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStateController.java
More file actions
34 lines (31 loc) · 1.55 KB
/
Copy pathStateController.java
File metadata and controls
34 lines (31 loc) · 1.55 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
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/state/{sessionId}/{gameId}")
public class StateController {
private final StateFactory stateFactory = new StateFactory();
private final StateModel model = new StateModel();
private final GameController gameController = new GameController();
/* GET /state/SESSION/GAME */
@RequestMapping(method=RequestMethod.GET)
public List<State> getStates(@PathVariable String sessionId, @PathVariable String gameId) throws SessionNotFoundException, GameNotFoundException {
return stateFactory.getStates(sessionId, gameId);
}
/* GET /state/SESSION/GAME/STATE */
@RequestMapping(value="/{stateId}", method=RequestMethod.GET)
public State getState(@PathVariable String sessionId, @PathVariable String gameId, @PathVariable String stateId) throws SessionNotFoundException, GameNotFoundException, StateNotFoundException {
return stateFactory.getState(sessionId, gameId, stateId);
}
}