import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
{
private final EndlessConsumer consumer;
private final ApplicationRecordHandler recordHandler;
+ private final AdderResults results;
@PostMapping("start")
@GetMapping("state")
- public Map<Integer, Map<String, Long>> state()
+ public Map<Integer, Map<String, AdderResult>> state()
{
return
recordHandler
}
@GetMapping("state/{user}")
- public ResponseEntity<Long> seen(@PathVariable String user)
+ public ResponseEntity<Long> state(@PathVariable String user)
{
for (AdderBusinessLogic adder : recordHandler.getState().values())
{
return ResponseEntity.notFound().build();
}
+ @GetMapping("results")
+ public Map<Integer, Map<String, List<AdderResult>>> results()
+ {
+ return results.getState();
+ }
+
+ @GetMapping("results/{user}")
+ public ResponseEntity<List<AdderResult>> results(@PathVariable String user)
+ {
+ for (Map<String, List<AdderResult>> resultsByUser : this.results.getState().values())
+ {
+ List<AdderResult> results = resultsByUser.get(user);
+ if (results != null)
+ return ResponseEntity.ok(results);
+ }
+
+ return ResponseEntity.notFound().build();
+ }
+
@ExceptionHandler
@ResponseStatus(HttpStatus.BAD_REQUEST)