package com.zioinfo.hrm.ai;

import com.zioinfo.hrm.common.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * AI 인사 분석 — Ollama 온프레미스 AI 전용. 외부 AI API 절대 금지.
 * 이직 예측, 성과 예측, 채용 추천, 조직 건강 진단.
 */
@RestController
@RequestMapping("/api/hrm/ai")
@RequiredArgsConstructor
public class AiController {

    private final AiService aiService;

    @GetMapping("/turnover-prediction/{empId}")
    public ApiResponse<Map<String, Object>> turnoverPrediction(@PathVariable Long empId) {
        return ApiResponse.ok(aiService.predictTurnover(empId));
    }

    @GetMapping("/performance-prediction/{empId}")
    public ApiResponse<Map<String, Object>> performancePrediction(@PathVariable Long empId) {
        return ApiResponse.ok(aiService.predictPerformance(empId));
    }

    @PostMapping("/recruitment-recommendation")
    public ApiResponse<Map<String, Object>> recruitmentRecommendation(@RequestBody Map<String, Object> criteria) {
        return ApiResponse.ok(aiService.recommendRecruitment(criteria));
    }

    @GetMapping("/org-health")
    public ApiResponse<Map<String, Object>> orgHealth(@RequestParam(required = false) Long deptId) {
        return ApiResponse.ok(aiService.analyzeOrgHealth(deptId));
    }

    @PostMapping("/analyze-resume")
    public ApiResponse<Map<String, Object>> analyzeResume(@RequestBody Map<String, Object> resume) {
        return ApiResponse.ok(aiService.analyzeResume(resume));
    }

    @GetMapping("/insights")
    public ApiResponse<Map<String, Object>> hrInsights() {
        return ApiResponse.ok(aiService.getHrInsights());
    }
}
