package com.its.op.service.its.vds;

import com.its.op.dao.repository.its.vds.TbVdsDtctClctRepository;
import com.its.op.dto.its.vds.TbVdsDtctClctDto;
import com.its.op.entity.its.vds.TbVdsDtctClct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

@Slf4j
@RequiredArgsConstructor
@Service
public class TbVdsDtctClctService {

    private final TbVdsDtctClctRepository repo;

    // 이력 데이터 조회
    @Transactional(readOnly = true)
    public List<TbVdsDtctClctDto> findAllByDateRange(String fromDt, String toDt, List<Long> ids) {
        List<TbVdsDtctClctDto> result = new ArrayList<>();
        List<TbVdsDtctClct>  data = this.repo.findAllByDateRange(fromDt, toDt, ids);
        if (data != null) {
            data.forEach(obj -> {
                result.add(obj.toDto());
            });
        }
        return result;
    }
}
