first implementation

This commit is contained in:
Adrien
2026-03-31 20:58:47 +02:00
parent dc0bcab36e
commit 618e28b354
1878 changed files with 1381732 additions and 5 deletions
@@ -0,0 +1,35 @@
package com.aiteacher.topic;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.NoSuchElementException;
@RestController
@RequestMapping("/api/v1/topics")
public class TopicController {
private final TopicConfigLoader topicConfigLoader;
private final TopicSummaryService topicSummaryService;
public TopicController(TopicConfigLoader topicConfigLoader,
TopicSummaryService topicSummaryService) {
this.topicConfigLoader = topicConfigLoader;
this.topicSummaryService = topicSummaryService;
}
@GetMapping
public ResponseEntity<List<Topic>> list() {
return ResponseEntity.ok(topicConfigLoader.getAll());
}
@PostMapping("/{id}/summary")
public ResponseEntity<TopicSummaryResponse> generateSummary(@PathVariable String id) {
Topic topic = topicConfigLoader.findById(id)
.orElseThrow(() -> new NoSuchElementException("Topic not found."));
TopicSummaryResponse response = topicSummaryService.generateSummary(topic);
return ResponseEntity.ok(response);
}
}