package com.madeu.dao.web.webuserinquiry;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 고객 1:1 문의 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTotalAppUserInquiryCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserInquirySqlMapDAO selectTotalAppUserInquiryCount START");
        String sqlId = "WebAppUserInquiry.selectTotalAppUserInquiryCount";
        logger.debug("WebUserInquirySqlMapDAO selectTotalAppUserInquiryCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 고객 1:1 문의 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListAppUserInquiry(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserInquirySqlMapDAO selectListAppUserInquiry START");
        String sqlId = "WebAppUserInquiry.selectListAppUserInquiry";
        logger.debug("WebUserInquirySqlMapDAO selectListAppUserInquiry END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 고객 1:1 문의 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectAppUserInquiry(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserInquirySqlMapDAO selectAppUserInquiry START");
        String sqlId = "WebAppUserInquiry.selectAppUserInquiry";
        logger.debug("WebUserInquirySqlMapDAO selectAppUserInquiry END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 고객 1:1 문의 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertAppUserInquiry(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserInquirySqlMapDAO insertAppUserInquiry START");
        String sqlId = "WebAppUserInquiry.insertAppUserInquiry";
        logger.debug("WebUserInquirySqlMapDAO insertAppUserInquiry END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 고객 1:1 문의 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateAppUserInquiry(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserInquirySqlMapDAO updateAppUserInquiry START");
        String sqlId = "WebAppUserInquiry.updateAppUserInquiry";
        logger.debug("WebUserInquirySqlMapDAO updateAppUserInquiry END");
        return getSqlSession().update(sqlId, paramMap);
    }

}
