import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
public class DriverController
{
private final EndlessConsumer consumer;
- private final KeyCountingRecordHandler keyCountingRecordHandler;
+ private final WordcountRecordHandler wordcount;
@PostMapping("start")
@GetMapping("seen")
- public Map<Integer, Map<String, Long>> seen()
+ public Map<Integer, Map<String, Map<String, Long>>> seen()
{
- return keyCountingRecordHandler.getSeen();
+ return wordcount.getSeen();
+ }
+
+ @GetMapping("seen/{user}")
+ public ResponseEntity<Map<String, Long>> seen(@PathVariable String user)
+ {
+ for (Map<String, Map<String, Long>> users : wordcount.getSeen().values())
+ {
+ Map<String, Long> words = users.get(user);
+ if (words != null)
+ return ResponseEntity.ok(words);
+ }
+
+ return ResponseEntity.notFound().build();
}