package com.madeu.dao.mobile.mobileuserinquiry;

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 MobileUserInquirySqlMapDAO 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>> selectTotalUserInquiryCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("MobileUserInquirySqlMapDAO selectTotalUserInquiryCount START");
        String sqlId = "MobileUserInquiry.selectTotalUserInquiryCount";
        logger.debug("MobileUserInquirySqlMapDAO selectTotalUserInquiryCount END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

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

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

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