package ru.soune.nocopy.handler;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import ru.soune.nocopy.dto.BaseRequest;
import ru.soune.nocopy.dto.BaseResponse;
import ru.soune.nocopy.dto.MessageCode;
import ru.soune.nocopy.dto.statistic.IncomeStatisticResponse;
import ru.soune.nocopy.service.statistic.IncomeStatisticService;

@Component
@RequiredArgsConstructor
@Slf4j
public class StatisticIncomeHandler implements RequestHandler {

    private final IncomeStatisticService statisticService;

    @Override
    public BaseResponse handle(BaseRequest request) throws Exception {
        IncomeStatisticResponse statistics = statisticService.getIncomeStatistics();

        return new BaseResponse(
                request.getMsgId(),
                MessageCode.SUCCESS.getCode(),
                MessageCode.SUCCESS.getDescription(),
                statistics
        );
    }
}
