package com.its.api.its.service.link;

import com.its.api.its.model.dto.link.TbLinkTrafHsDto;
import com.its.api.its.model.entity.link.TbLinkTrafHs;
import com.its.api.its.repository.link.TbLinkTrafHsRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Service
public class TbLinkTrafHsService {

    private final TbLinkTrafHsRepository repo;

    public List<TbLinkTrafHsDto> findAllByDateRange(Long LINK_ID, String fromDt, String toDt) {

        List<TbLinkTrafHsDto> result = new ArrayList<>();
        List<TbLinkTrafHs> data = repo.findAllByDateRange(LINK_ID, fromDt, toDt);
        for (TbLinkTrafHs obj : data) {
            result.add(obj.toDto());
        }
        return result;
    }

}
