package com.madeu.dao.mobile.mobilephoneauth;

import jakarta.annotation.PostConstruct;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

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

@Repository
public class MobilePhoneAuthSqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}

	/**
	 * 휴대폰 인증 수 조회(당일)
	 *
	 * @param map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPhoneAuthCountToday(HashMap<String, Object> map)
			throws DataAccessException {
		logger.debug("MobilePhoneAuthSqlMapDAO selectListPhoneAuthCountToday START");
		String sqlId = "MobilePhoneAuth.selectListPhoneAuthCountToday";
		logger.debug("MobilePhoneAuthSqlMapDAO selectListPhoneAuthCountToday END");
		return getSqlSession().selectList(sqlId, map);
	}

	/**
	 * 휴대폰 인증 확인
	 *
	 * @param map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectPhoneAuthCheck(HashMap<String, Object> map)
			throws DataAccessException {
		logger.debug("MobilePhoneAuthSqlMapDAO selectPhoneAuthCheck START");
		String sqlId = "MobilePhoneAuth.selectPhoneAuthCheck";
		logger.debug("MobilePhoneAuthSqlMapDAO selectPhoneAuthCheck END");
		return getSqlSession().selectList(sqlId, map);
	}

	/**
	 * 인증번호 등록
	 *
	 * @param map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertPhoneAuth(HashMap<String, Object> map)
			throws DataAccessException {
		logger.debug("MobilePhoneAuthSqlMapDAO insertPhoneAuth START");
		String sqlId = "MobilePhoneAuth.insertPhoneAuth";
		logger.debug("MobilePhoneAuthSqlMapDAO insertPhoneAuth END");
		return getSqlSession().insert(sqlId, map);
	}
}
