package com.unicorn.hgzero.ai.biz.service;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.unicorn.hgzero.ai.biz.domain.ExtractedTodo;
import com.unicorn.hgzero.ai.biz.gateway.LlmGateway;
import com.unicorn.hgzero.ai.biz.usecase.TodoExtractionUseCase;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * Todo 자동 추출 Service
 * LLM 기반 액션 아이템 추출
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TodoExtractionService implements TodoExtractionUseCase {

    private final LlmGateway llmGateway;
    private final ObjectMapper objectMapper;

    @Override
    public List<ExtractedTodo> extractTodos(String meetingId, String minutesContent, String userId) {
        log.info("Extracting todos from minutes: meetingId={}, userId={}", meetingId, userId);

        // LLM을 통한 Todo 추출
        String llmResponse = llmGateway.extractTodos(minutesContent);

        // TODO: JSON 파싱 및 ExtractedTodo 리스트 생성
        // 현재는 mock 데이터 반환
        return List.of(
            ExtractedTodo.builder()
                .content("API 설계서 작성")
                .assignee("박민수")
                .dueDate(LocalDate.of(2025, 1, 30))
                .priority("HIGH")
                .sectionReference("결정사항 #3")
                .build()
        );
    }
}
