package com.madeu.dao.web.webpopup;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 홈페이지 팝업 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTotalWebPopupCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO selectTotalWebPopupCount START");
        String sqlId = "WebPopup.selectTotalWebPopupCount";
        logger.debug("WebPopupSqlMapDAO selectTotalWebPopupCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 팝업 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListWebPopup(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO selectListWebPopup START");
        String sqlId = "WebPopup.selectListWebPopup";
        logger.debug("WebPopupSqlMapDAO selectListWebPopup END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 팝업 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectWebPopup(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO selectWebPopup START");
        String sqlId = "WebPopup.selectWebPopup";
        logger.debug("WebPopupSqlMapDAO selectWebPopup END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 팝업 정보 갯수 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectWebPopupCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO selectWebPopupCount START");
        String sqlId = "WebPopup.selectWebPopupCount";
        logger.debug("WebPopupSqlMapDAO selectWebPopupCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 팝업 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertWebPopup(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO insertWebPopup START");
        String sqlId = "WebPopup.insertWebPopup";
        logger.debug("WebPopupSqlMapDAO insertWebPopup END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 홈페이지 팝업 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateWebPopup(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO updateWebPopup START");
        String sqlId = "WebPopup.updateWebPopup";
        logger.debug("WebPopupSqlMapDAO updateWebPopup END");
        return getSqlSession().update(sqlId, paramMap);
    }

    /**
     * 홈페이지 팝업 정보 삭제
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int deleteWebPopup(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebPopupSqlMapDAO deleteWebPopup START");
        String sqlId = "WebPopup.deleteWebPopup";
        logger.debug("WebPopupSqlMapDAO deleteWebPopup END");
        return getSqlSession().update(sqlId, paramMap);
    }

}
