package com.madeu.dao.web.webwork;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 근무설정 정보 총 갯수 조회 (total count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalWorkCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebWorkSqlMapDAO selectTotalWorkCount START");
		String sqlId = "WebWork.selectTotalWorkCount";
		logger.debug("WebWorkSqlMapDAO selectTotalWorkCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 근무설정 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListWork(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebWorkSqlMapDAO selectListWork START");
		String sqlId = "WebWork.selectListWork";
		logger.debug("WebWorkSqlMapDAO selectListWork END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 근무설정 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectWork(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebWorkSqlMapDAO selectWork START");
		String sqlId = "WebWork.selectWork";
		logger.debug("WebWorkSqlMapDAO selectWork END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 근무설정 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertWork(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebWorkSqlMapDAO insertWork START");
		String sqlId = "WebWork.insertWork";
		logger.debug("WebWorkSqlMapDAO insertWork END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 근무설정 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateWork(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebWorkSqlMapDAO updateWork START");
		String sqlId = "WebWork.updateWork";
		logger.debug("WebWorkSqlMapDAO updateWork END");
		return getSqlSession().update(sqlId, paramMap);
	}

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