package com.madeu.dao.mobile.mobileReservation;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

	/**
	 * 예약내역 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReservationCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectListReservationCount START");
		String sqlId = "MobileReservation.selectListReservationCount";
		logger.debug("MobileReservationSqlMapDAO selectListReservationCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}


	/**
	 * 예약내역 리스트 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReservation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectListReservation START");
		String sqlId = "MobileReservation.selectListReservation";
		logger.debug("MobileReservationSqlMapDAO selectListReservation END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 이전 예약내역 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReservationHistoryCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectListReservationHistoryCount START");
		String sqlId = "MobileReservation.selectListReservationHistoryCount";
		logger.debug("MobileReservationSqlMapDAO selectListReservationHistoryCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}


	/**
	 * 이전 예약내역 리스트 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReservationHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectListReservationHistory START");
		String sqlId = "MobileReservation.selectListReservationHistory";
		logger.debug("MobileReservationSqlMapDAO selectListReservationHistory END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 시간 별 예약 수 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public Integer selectReserveCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectReserveCount START");
		String sqlId = "MobileReservation.selectReserveCount";
		logger.debug("MobileReservationSqlMapDAO selectReserveCount END");
		return getSqlSession().selectOne(sqlId, paramMap);
	}

	/**
	 * 고객 정보로 예약 중복 확인
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReserveYn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectListReserveYn START");
		String sqlId = "MobileReservation.selectListReserveYn";
		logger.debug("MobileReservationSqlMapDAO selectListReserveYn END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 시술 정보 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTreatmentProcedure(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectTreatmentProcedure START");
		String sqlId = "MobileReservation.selectTreatmentProcedure";
		logger.debug("MobileReservationSqlMapDAO selectTreatmentProcedure 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("MobileReservationSqlMapDAO selectHospitalHoliday START");
		String sqlId = "MobileReservation.selectHospitalHoliday";
		logger.debug("MobileReservationSqlMapDAO selectHospitalHoliday END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 상세 조회 (one)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectReserve START");
		String sqlId = "MobileReservation.selectReserve";
		logger.debug("MobileReservationSqlMapDAO selectReserve END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 홈 상단 예약 알림 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectReservationHeader(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO selectReservationHeader START");
		String sqlId = "MobileReservation.selectReservationHeader";
		logger.debug("MobileReservationSqlMapDAO selectReservationHeader END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO insertReserve START");
		String sqlId = "MobileReservation.insertReserve";
		logger.debug("MobileReservationSqlMapDAO insertReserve END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 예약현황 상태 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateReserveStatus(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO updateReserveStatus START");
		String sqlId = "MobileReservation.updateReserveStatus";
		logger.debug("MobileReservationSqlMapDAO updateReserveStatus END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 예약현황 상태 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateReserveUserCheckYn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileReservationSqlMapDAO updateReserveUserCheckYn START");
		String sqlId = "MobileReservation.updateReserveUserCheckYn";
		logger.debug("MobileReservationSqlMapDAO updateReserveUserCheckYn END");
		return getSqlSession().update(sqlId, paramMap);
	}
}