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

import com.its.op.dao.repository.its.scrs.TbScIxrCmraSttsHsRepository;
import com.its.op.dto.its.scrs.TbScIxrCmraSttsHsDto;
import com.its.op.entity.its.scrs.TbScIxrCmraSttsHs;
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 TbScIxrCmraSttsHsService {

    private final TbScIxrCmraSttsHsRepository repo;

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

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

}
