package com.zioinfo.hrm.integration;

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

import java.util.Map;

/**
 * ITSM / ERP / Groupware 연계 API.
 * 보안 불변: 자격증명/PII 응답 미노출.
 */
@RestController
@RequestMapping("/api/hrm/integration")
@RequiredArgsConstructor
public class IntegrationController {

    private final IntegrationService integrationService;

    @GetMapping("/itsm/health")
    public ApiResponse<Map<String, Object>> itsmHealth() {
        return ApiResponse.ok(integrationService.checkItsm());
    }

    @GetMapping("/erp/payroll-sync/{year}/{month}")
    public ApiResponse<Map<String, Object>> syncPayrollToErp(
            @PathVariable int year, @PathVariable int month) {
        return ApiResponse.ok(integrationService.syncPayrollToErp(year, month));
    }

    @GetMapping("/groupware/leave-sync/{empId}")
    public ApiResponse<Map<String, Object>> syncLeaveToGroupware(@PathVariable Long empId) {
        return ApiResponse.ok(integrationService.syncLeaveToGroupware(empId));
    }
}
