package com.ga.api.service.report;

import com.ga.core.mapper.report.ReportMapper;
import com.ga.core.vo.report.ChargebackRiskRow;
import com.ga.core.vo.report.OrgReportRow;
import com.ga.core.vo.report.PerfReportRow;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.cursor.Cursor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 리포트 서비스 — 기존 정산 데이터 위 읽기전용 집계.
 * Cursor 변형은 엑셀 export 용 (ExcelService.exportLargeExcel 가 트랜잭션 내에서 소비).
 */
@Service
@RequiredArgsConstructor
public class ReportService {

    private final ReportMapper mapper;

    @Transactional(readOnly = true)
    public List<PerfReportRow> performance(String year) {
        return mapper.selectPerformance(year);
    }

    public Cursor<PerfReportRow> performanceCursor(String year) {
        return mapper.selectPerformanceCursor(year);
    }

    @Transactional(readOnly = true)
    public List<OrgReportRow> org(String settleMonth) {
        return mapper.selectOrg(settleMonth);
    }

    public Cursor<OrgReportRow> orgCursor(String settleMonth) {
        return mapper.selectOrgCursor(settleMonth);
    }

    @Transactional(readOnly = true)
    public List<ChargebackRiskRow> chargebackRisk() {
        return mapper.selectChargebackRisk();
    }

    public Cursor<ChargebackRiskRow> chargebackRiskCursor() {
        return mapper.selectChargebackRiskCursor();
    }
}
