package com.madeu.dao.web.webmainbanner;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 홈페이지 메인 배너 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTotalWebMainBannerCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO selectTotalWebMainBannerCount START");
        String sqlId = "WebMainBanner.selectTotalWebMainBannerCount";
        logger.debug("WebMainBannerSqlMapDAO selectTotalWebMainBannerCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 메인 배너 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListWebMainBanner(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO selectListWebMainBanner START");
        String sqlId = "WebMainBanner.selectListWebMainBanner";
        logger.debug("WebMainBannerSqlMapDAO selectListWebMainBanner END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 메인 배너 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectWebMainBanner(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO selectWebMainBanner START");
        String sqlId = "WebMainBanner.selectWebMainBanner";
        logger.debug("WebMainBannerSqlMapDAO selectWebMainBanner END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 메인 배너 갯수 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectWebMainBannerCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO selectWebMainBannerCount START");
        String sqlId = "WebMainBanner.selectWebMainBannerCount";
        logger.debug("WebMainBannerSqlMapDAO selectWebMainBannerCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 홈페이지 메인 배너 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertWebMainBanner(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO insertWebMainBanner START");
        String sqlId = "WebMainBanner.insertWebMainBanner";
        logger.debug("WebMainBannerSqlMapDAO insertWebMainBanner END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 홈페이지 메인 배너 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateWebMainBanner(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO updateWebMainBanner START");
        String sqlId = "WebMainBanner.updateWebMainBanner";
        logger.debug("WebMainBannerSqlMapDAO updateWebMainBanner END");
        return getSqlSession().update(sqlId, paramMap);
    }

    /**
     * 홈페이지 메인 배너 정보 삭제
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int deleteWebMainBanner(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebMainBannerSqlMapDAO deleteWebMainBanner START");
        String sqlId = "WebMainBanner.deleteWebMainBanner";
        logger.debug("WebMainBannerSqlMapDAO deleteWebMainBanner END");
        return getSqlSession().update(sqlId, paramMap);
    }

}
