package com.jasamedika.medifirst2000.service.impl;

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

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

import com.jasamedika.medifirst2000.dao.TahapanRekrutmenTestDao;
import com.jasamedika.medifirst2000.dto.TahapanRekrutmenTestDto;
import com.jasamedika.medifirst2000.entities.Produk;
import com.jasamedika.medifirst2000.entities.TahapanRekrutmenTest;
import com.jasamedika.medifirst2000.service.TahapanRekrutmenTestService;

@Service("TahapanRekrutmenTestService")
public class TahapanRekrutmenTestServiceImpl extends BaseVoServiceImpl implements TahapanRekrutmenTestService {
	@Autowired
	private TahapanRekrutmenTestDao tahapanRekrutmenTestDao;
	
	@Override
	public Map<String,Object> save(TahapanRekrutmenTestDto dto) {
		Map<String,Object> map=new HashMap<String,Object>();
		TahapanRekrutmenTest tahapan=new TahapanRekrutmenTest();
		if(dto.getId()!=null)
			tahapan.setId(dto.getId());
		tahapan.setNoUrut(dto.getNoUrut());
		Produk produkRs=new Produk();
		produkRs.setId(dto.getProdukRsId());
		tahapan.setProdukRs(produkRs);
		TahapanRekrutmenTest result=tahapanRekrutmenTestDao.save(tahapan);
		map.put("id", result.getId());
		return map;
	}

	@Override
	public Map<String,Object> getById(Integer id) {
		Map<String,Object> tahapan=tahapanRekrutmenTestDao.findById(id);
		return tahapan;
	}

	@Override
	public Map<String,Object> getAll() {
		Map<String,Object> map=new HashMap<String,Object>();
		List<Map<String,Object>> listTahapan=tahapanRekrutmenTestDao.getAllData();
		map.put("data", listTahapan);
		map.put("maxUrut", tahapanRekrutmenTestDao.getMaxNoUrut()+1);
		return map;
	}
	

}
