package com.madeu.dao.web.webstockclosedetail;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

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

	/**
	 * 재고마감 상세 리스트 조회 (List, Excel)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListStockCloseDetailExcel(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseDetailSqlMapDAO selectListStockCloseDetailExcel START");
		String sqlId = "WebStockCloseDetail.selectListStockCloseDetailExcel";
		logger.debug("WebStockCloseDetailSqlMapDAO selectListStockCloseDetailExcel END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 재고마감 상세 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertStockCloseDetail(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseDetailSqlMapDAO insertStockCloseDetail START");
		String sqlId = "WebStockCloseDetail.insertStockCloseDetail";
		logger.debug("WebStockCloseDetailSqlMapDAO insertStockCloseDetail END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	/**
	 * 재고마감 재고품목수, 품목별 재고수, 거래처수, 재고총액 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalStockCloseDetail(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebStockCloseDetailSqlMapDAO selectTotalStockCloseDetail START");
		String sqlId = "WebStockCloseDetail.selectTotalStockCloseDetail";
		logger.debug("WebStockCloseDetailSqlMapDAO selectTotalStockCloseDetail END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 데이터 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public Map<String, Object> selectDate(HashMap<String, Object> paramMap)	throws DataAccessException {
		logger.debug("WebStockCloseDetailSqlMapDAO selectDate START");
		String sqlId = "WebStockCloseDetail.selectDate";
		logger.debug("WebStockCloseDetailSqlMapDAO selectDate END");
		return getSqlSession().selectOne(sqlId, paramMap);
	}
}
