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

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

import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Repository;

import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;

/**
* 1. 기능 : EAIMessage를 관리하기 위한 Data Access Object 이다.
* 2. 처리 개요 :  EAIMessage 테이블에 대한 Create, Read, Update, Delete 를 처리한다.
*
* 3. 주의사항
*
* @author  :
* @version : v 1.0.0
* @see : EAIMessageQuery.java
* @since   :
*/
@Repository("eaiMsgDao")
@SuppressWarnings("unchecked")
public class EaiMsgDao extends SqlMapClientTemplateDao {

    public int selectListCount(HashMap paramMap) throws Exception {
    	return (Integer)template.queryForObject("EaiMsg.selectListCount", paramMap);
    }	
    public List selectList(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectList", paramMap);
    }	
    public List selectListToExcel(HashMap param) throws Exception {
    	return template.queryForList("EaiMsg.selectListToExcel", param);
    }
    public HashMap selectDetail(HashMap paramMap) throws Exception {
    	return (HashMap)template.queryForObject("EaiMsg.selectDetail", paramMap);
    }	

    public void insert(HashMap paramMap) throws Exception{
        this.template.insert("EaiMsg.insert", paramMap);
    }      
    public void update(HashMap paramMap) throws Exception{
        this.template.update("EaiMsg.update", paramMap);
    }
    public void updateTranType(HashMap paramMap) throws Exception{
        this.template.update("EaiMsg.updateTranType", paramMap);
    }
    public void delete(HashMap paramMap) throws Exception{
        this.template.delete("EaiMsg.delete", paramMap);
    }	
    
    public List selectListSvc(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectListSvc", paramMap);
    }	
    public HashMap selectDetailSvc(HashMap paramMap) throws Exception {
    	return (HashMap)template.queryForObject("EaiMsg.selectDetailSvc", paramMap);
    }	
    public List selectDetailSvcAll(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectDetailSvcAll", paramMap);
    }	    

    public void insertSvc(HashMap paramMap) throws Exception{
        this.template.insert("EaiMsg.insertSvc", paramMap);
    }  
    public void updateSvc(HashMap paramMap) throws Exception{
        this.template.update("EaiMsg.updateSvc", paramMap);
    }         
    public void deleteSvc(HashMap paramMap) throws Exception{
        this.template.delete("EaiMsg.deleteSvc", paramMap);
    }
    
    public void insertSvcClone(HashMap paramMap) throws Exception{
        this.template.insert("EaiMsg.insertSvcClone", paramMap);
    }
    
    public List selectListRef(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectListRef", paramMap);
    }	 

    public List selectListRefEtc(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectListRefEtc", paramMap);
    }	
    
    public void deleteRefForEaiSvcName(HashMap paramMap) throws Exception{
        this.template.delete("EaiMsg.deleteRefForEaiSvcName", paramMap);
    }       
    public void insertRef(HashMap paramMap) throws Exception{
    	paramMap.put("SVCPRCSSNO", MapUtils.getIntValue(paramMap, "SVCPRCSSNO"));
    	paramMap.put("REFMSGIDNO", MapUtils.getIntValue(paramMap, "REFMSGIDNO"));
        this.template.insert("EaiMsg.insertRef", paramMap);
    }
    
    public void insertRefClone(HashMap paramMap) throws Exception{
        this.template.insert("EaiMsg.insertRefClone", paramMap);
    }
    
    public List selectListCondRule(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectListCondRule", paramMap);
    }	    
    
    public void deleteCondRuleForEaiSvcName(HashMap paramMap) throws Exception{
        this.template.delete("EaiMsg.deleteCondRuleForEaiSvcName", paramMap);
    }  
    public void insertCondRule(HashMap paramMap) throws Exception{
        this.template.insert("EaiMsg.insertCondRule", paramMap);
    }
    
    public void insertCondRuleClone(HashMap paramMap) throws Exception{
        this.template.insert("EaiMsg.insertCondRuleClone", paramMap);
    }
    
    public List selectListAll(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectListAll", paramMap);
    }
    
    public List<HashMap> selectListDetail(HashMap paramMap) throws Exception {
    	return template.queryForList("EaiMsg.selectDetail", paramMap);
    }
    
	/**
	 * 해당 EAI 서비스메시지의 참고메시지 id(소스레이아웃명) 를 리턴한다.
	 * @param eaiSvcCd
	 * @return
	 * @throws DAOException
	 */
	public String selectRefMsgID( HashMap paramMap ) throws DAOException {
	   List list = template.queryForList("EaiMsg.selectEaiRefMsgs", paramMap);
		
       String refMsgID = "" ;
       if( list != null && list.size() > 0 ) {
           refMsgID = (String)((HashMap)list.get(0)).get("REFMSGIDNAME");
       }
       
       return refMsgID ;		
	}	
	 public List selectSnaAdpApList(HashMap paramMap) throws Exception {
	    	return template.queryForList("EaiMsg.selectSnaAdpApList", paramMap);
	 }	
	 public List selectOuAdpInstList(HashMap paramMap) throws Exception {
	    	return template.queryForList("EaiMsg.selectOuAdpInstList", paramMap);
	 }	
	 public List selectInAdpInstList(HashMap paramMap) throws Exception {
	    	return template.queryForList("EaiMsg.selectInAdpInstList", paramMap);
	 }	

}
