package com.madeu.dao.mobile.mobilenotice;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 앱 공지사항 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTotalNoticeCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("MobileNoticeSqlMapDAO selectTotalNoticeCount START");
        String sqlId = "MobileNotice.selectTotalNoticeCount";
        logger.debug("MobileNoticeSqlMapDAO selectTotalNoticeCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 공지사항 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListNotice(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("MobileNoticeSqlMapDAO selectListNotice START");
        String sqlId = "MobileNotice.selectListNotice";
        logger.debug("MobileNoticeSqlMapDAO selectListNotice END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 공지사항 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectNotice(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("MobileNoticeSqlMapDAO selectNotice START");
        String sqlId = "MobileNotice.selectNotice";
        logger.debug("MobileNoticeSqlMapDAO selectNotice END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
}
