package com.bb.dao;

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

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.bb.model.CoinVo;

@Repository("coinDao")
public class CoinDaoImpl implements CoinDao{
	
	  /** 메인DB 연결 */
    @Autowired @Qualifier("sqlSessionMain")
    protected SqlSession sqlSession;
 
    /** 서브DB 연결 */
    @Autowired @Qualifier("sqlSessionSub")
    protected SqlSession sqlSessionSub;

	@Override
	public void saveCoinInfo(CoinVo coinInfo) {
		sqlSession.insert("saveCoinInfo", coinInfo);
		
	}

	@Override
	public CoinVo getCoinInfo(String coinSymbol, String currency) {	
		Map param = new HashMap();
		param.put("coinSymbol", coinSymbol);
		param.put("currency", currency);
		return sqlSessionSub.selectOne("getCoinInfo", param);
	}
	 
}
