package com.madeu.dao.web.webvacation;

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 jakarta.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class WebVacationSqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 연차설정 조회 (List, option)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListVacationOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO selectListVacationOption START");
		String sqlId = "WebVacation.selectListVacationOption";
		logger.debug("WebVacationSqlMapDAO selectListVacationOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 연차설정 정보 총 갯수 조회 (total count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalVacationCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO selectTotalVacationCount START");
		String sqlId = "WebVacation.selectTotalVacationCount";
		logger.debug("WebVacationSqlMapDAO selectTotalVacationCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 연차설정 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListVacation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO selectListVacation START");
		String sqlId = "WebVacation.selectListVacation";
		logger.debug("WebVacationSqlMapDAO selectListVacation END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 연차설정 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectVacation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO selectVacation START");
		String sqlId = "WebVacation.selectVacation";
		logger.debug("WebVacationSqlMapDAO selectVacation END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 연차설정 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertVacation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO insertVacation START");
		String sqlId = "WebVacation.insertVacation";
		logger.debug("WebVacationSqlMapDAO insertVacation END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 연차설정 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateVacation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO updateVacation START");
		String sqlId = "WebVacation.updateVacation";
		logger.debug("WebVacationSqlMapDAO updateVacation END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 연차설정 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteVacation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebVacationSqlMapDAO deleteVacation START");
		String sqlId = "WebVacation.deleteVacation";
		logger.debug("WebVacationSqlMapDAO deleteVacation END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
