package com.madeu.dao.web.webduty;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 직무 조회 (List, option)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListDutyOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebDutySqlMapDAO selectListDutyOption START");
		String sqlId = "WebDuty.selectListDutyOption";
		logger.debug("WebDutySqlMapDAO selectListDutyOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직무 정보 총 갯수 조회 (total count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalDutyCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebDutySqlMapDAO selectTotalDutyCount START");
		String sqlId = "WebDuty.selectTotalDutyCount";
		logger.debug("WebDutySqlMapDAO selectTotalDutyCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직무 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListDuty(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebDutySqlMapDAO selectListDuty START");
		String sqlId = "WebDuty.selectListDuty";
		logger.debug("WebDutySqlMapDAO selectListDuty END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직무 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectDuty(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebDutySqlMapDAO selectDuty START");
		String sqlId = "WebDuty.selectDuty";
		logger.debug("WebDutySqlMapDAO selectDuty END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 직무 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertDuty(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebDutySqlMapDAO insertDuty START");
		String sqlId = "WebDuty.insertDuty";
		logger.debug("WebDutySqlMapDAO insertDuty END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 직무 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateDuty(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebDutySqlMapDAO updateDuty START");
		String sqlId = "WebDuty.updateDuty";
		logger.debug("WebDutySqlMapDAO updateDuty END");
		return getSqlSession().update(sqlId, paramMap);
	}

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