package com.madeu.dao.web.webpush;

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 WebPushSqlMapDAO 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("WebPushSqlMapDAO selectTotalPushCount START");
		String sqlId = "WebPush.selectTotalPushCount";
		logger.debug("WebPushSqlMapDAO 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("WebPushSqlMapDAO selectListPush START");
		String sqlId = "WebPush.selectListPush";
		logger.debug("WebPushSqlMapDAO selectListPush END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 푸시 리스트 조회 (GROUP)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPushTimeGroup(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebPushSqlMapDAO selectListPushTimeGroup START");
		String sqlId = "WebPush.selectListPushTimeGroup";
		logger.debug("WebPushSqlMapDAO selectListPushTimeGroup END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 푸시 리스트 조회 (GROUP)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPushTimeGroup2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebPushSqlMapDAO selectListPushTimeGroup2 START");
		String sqlId = "WebPush.selectListPushTimeGroup2";
		logger.debug("WebPushSqlMapDAO selectListPushTimeGroup2 END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 푸시 리스트 조회 (GROUP)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPushTime(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebPushSqlMapDAO selectListPushTime START");
		String sqlId = "WebPush.selectListPushTime";
		logger.debug("WebPushSqlMapDAO selectListPushTime END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 푸시 리스트 조회 (GROUP)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListPushTime2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebPushSqlMapDAO selectListPushTime2 START");
		String sqlId = "WebPush.selectListPushTime2";
		logger.debug("WebPushSqlMapDAO selectListPushTime2 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("WebPushSqlMapDAO selectPush START");
		String sqlId = "WebPush.selectPush";
		logger.debug("WebPushSqlMapDAO selectPush END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

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

	/**
	 * 앱 푸시 수정 - State
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updatePushState(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebPushSqlMapDAO updatePushState START");
		String sqlId = "WebPush.updatePushState";
		logger.debug("WebPushSqlMapDAO updatePushState END");
		return getSqlSession().update(sqlId, paramMap);
	}

}
