package com.madeu.dao.web.webauthmenurelation;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	
	/**
	 * 권한별 메뉴 정보 조회 (one)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectAuthMenuRelation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebAuthMenuRelationSqlMapDAO selectAuthMenuRelation START");
		String sqlId = "WebAuthMenuRelation.selectAuthMenuRelation";
		logger.debug("WebAuthMenuRelationSqlMapDAO selectAuthMenuRelation END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 권한별 메뉴 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListAuthMenuRelation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebAuthMenuRelationSqlMapDAO selectListAuthMenuRelation START");
		String sqlId = "WebAuthMenuRelation.selectListAuthMenuRelation";
		logger.debug("WebAuthMenuRelationSqlMapDAO selectListAuthMenuRelation END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 권한별 메뉴 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertAuthMenuRelation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebAuthMenuRelationSqlMapDAO insertAuthMenuRelation START");
		String sqlId = "WebAuthMenuRelation.insertAuthMenuRelation";
		logger.debug("WebAuthMenuRelationSqlMapDAO insertAuthMenuRelation END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 권한별 메뉴 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteAuthMenuRelation(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebAuthMenuRelationSqlMapDAO deleteAuthMenuRelation START");
		String sqlId = "WebAuthMenuRelation.deleteAuthMenuRelation";
		logger.debug("WebAuthMenuRelationSqlMapDAO deleteAuthMenuRelation END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
