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.JenisResponDao;
import com.jasamedika.medifirst2000.entities.JenisRespon;
import com.jasamedika.medifirst2000.entities.JenisRespon;
import com.jasamedika.medifirst2000.service.JenisResponService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.JenisResponVO;

@Service("JenisResponService")
public class JenisResponServiceImpl extends BaseVoServiceImpl implements JenisResponService {
	
	@Autowired
	private BaseConverterImpl<JenisResponVO, JenisRespon> jenisResponConverter; 
	
	@Autowired
	private JenisResponDao jenisResponDao;

	@Override
	public Map<String, Object> saveJenisRespon(JenisResponVO vo) {
		
		Map<String, Object> result = new HashMap<String, Object>();
		if(CommonUtil.isNotNullOrEmpty(vo))
		{
			JenisRespon jenisRespon = jenisResponConverter.transferVOToModel(vo, new JenisRespon());
			if(CommonUtil.isNotNullOrEmpty(jenisRespon))
			{
				JenisRespon model = jenisResponDao.save(jenisRespon);
				result.put("id", model.getId());
			}
		}
		return result;
	}

}
