package com.madeu.dao.web.webappcontents;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 앱 시술 콘텐츠 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTotalAppContentsCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppContentsSqlMapDAO selectTotalAppContentsCount START");
        String sqlId = "WebAppContents.selectTotalAppContentsCount";
        logger.debug("WebAppContentsSqlMapDAO selectTotalAppContentsCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 시술 콘텐츠 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListAppContents(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppContentsSqlMapDAO selectListAppContents START");
        String sqlId = "WebAppContents.selectListAppContents";
        logger.debug("WebAppContentsSqlMapDAO selectListAppContents END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 시술 콘텐츠 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectAppContents(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppContentsSqlMapDAO selectAppContents START");
        String sqlId = "WebAppContents.selectAppContents";
        logger.debug("WebAppContentsSqlMapDAO selectAppContents END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 앱 시술 콘텐츠 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertAppContents(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppContentsSqlMapDAO insertAppContents START");
        String sqlId = "WebAppContents.insertAppContents";
        logger.debug("WebAppContentsSqlMapDAO insertAppContents END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 앱 시술 콘텐츠 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateAppContents(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppContentsSqlMapDAO updateAppContents START");
        String sqlId = "WebAppContents.updateAppContents";
        logger.debug("WebAppContentsSqlMapDAO updateAppContents END");
        return getSqlSession().update(sqlId, paramMap);
    }

    /**
     * 앱 시술 콘텐츠 정보 삭제
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int deleteAppContents(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppContentsSqlMapDAO deleteAppContents START");
        String sqlId = "WebAppContents.deleteAppContents";
        logger.debug("WebAppContentsSqlMapDAO deleteAppContents END");
        return getSqlSession().update(sqlId, paramMap);
    }

}
