package com.madeu.dao.mobile.mobilekakao;

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 MobileKakaoSqlMapDAO 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("MobileKakaoSqlMapDAO selectTotalKakaoCount START");
		String sqlId = "MobileKakao.selectTotalKakaoCount";
		logger.debug("MobileKakaoSqlMapDAO 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("MobileKakaoSqlMapDAO selectListKakao START");
		String sqlId = "MobileKakao.selectListKakao";
		logger.debug("MobileKakaoSqlMapDAO 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("MobileKakaoSqlMapDAO selectListKakaoTemplate START");
		String sqlId = "MobileKakao.selectListKakaoTemplate";
		logger.debug("MobileKakaoSqlMapDAO 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("MobileKakaoSqlMapDAO selectListKakaoState START");
		String sqlId = "MobileKakao.selectListKakaoState";
		logger.debug("MobileKakaoSqlMapDAO 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("MobileKakaoSqlMapDAO selectListPopbillState START");
		String sqlId = "MobileKakao.selectListPopbillState";
		logger.debug("MobileKakaoSqlMapDAO 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("MobileKakaoSqlMapDAO selectKakao START");
		String sqlId = "MobileKakao.selectKakao";
		logger.debug("MobileKakaoSqlMapDAO selectKakao END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

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

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

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