package com.its.api.its.service.oper;

import com.its.api.its.model.dto.oper.TbUserCnncHsDto;
import com.its.api.its.model.entity.oper.TbUserCnncHs;
import com.its.api.its.repository.oper.TbUserCnncHsRepository;
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 TbUserCnncHsService {

    private final TbUserCnncHsRepository repo;

    public List<TbUserCnncHsDto> findAllByDateRange(String from_dt, String to_dt) {
        List<TbUserCnncHsDto> result = new ArrayList<>();
        List<TbUserCnncHs> data = repo.findAllByDateRange(from_dt, to_dt);
        if (data != null) {
            data.forEach(obj -> {
                result.add(obj.toDto());
            });
        }
        return result;
    }
}
