package com.madeu.dao.web.webpublicholiday;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

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;

@Repository
public class WebPublicHolidaySqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

	/**
	 * 공휴일 중복 조회
	 * 
	 * @param map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListPublicHolidayDate(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebPublicHolidaySqlMapDAO selectListPublicHolidayDate START");
		String sqlId = "WebPublicHoliday.selectListPublicHolidayDate";
		logger.debug("WebPublicHolidaySqlMapDAO selectListPublicHolidayDate END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 공휴일 등록 
	 * 
	 * @param map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertPublicHoliday(HashMap<String, Object> paramMap) throws DataAccessException {
		logger.debug("WebPublicHolidaySqlMapDAO insertPublicHoliday START");
		String sqlId = "WebPublicHoliday.insertPublicHoliday";
		logger.debug("WebPublicHolidaySqlMapDAO insertPublicHoliday END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 공휴일 수정
	 * 
	 * @param map
	 * @return
	 * @throws DataAccessException
	 */
	public int updatePublicHoliday(HashMap<String, Object> paramMap) throws DataAccessException{
		logger.debug("WebPublicHolidaySqlMapDAO updatePublicHoliday START");
		String sqlId = "WebPublicHoliday.updatePublicHoliday";
		logger.debug("WebPublicHolidaySqlMapDAO updatePublicHoliday END");
		return getSqlSession().update(sqlId, paramMap);
	}
}