package com.its.op.service.its.vms;

import com.its.op.dao.repository.its.vms.TbVmsFormTypeRepository;
import com.its.op.dto.its.vms.TbVmsFormTypeDto;
import com.its.op.entity.its.vms.TbVmsFormType;
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 TbVmsFormTypeService {

    private final TbVmsFormTypeRepository repo;

    // 전체 데이터 조회
    @Transactional(readOnly = true)
    public List<TbVmsFormTypeDto> findAll() {
        List<TbVmsFormTypeDto> result = new ArrayList<>();
        List<TbVmsFormType> data = this.repo.findAll();
        data.forEach(obj -> {
            if (("Y").equals(obj.getUseYn())) {
                result.add(obj.toDto());
            }
        });
        return result;
    }

}
