package com.madeu.dao.web.webcompanyproduct;

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

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 거래처 제품 정보 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListCompanyProduct(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebCompanyProductSqlMapDAO selectListCompanyProduct START");
		String sqlId = "WebCompanyProduct.selectListCompanyProduct";
		logger.debug("WebCompanyProductSqlMapDAO selectListCompanyProduct END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 거래처 정보 및 제품 정보 상세 조회 (one)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectCompanyProduct(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebCompanyProductSqlMapDAO selectCompanyProduct START");
		String sqlId = "WebCompanyProduct.selectCompanyProduct";
		logger.debug("WebCompanyProductSqlMapDAO selectCompanyProduct END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 거래처 제품 연결 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertCompanyProduct(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebCompanyProductSqlMapDAO insertCompanyProduct START");
		String sqlId = "WebCompanyProduct.insertCompanyProduct";
		logger.debug("WebCompanyProductSqlMapDAO insertCompanyProduct END");
		return getSqlSession().insert(sqlId, paramMap);
	}
	
	/**
	 * 거래처 제품 연결 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteCompanyProduct(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebCompanyProductSqlMapDAO deleteCompanyProduct START");
		String sqlId = "WebCompanyProduct.deleteCompanyProduct";
		logger.debug("WebCompanyProductSqlMapDAO deleteCompanyProduct END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
