package com.ga.api.service.kpi;

import com.ga.common.model.PageResponse;
import com.ga.core.mapper.kpi.KpiMapper;
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 lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class KpiService {

    private final KpiMapper kpiMapper;

    public PageResponse<KpiMonthlySummaryResp> monthlySummary(KpiSearchParam param) {
        param.startPage();
        return PageResponse.of(kpiMapper.selectMonthlySummary(param));
    }

    public PageResponse<KpiOrgSummaryResp> orgSummary(KpiSearchParam param) {
        param.startPage();
        return PageResponse.of(kpiMapper.selectOrgSummary(param));
    }

    public PageResponse<KpiRetentionResp> retention(KpiSearchParam param) {
        param.startPage();
        return PageResponse.of(kpiMapper.selectRetention(param));
    }

    public PageResponse<KpiCumulativeResp> cumulative(KpiSearchParam param) {
        param.startPage();
        return PageResponse.of(kpiMapper.selectCumulative(param));
    }
}
