package com.its.api.its.service.vms;

import com.its.api.its.model.dto.vms.VwVmsDsplPrstDto;
import com.its.api.its.model.entity.vms.VwVmsDsplPrst;
import com.its.api.its.repository.vms.VwVmsDsplPrstRepository;
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 VwVmsDsplPrstService {

    private final VwVmsDsplPrstRepository repo;

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

    public List<VwVmsDsplPrstDto> findByIdList(Long id) {
        List<VwVmsDsplPrstDto> result = new ArrayList<>();
        List<VwVmsDsplPrst> data = this.repo.findByIdList(id);
        for (VwVmsDsplPrst entity : data) {
            result.add(entity.toDto());
        }
        return result;
    }

}
