package com.jasamedika.medifirst2000.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.IntervensiDao;
import com.jasamedika.medifirst2000.service.IntervensiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.Intervensi;
import com.jasamedika.medifirst2000.vo.IntervensiVO;

@Service("IntervensiService")
public class IntervensiServiceImpl extends BaseVoServiceImpl implements IntervensiService {

	@Autowired
	private BaseConverterImpl<IntervensiVO, Intervensi> intervensiConverter; 
	
	@Autowired
	private IntervensiDao intervensiDao;
	
	@Override
	public Map<String, Object> saveIntervensi(IntervensiVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if(CommonUtil.isNotNullOrEmpty(vo))
		{
			Intervensi intervensi = intervensiConverter.transferVOToModel(vo, new Intervensi());
			if(CommonUtil.isNotNullOrEmpty(intervensi))
			{
				Intervensi model = intervensiDao.save(intervensi);
				result.put("id", model.getId());
			}
		}
		return result;
	}

}
