package com.pharmacopoeia.controller;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.Map;

@RestController
@RequestMapping("/api/v1/exam/qa")
public class ExamQaController {

    @PostMapping("/ask")
    public ResponseEntity<Map<String, Object>> examAsk(@RequestBody Map<String, String> req) {
        return ResponseEntity.ok(Map.of(
                "answer", "待考试知识库构建后可用",
                "sources", java.util.Collections.emptyList()
        ));
    }

    @PostMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<ServerSentEvent<String>> examStream(@RequestBody Map<String, String> req) {
        return Flux.just(
                ServerSentEvent.<String>builder()
                        .data("待考试知识库构建后可用")
                        .build(),
                ServerSentEvent.<String>builder()
                        .data("[DONE]")
                        .build()
        );
    }
}
