package com.lingyue.extract.controller;

import com.lingyue.common.domain.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 健康检查控制器
 * 
 * @author lingyue
 * @since 2026-01-22
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/extract")
@Tag(name = "数据提取服务", description = "数据提取规则系统 API")
public class HealthController {
    
    /**
     * 健康检查
     */
    @GetMapping("/health")
    @Operation(summary = "健康检查", description = "检查数据提取服务是否正常运行")
    public AjaxResult<?> health() {
        Map<String, Object> info = new HashMap<>();
        info.put("service", "extract-service");
        info.put("status", "UP");
        info.put("timestamp", LocalDateTime.now().toString());
        info.put("version", "1.0.0");
        
        return AjaxResult.success("服务正常", info);
    }
    
    /**
     * 服务信息
     */
    @GetMapping("/info")
    @Operation(summary = "服务信息", description = "获取数据提取服务的基本信息")
    public AjaxResult<?> info() {
        Map<String, Object> info = new HashMap<>();
        info.put("name", "Extract Service");
        info.put("description", "数据提取规则服务 - 项目管理、规则配置、内容提取");
        info.put("version", "1.0.0");
        info.put("features", new String[]{
            "项目管理 (Project)",
            "来源文档管理 (SourceDocument)",
            "提取规则配置 (ExtractRule)",
            "内容定位 (ContentLocator)",
            "AI 提取 (AIExtract)",
            "结果管理 (ExtractResult)",
            "规则模板 (RuleTemplate)"
        });
        
        return AjaxResult.success(info);
    }
}
