import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
@RestController
}
- @GetMapping("seen")
- public Map<Integer, Map<String, List<Long>>> seen()
+ @GetMapping("state")
+ public Map<Integer, Map<String, Long>> state()
{
- return sumRecordHandler.getSeen();
+ return
+ sumRecordHandler
+ .getState()
+ .entrySet()
+ .stream()
+ .collect(Collectors.toMap(
+ entry -> entry.getKey(),
+ entry -> entry.getValue().getState()));
}
- @GetMapping("seen/{user}")
- public ResponseEntity<List<Long>> seen(@PathVariable String user)
+ @GetMapping("state/{user}")
+ public ResponseEntity<Long> seen(@PathVariable String user)
{
- for (Map<String, List<Long>> users : sumRecordHandler.getSeen().values())
+ for (SumBusinessLogic sumBusinessLogic : sumRecordHandler.getState().values())
{
- List<Long> results = users.get(user);
- if (results != null)
- return ResponseEntity.ok(results);
+ Optional<Long> sum = sumBusinessLogic.getSum(user);
+ if (sum.isPresent())
+ return ResponseEntity.ok(sum.get());
}
return ResponseEntity.notFound().build();