package com.ga.api.controller.kpi;

import com.ga.api.service.kpi.KpiService;
import com.ga.common.annotation.RequirePermission;
import com.ga.common.model.ApiResponse;
import com.ga.common.model.PageResponse;
import com.ga.core.vo.kpi.KpiCumulativeResp;
import com.ga.core.vo.kpi.KpiMonthlySummaryResp;
import com.ga.core.vo.kpi.KpiOrgSummaryResp;
import com.ga.core.vo.kpi.KpiRetentionResp;
import com.ga.core.vo.kpi.KpiSearchParam;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "KPI 대시보드")
@RestController
@RequestMapping("/api/kpi")
@RequiredArgsConstructor
public class KpiController {

    private final KpiService service;

    @GetMapping("/monthly-summary")
    @RequirePermission(menu = "KPI_MONTHLY", perm = "READ")
    public ApiResponse<PageResponse<KpiMonthlySummaryResp>> monthlySummary(@ModelAttribute KpiSearchParam param) {
        return ApiResponse.ok(service.monthlySummary(param));
    }

    @GetMapping("/org-summary")
    @RequirePermission(menu = "KPI_ORG", perm = "READ")
    public ApiResponse<PageResponse<KpiOrgSummaryResp>> orgSummary(@ModelAttribute KpiSearchParam param) {
        return ApiResponse.ok(service.orgSummary(param));
    }

    @GetMapping("/retention")
    @RequirePermission(menu = "KPI_RETENTION", perm = "READ")
    public ApiResponse<PageResponse<KpiRetentionResp>> retention(@ModelAttribute KpiSearchParam param) {
        return ApiResponse.ok(service.retention(param));
    }

    @GetMapping("/cumulative")
    @RequirePermission(menu = "KPI_CUMULATIVE", perm = "READ")
    public ApiResponse<PageResponse<KpiCumulativeResp>> cumulative(@ModelAttribute KpiSearchParam param) {
        return ApiResponse.ok(service.cumulative(param));
    }
}
