package com.its.api.its.service.road;

import com.its.api.its.model.dto.road.TbRoadTrafHsDto;
import com.its.api.its.model.entity.road.TbRoadTrafHs;
import com.its.api.its.repository.road.TbRoadTrafHsRepository;
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 TbRoadTrafHsService {

    private final TbRoadTrafHsRepository repo;

    public List<TbRoadTrafHsDto> findAllByDateRange(Long ROAD_ID, String fromDt, String toDt) {

        List<TbRoadTrafHsDto> result = new ArrayList<>();
        List<TbRoadTrafHs> data = repo.findAllByDateRange(ROAD_ID, fromDt, toDt);
        for (TbRoadTrafHs obj : data) {
            result.add(obj.toDto());
        }
        return result;
        /*Map<String, String> param = new HashMap<>();
        param.put("ROAD_ID", String.valueOf(ROAD_ID));
        param.put("FROM_DT", fromDt);
        param.put("TO_DT", toDt);
        return mapper.findAllByDateRange(param);*/
    }

}
