package com.madeu.dao.web.webtreatmentprocedureproduct;

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

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

    @PostConstruct
    void init() {
        setSqlSessionTemplate(sqlSessionTemplate);
    }

    /**
     * 시술 제품 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListTreatmentProcedureProduct(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebTreatmentProcedureProductSqlMapDAO selectListTreatmentProcedureProduct START");
        String sqlId = "WebTreatmentProcedureProduct.selectListTreatmentProcedureProduct";
        logger.debug("WebTreatmentProcedureProductSqlMapDAO selectListTreatmentProcedureProduct END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 시술 제품 정보 조회 (one)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectTreatmentProcedureProduct(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebTreatmentProcedureProductSqlMapDAO selectTreatmentProcedureProduct START");
        String sqlId = "WebTreatmentProcedureProduct.selectTreatmentProcedureProduct";
        logger.debug("WebTreatmentProcedureProductSqlMapDAO selectTreatmentProcedureProduct END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 시술 제품 정보 등록
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int insertTreatmentProcedureProduct(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebTreatmentProcedureProductSqlMapDAO insertTreatmentProcedureProduct START");
        String sqlId = "WebTreatmentProcedureProduct.insertTreatmentProcedureProduct";
        logger.debug("WebTreatmentProcedureProductSqlMapDAO insertTreatmentProcedureProduct END");
        return getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 시술 제품 정보 삭제
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int deleteTreatmentProcedureProduct(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebTreatmentProcedureProductSqlMapDAO deleteTreatmentProcedureProduct START");
        String sqlId = "WebTreatmentProcedureProduct.deleteTreatmentProcedureProduct";
        logger.debug("WebTreatmentProcedureProductSqlMapDAO deleteTreatmentProcedureProduct END");
        return getSqlSession().update(sqlId, paramMap);
    }
}
