package com.madeu.dao.web.webappboard;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

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

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

    /**
     * 앱 시술 보드 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectAppBoard(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppBoardSqlMapDAO selectAppBoard START");
        String sqlId = "WebAppBoard.selectAppBoard";
        logger.debug("WebAppBoardSqlMapDAO selectAppBoard END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 앱 시술 보드 컨텐츠 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertBoardContent(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppBoardSqlMapDAO insertBoardContent START");
        String sqlId = "WebAppBoard.insertBoardContent";
        logger.debug("WebAppBoardSqlMapDAO insertBoardContent END");
        return getSqlSession().insert(sqlId, paramMap);
    }
    /**
     * 앱 시술 보드 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertAppBoard(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppBoardSqlMapDAO insertAppBoard START");
        String sqlId = "WebAppBoard.insertAppBoard";
        logger.debug("WebAppBoardSqlMapDAO insertAppBoard END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 앱 시술 보드 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateAppBoard(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppBoardSqlMapDAO updateAppBoard START");
        String sqlId = "WebAppBoard.updateAppBoard";
        logger.debug("WebAppBoardSqlMapDAO updateAppBoard END");
        return getSqlSession().update(sqlId, paramMap);
    }

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

    /**
     * 앱 시술 보드 정보 삭제
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int deleteAppBoard(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppBoardSqlMapDAO deleteAppBoard START");
        String sqlId = "WebAppBoard.deleteAppBoard";
        logger.debug("WebAppBoardSqlMapDAO deleteAppBoard END");
        return getSqlSession().update(sqlId, paramMap);
    }

}
