package com.madeu.dao.web.webkakao;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

	/**
	 * 알림톡 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalKakaoCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO selectTotalKakaoCount START");
		String sqlId = "WebKakao.selectTotalKakaoCount";
		logger.debug("WebKakaoSqlMapDAO selectTotalKakaoCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 알림톡 정보 리스트 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListKakao(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO selectListKakao START");
		String sqlId = "WebKakao.selectListKakao";
		logger.debug("WebKakaoSqlMapDAO selectListKakao END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * Kakao 리스트 조회 - Template
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListKakaoTemplate(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO selectListKakaoTemplate START");
		String sqlId = "WebKakao.selectListKakaoTemplate";
		logger.debug("WebKakaoSqlMapDAO selectListKakaoTemplate END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * Kakao 리스트 조회 - State
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListKakaoState(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO selectListKakaoState START");
		String sqlId = "WebKakao.selectListKakaoState";
		logger.debug("WebKakaoSqlMapDAO selectListKakaoState 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("WebKakaoSqlMapDAO selectListPopbillState START");
		String sqlId = "WebKakao.selectListPopbillState";
		logger.debug("WebKakaoSqlMapDAO selectListPopbillState END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 알림톡 정보 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectKakao(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO selectKakao START");
		String sqlId = "WebKakao.selectKakao";
		logger.debug("WebKakaoSqlMapDAO selectKakao END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 알림톡 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertKakao(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO insertKakao START");
		String sqlId = "WebKakao.insertKakao";
		logger.debug("WebKakaoSqlMapDAO insertKakao END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 알림톡 정보 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateKakao(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO updateKakao START");
		String sqlId = "WebKakao.updateKakao";
		logger.debug("WebKakaoSqlMapDAO updateKakao END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 알림톡 수정 - State
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateKakaoState(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO updateKakaoState START");
		String sqlId = "WebKakao.updateKakaoState";
		logger.debug("WebKakaoSqlMapDAO updateKakaoState END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 알림톡 수정 - 팝빌 전송상태, 팝빌 전송결과
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public int updateKakaoPopbillState(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebKakaoSqlMapDAO updateKakaoPopbillState START");
		String sqlId = "WebKakao.updateKakaoPopbillState";
		logger.debug("WebKakaoSqlMapDAO updateKakaoPopbillState END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
}
