package com.madeu.dao.api.doctalk;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 고객 식별자 조회 (one, 고객명/전화번호로 조회)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserId(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("DocTalkSqlMapDAO selectUserId START");
        String sqlId = "DocTalk.selectUserId";
        logger.debug("DocTalkSqlMapDAO selectUserId END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
	/**
	 * 고객 상담차트 - 차트 번호 조회 (신규생성)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectConsultingChartNumber(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("DocTalkSqlMapDAO selectConsultingChartNumber START");
		String sqlId = "DocTalk.selectConsultingChartNumber";
		logger.debug("DocTalkSqlMapDAO selectConsultingChartNumber END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 고객 시술차트 - 차트 번호 조회 (신규생성)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectMedicalChartNumber(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("DocTalkSqlMapDAO selectMedicalChartNumber START");
		String sqlId = "DocTalk.selectMedicalChartNumber";
		logger.debug("DocTalkSqlMapDAO selectMedicalChartNumber END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

    /**
     * 고객 등록 (간편예약고객)
     *
     * @param Map
     * @throws DataAccessException
     */
    public void insertUserTemp(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("DocTalkSqlMapDAO insertUserTemp START");
        String sqlId = "DocTalk.insertUserTemp";
        logger.debug("DocTalkSqlMapDAO insertUserTemp END");
        getSqlSession().insert(sqlId, paramMap);
    }

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

	/**
	 * 고객 상담차트 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertConsultingChart(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("DocTalkSqlMapDAO insertConsultingChart START");
		String sqlId = "DocTalk.insertConsultingChart";
		logger.debug("DocTalkSqlMapDAO insertConsultingChart END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 고객 시술차트 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertMedicalChart(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("DocTalkSqlMapDAO insertMedicalChart START");
		String sqlId = "DocTalk.insertMedicalChart";
		logger.debug("DocTalkSqlMapDAO insertMedicalChart END");
		return getSqlSession().insert(sqlId, paramMap);
	}

}
