package com.madeu.dao.web.webtreatment;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 진료 조회 (List, option)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListTreatmentOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO selectListTreatmentOption START");
		String sqlId = "WebTreatment.selectListTreatmentOption";
		logger.debug("WebTreatmentSqlMapDAO selectListTreatmentOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}


	/**
	 * 진료 조회 (List, option)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListTreatmentOption2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO selectListTreatmentOption2 START");
		String sqlId = "WebTreatment.selectListTreatmentOption2";
		logger.debug("WebTreatmentSqlMapDAO selectListTreatmentOption2 END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 진료 정보 총 갯수 조회 (total count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalTreatmentCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO selectTotalTreatmentCount START");
		String sqlId = "WebTreatment.selectTotalTreatmentCount";
		logger.debug("WebTreatmentSqlMapDAO selectTotalTreatmentCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 진료 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListTreatment(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO selectListTreatment START");
		String sqlId = "WebTreatment.selectListTreatment";
		logger.debug("WebTreatmentSqlMapDAO selectListTreatment END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	/**
	 * 멤버십상품 조회 (List, option)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectMembershipOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO selectMembershipOption START");
		String sqlId = "WebTreatment.selectMembershipOption";
		logger.debug("WebTreatmentSqlMapDAO selectMembershipOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	/**
	 * 진료 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTreatment(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO selectTreatment START");
		String sqlId = "WebTreatment.selectTreatment";
		logger.debug("WebTreatmentSqlMapDAO selectTreatment END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 진료 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertTreatment(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO insertTreatment START");
		String sqlId = "WebTreatment.insertTreatment";
		logger.debug("WebTreatmentSqlMapDAO insertTreatment END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 진료 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteTreatment(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebTreatmentSqlMapDAO deleteTreatment START");
		String sqlId = "WebTreatment.deleteTreatment";
		logger.debug("WebTreatmentSqlMapDAO deleteTreatment END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
