package com.madeu.dao.web.websms;

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 WebSmsSqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

	/**
	 * 문자 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalSmsCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO selectTotalSmsCount START");
		String sqlId = "WebSms.selectTotalSmsCount";
		logger.debug("WebSmsSqlMapDAO selectTotalSmsCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 문자 정보 리스트 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListSms(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO selectListSms START");
		String sqlId = "WebSms.selectListSms";
		logger.debug("WebSmsSqlMapDAO selectListSms END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * SMS 리스트 조회 - Time
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListSmsTime(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO selectListSmsTime START");
		String sqlId = "WebSms.selectListSmsTime";
		logger.debug("WebSmsSqlMapDAO selectListSmsTime END");
		return getSqlSession().selectList(sqlId, paramMap);
	}


	/**
	 * SMS 리스트 조회 - State
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListSmsState(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO selectListSmsState START");
		String sqlId = "WebSms.selectListSmsState";
		logger.debug("WebSmsSqlMapDAO selectListSmsState END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 문자 리스트 조회 - 팝빌 전송상태 (POPBILL_STATE)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPopbillState(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO selectListPopbillState START");
		String sqlId = "WebSms.selectListPopbillState";
		logger.debug("WebSmsSqlMapDAO selectListPopbillState END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 문자 정보 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectSms(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO selectSms START");
		String sqlId = "WebSms.selectSms";
		logger.debug("WebSmsSqlMapDAO selectSms END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 문자 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertSms(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO insertSms START");
		String sqlId = "WebSms.insertSms";
		logger.debug("WebSmsSqlMapDAO insertSms END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 문자 정보 등록 - 상담 차트
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertSmsConsultingChart(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO insertSmsConsultingChart START");
		String sqlId = "WebSms.insertSmsConsultingChart";
		logger.debug("WebSmsSqlMapDAO insertSmsConsultingChart END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 문자 정보 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateSms(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO updateSms START");
		String sqlId = "WebSms.updateSms";
		logger.debug("WebSmsSqlMapDAO updateSms END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 문자 수정 - State
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateSmsState(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO updateSmsState START");
		String sqlId = "WebSms.updateSmsState";
		logger.debug("WebSmsSqlMapDAO updateSmsState END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 문자 수정 - 팝빌 전송상태, 팝빌 전송결과
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public int updateSmsPopbillState(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebSmsSqlMapDAO updateSmsPopbillState START");
		String sqlId = "WebSms.updateSmsPopbillState";
		logger.debug("WebSmsSqlMapDAO updateSmsPopbillState END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
}
