package com.madeu.dao.web.webhospital;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 병원 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectHospital(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebHospitalSqlMapDAO selectHospital START");
		String sqlId = "WebHospital.selectHospital";
		logger.debug("WebHospitalSqlMapDAO selectHospital END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 병원 정보 휴일 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectHospitalWeek(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebHospitalSqlMapDAO selectHospitalWeek START");
		String sqlId = "WebHospital.selectHospitalWeek";
		logger.debug("WebHospitalSqlMapDAO selectHospitalWeek END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 병원 정보 휴일 조회2
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectHospitalWeek2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebHospitalSqlMapDAO selectHospitalWeek2 START");
		String sqlId = "WebHospital.selectHospitalWeek2";
		logger.debug("WebHospitalSqlMapDAO selectHospitalWeek2 END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	/**
	 * 병원 월별 휴일 정보
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectHospitalHoliday(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebHospitalSqlMapDAO selectHospitalHoliday START");
		String sqlId = "WebHospital.selectHospitalHoliday";
		logger.debug("WebHospitalSqlMapDAO selectHospitalHoliday END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 병원 정보 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateHospital(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebHospitalSqlMapDAO updateHospital START");
		String sqlId = "WebHospital.updateHospital";
		logger.debug("WebHospitalSqlMapDAO updateHospital END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
