package com.eactive.eai.rms.onl.manage.serviceinfo.header;

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

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

@Service("hostHeaderService")
public class HostHeaderService {

	@Autowired
	@Qualifier("hostHeaderDao")
	private HostHeaderDao dao;
	
	public HashMap selectList(int startNum,int endNum,String eaiBizCode, String searchUbmugign) throws Exception {
		HashMap paramMap = new HashMap();
		//검색 조건 
		paramMap.put("eaiBizCode", eaiBizCode);
		paramMap.put("searchUbmugign", searchUbmugign);
		// 전체 목록수 얻기
		int totalCount = dao.selectListCount(paramMap);

		paramMap.put("startNum" , startNum);// 시작 record
		paramMap.put("endNum"   , endNum);// 끝 record

		List list = dao.selectList(paramMap);

		HashMap map = new HashMap();

		map.put("totalCount", totalCount);

		map.put("list", list);

		return map;
	}	

	public HashMap<String, Object> selectDetail(String eaiBizCode) throws Exception {

		HashMap paramMap = new HashMap();
		paramMap.put("eaiBizCode", eaiBizCode);
		return dao.selectDetail( paramMap);
	}	

	public void insert(HashMap<String,Object> paramMap) throws Exception {
		//1.중복체크
		paramMap.put("eaiBizCode", paramMap.get("eaiBizCode"));
		int dupChk = dao.selectListCount(paramMap);
		if (dupChk > 0) throw new Exception("이미 존재하는 HostHeader 입니다. - "+ paramMap.get("eaiBizCode"));
		
		dao.insert(paramMap);
	}
	
	public void update(HashMap<String,Object> paramMap) throws Exception {
		dao.update(paramMap);
	}	

	public void delete(HashMap<String,Object> paramMap) throws Exception {
        dao.delete(paramMap);
	}		

}
