package com.madeu.dao.web.webloghistory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

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;

@Repository
public class WebLogHistorySqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 오류 로그 정보 총 갯수 조회 (total count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalLogHistoryCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebLogHistorySqlMapDAO selectTotalLogHistoryCount START");
		String sqlId = "WebLogHistory.selectTotalLogHistoryCount";
		logger.debug("WebLogHistorySqlMapDAO selectTotalLogHistoryCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 오류 로그 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListLogHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebLogHistorySqlMapDAO selectListLogHistory START");
		String sqlId = "WebLogHistory.selectListLogHistory";
		logger.debug("WebLogHistorySqlMapDAO selectListLogHistory END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 오류 로그 정보 조회
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectLogHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebLogHistorySqlMapDAO selectLogHistory START");
		String sqlId = "WebLogHistory.selectLogHistory";
		logger.debug("WebLogHistorySqlMapDAO selectLogHistory END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 오류 로그 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertLogHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebLogHistorySqlMapDAO insertLogHistory START");
		String sqlId = "WebLogHistory.insertLogHistory";
		logger.debug("WebLogHistorySqlMapDAO insertLogHistory END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 오류 로그 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateLogHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebLogHistorySqlMapDAO updateLogHistory START");
		String sqlId = "WebLogHistory.updateLogHistory";
		logger.debug("WebLogHistorySqlMapDAO updateLogHistory END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 오류 로그 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteLogHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebLogHistorySqlMapDAO deleteLogHistory START");
		String sqlId = "WebLogHistory.deleteLogHistory";
		logger.debug("WebLogHistorySqlMapDAO deleteLogHistory END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
