package com.zioinfo.kintex.system.syshealth;

import com.zioinfo.kintex.auth.KintexPrincipal;
import com.zioinfo.kintex.common.ApiResponse;
import com.zioinfo.kintex.system.SystemAccessGuard;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

/** 시스템관리 — 시스템 상태 대시보드 API. ADMIN 게이트(공개 /health 와 별개, 확장 지표). */
@RestController
@RequestMapping("/api/admin/system-health")
public class SystemHealthController {

    private final SystemHealthService service;
    private final SystemAccessGuard guard;

    public SystemHealthController(SystemHealthService service, SystemAccessGuard guard) {
        this.service = service;
        this.guard = guard;
    }

    @GetMapping
    public ApiResponse<SystemHealthDto> health(@AuthenticationPrincipal KintexPrincipal principal) {
        guard.requireAdmin(principal);
        return ApiResponse.ok(service.health());
    }
}
