package com.its.api.bis.service;

import com.its.api.bis.model.dto.BisProcessStatusHistoryDto;
import com.its.api.bis.model.entity.BisProcessStatusHistory;
import com.its.api.bis.repository.BisProcessStatusHistoryRepository;
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 BisProcessStatusHistoryService {

    private final BisProcessStatusHistoryRepository repo;

    // 전체 데이터 조회
    @Transactional(readOnly = true)
    public List<BisProcessStatusHistoryDto> findAll() {
        List<BisProcessStatusHistoryDto> result = new ArrayList<>();
        List<BisProcessStatusHistory> data = this.repo.findAll();
        for (BisProcessStatusHistory entity : data) {
            result.add(entity.toDto());
        }
        return result;
    }

}
