package com.madeu.dao.web.webappevent;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

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

    /**
     * 앱 이벤트 메인노출 갯수 조회 (count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectAppEventExposedCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppEventSqlMapDAO selectAppEventExposedCount START");
        String sqlId = "WebAppEvent.selectAppEventExposedCount";
        logger.debug("WebAppEventSqlMapDAO selectAppEventExposedCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 이벤트 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTotalAppEventCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppEventSqlMapDAO selectTotalAppEventCount START");
        String sqlId = "WebAppEvent.selectTotalAppEventCount";
        logger.debug("WebAppEventSqlMapDAO selectTotalAppEventCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

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

    /**
     * 앱 이벤트 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectAppEvent(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppEventSqlMapDAO selectAppEvent START");
        String sqlId = "WebAppEvent.selectAppEvent";
        logger.debug("WebAppEventSqlMapDAO selectAppEvent END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 이벤트 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertAppEvent(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppEventSqlMapDAO insertAppEvent START");
        String sqlId = "WebAppEvent.insertAppEvent";
        logger.debug("WebAppEventSqlMapDAO insertAppEvent END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 앱 이벤트 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateAppEvent(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppEventSqlMapDAO updateAppEvent START");
        String sqlId = "WebAppEvent.updateAppEvent";
        logger.debug("WebAppEventSqlMapDAO updateAppEvent END");
        return getSqlSession().update(sqlId, paramMap);
    }

    /**
     * 앱 이벤트 정보 삭제
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int deleteAppEvent(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppEventSqlMapDAO deleteAppEvent START");
        String sqlId = "WebAppEvent.deleteAppEvent";
        logger.debug("WebAppEventSqlMapDAO deleteAppEvent END");
        return getSqlSession().update(sqlId, paramMap);
    }

}
