package com.madeu.dao.web.webstockclose;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 재고마감 리스트 총 갯수 (COUNT)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalStockCloseCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO selectTotalStockCloseCount START");
		String sqlId = "WebStockClose.selectTotalStockCloseCount";
		logger.debug("WebStockCloseSqlMapDAO selectTotalStockCloseCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 재고마감 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockClose(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO selectListStockClose START");
		String sqlId = "WebStockClose.selectListStockClose";
		logger.debug("WebStockCloseSqlMapDAO selectListStockClose END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 재고마감 리스트 조회 (List, Excel)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockCloseExcel(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO selectListStockCloseExcel START");
		String sqlId = "WebStockClose.selectListStockCloseExcel";
		logger.debug("WebStockCloseSqlMapDAO selectListStockCloseExcel END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 재고마감 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertStockClose(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO insertStockClose START");
		String sqlId = "WebStockClose.insertStockClose";
		logger.debug("WebStockCloseSqlMapDAO insertStockClose END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	/**
	 * 재고마감 정보 삭제
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectIdBeforeUpdate(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO selectIdBeforeUpdate START");
		String sqlId = "WebStockClose.selectIdBeforeUpdate";
		logger.debug("WebStockCloseSqlMapDAO selectIdBeforeUpdate END");
		return getSqlSession().selectList(sqlId,paramMap);
	}
	/**
	 * 재고마감 정보 삭제
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateStockClose(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO updateStockClose START");
		String sqlId = "WebStockClose.updateStockClose";
		logger.debug("WebStockCloseSqlMapDAO insertStockClose END");
		return getSqlSession().update(sqlId, paramMap);
	}
	/**
	 * 재고마감 상세정보 삭제
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateStockCloseDetail(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseSqlMapDAO updateStockCloseDetail START");
		String sqlId = "WebStockClose.updateStockCloseDetail";
		logger.debug("WebStockCloseSqlMapDAO updateStockCloseDetail END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
