package com.madeu.dao.web.webappuser;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

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

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

    /**
     * 앱 회원 정보 리스트 조회 (List, Excel)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListAppUserExcel(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebAppUserSqlMapDAO selectListAppUserExcel START");
        String sqlId = "WebAppUser.selectListAppUserExcel";
        logger.debug("WebAppUserSqlMapDAO selectListAppUserExcel END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
}
