package com.jasamedika.medifirst2000.service.impl;

import com.jasamedika.medifirst2000.converter.base.BaseVoConverter;
import com.jasamedika.medifirst2000.entities.JenisLog;
import com.jasamedika.medifirst2000.dao.JenisLogDao;
import com.jasamedika.medifirst2000.service.JenisLogService;
import com.jasamedika.medifirst2000.vo.JenisLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Salman
 * @version 1.0.0
 * @since 02/02/2024
 */
@Service
@Transactional
public class JenisLogServiceImpl implements JenisLogService {

    @Autowired
    private BaseVoConverter<JenisLogVO, JenisLog> jenisLogVoConverter;

    @Autowired
    private JenisLogDao jenisLogDao;

    @Override
    public void save(List<JenisLogVO> vos) {
        List<JenisLog> entities = new ArrayList<>();
        vos.forEach(vo -> {
            JenisLog entity = jenisLogVoConverter.transferVOToModel(vo, new JenisLog());
            entities.add(entity);
        });
        jenisLogDao.save(entities);
    }
}
