package com.its.op.service.its.scrs;

import com.its.op.dao.repository.its.scrs.TbScSgnlIxrOperHsRepository;
import com.its.op.dto.its.scrs.TbScSgnlIxrOperHsDto;
import com.its.op.entity.its.scrs.TbScSgnlIxrOperHs;
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 TbScSgnlIxrOperHsService {

    private final TbScSgnlIxrOperHsRepository repo;

    public List<TbScSgnlIxrOperHsDto> findAllByDateRange(Integer sgnlIxrNmbr, String fromDt, String toDt) {
        List<TbScSgnlIxrOperHsDto> result = new ArrayList<>();
        List<TbScSgnlIxrOperHs> data = this.repo.findAllByDateRange(sgnlIxrNmbr, fromDt, toDt);
        if (data != null) {
            data.forEach(obj -> {
                result.add(obj.toDto());
            });
        }
        return result;
    }

}
