package com.madeu.dao.web.webmember;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * (활성화) 직원 확인 (one)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> checkMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO checkMember START");
		String sqlId = "WebMember.checkMember";
		logger.debug("WebMemberSqlMapDAO checkMember END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 직원아이디 조회 (one)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public String selectMemberId(String id)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectMemberId START");
		String sqlId = "WebMember.selectMemberId";
		logger.debug("WebMemberSqlMapDAO selectMemberId END");
		return getSqlSession().selectOne(sqlId, id);
	}
	/**
	 * 닥터 조회 (List, option)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListMemberDoctorOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectListMemberDoctorOption START");
		String sqlId = "WebMember.selectListMemberDoctorOption";
		logger.debug("WebMemberSqlMapDAO selectListMemberDoctorOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 해당 시술 닥터 및 해당과 상담자 조회 (List, option)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListMemberDoctorConsultingOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectListMemberDoctorConsultingOption START");
		String sqlId = "WebMember.selectListMemberDoctorConsultingOption";
		logger.debug("WebMemberSqlMapDAO selectListMemberDoctorConsultingOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 닥터 및 상담자 조회 (List, option)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListMemberDoctorConsultingOption2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectListMemberDoctorConsultingOption2 START");
		String sqlId = "WebMember.selectListMemberDoctorConsultingOption2";
		logger.debug("WebMemberSqlMapDAO selectListMemberDoctorConsultingOption2 END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 총 갯수 조회 (total count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalMemberCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectTotalMemberCount START");
		String sqlId = "WebMember.selectTotalMemberCount";
		logger.debug("WebMemberSqlMapDAO selectTotalMemberCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectListMember START");
		String sqlId = "WebMember.selectListMember";
		logger.debug("WebMemberSqlMapDAO selectListMember END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectMember START");
		String sqlId = "WebMember.selectMember";
		logger.debug("WebMemberSqlMapDAO selectMember END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 리스트 조회 (List, Excel)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListMemberExcel(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectListMemberExcel START");
		String sqlId = "WebMember.selectListMemberExcel";
		logger.debug("WebMemberSqlMapDAO selectListMemberExcel END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 사번 생성 조회 (one)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectMemberCountSeq(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectMemberCountSeq START");
		String sqlId = "WebMember.selectMemberCountSeq";
		logger.debug("WebMemberSqlMapDAO selectMemberCountSeq END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 비밀번호 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectMemberPassword(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectMemberPassword START");
		String sqlId = "WebMember.selectMemberPassword";
		logger.debug("WebMemberSqlMapDAO selectMemberPassword END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 코드로 조회 (one, 휴무/연차 아닌 직원)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectMemberAvailableYn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO selectMemberAvailableYn START");
		String sqlId = "WebMember.selectMemberAvailableYn";
		logger.debug("WebMemberSqlMapDAO selectMemberAvailableYn END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO insertMember START");
		String sqlId = "WebMember.insertMember";
		logger.debug("WebMemberSqlMapDAO insertMember END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO updateMember START");
		String sqlId = "WebMember.updateMember";
		logger.debug("WebMemberSqlMapDAO updateMember END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 직원 정보 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateMemberOrderNumber(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO updateMemberOrderNumber START");
		String sqlId = "WebMember.updateMemberOrderNumber";
		logger.debug("WebMemberSqlMapDAO updateMemberOrderNumber END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 상태 수정 
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateMemberStatus(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO updateMemberStatus START");
		String sqlId = "WebMember.updateMemberStatus";
		logger.debug("WebMemberSqlMapDAO updateMemberStatus END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 직원 정보 비밀번호 수정 
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateMemberPassword(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO updateMemberPassword START");
		String sqlId = "WebMember.updateMemberPassword";
		logger.debug("WebMemberSqlMapDAO updateMemberPassword END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 직원 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebMemberSqlMapDAO deleteMember START");
		String sqlId = "WebMember.deleteMember";
		logger.debug("WebMemberSqlMapDAO deleteMember END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
