package com.madeu.dao.mobile.mobilepush;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

	/**
	 * 앱 푸시 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalPushCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobilePushSqlMapDAO selectTotalPushCount START");
		String sqlId = "MobilePush.selectTotalPushCount";
		logger.debug("MobilePushSqlMapDAO selectTotalPushCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 앱 푸시 정보 리스트 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPush(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobilePushSqlMapDAO selectListPush START");
		String sqlId = "MobilePush.selectListPush";
		logger.debug("MobilePushSqlMapDAO selectListPush END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 앱 푸시 정보 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectPush(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobilePushSqlMapDAO selectPush START");
		String sqlId = "MobilePush.selectPush";
		logger.debug("MobilePushSqlMapDAO selectPush END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 푸시 알림 갯수 체크
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectPushCountCheck(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobilePushSqlMapDAO selectPushCountCheck START");
		String sqlId = "MobilePush.selectPushCountCheck";
		logger.debug("MobilePushSqlMapDAO selectPushCountCheck END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 앱 푸시 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertPush(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobilePushSqlMapDAO insertPush START");
		String sqlId = "MobilePush.insertPush";
		logger.debug("MobilePushSqlMapDAO insertPush END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 앱 푸시 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updatePushUserCheckYn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobilePushSqlMapDAO updatePushUserCheckYn START");
		String sqlId = "MobilePush.updatePushUserCheckYn";
		logger.debug("MobilePushSqlMapDAO updatePushUserCheckYn END");
		return getSqlSession().update(sqlId, paramMap);
	}

}
