package com.madeu.dao.mobile.mobilemembership;

import jakarta.annotation.PostConstruct;
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 java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class MobileMembershipSqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

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

	/**
	 * 멤버십 잔액 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalMembershipBalance(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO selectTotalMembershipBalance START");
		String sqlId = "MobileMembership.selectTotalMembershipBalance";
		logger.debug("MobileMembershipSqlMapDAO selectTotalMembershipBalance END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 멤버십 사용내역 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListMembershipUseCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipUseCount START");
		String sqlId = "MobileMembership.selectListMembershipUseCount";
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipUseCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}


	/**
	 * 멤버십 사용내역 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListMembershipUse(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipUse START");
		String sqlId = "MobileMembership.selectListMembershipUse";
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipUse END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 멤버십 충전내역 정보 총 갯수 조회 (total count)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListMembershipChargeCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipChargeCount START");
		String sqlId = "MobileMembership.selectListMembershipChargeCount";
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipChargeCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}


	/**
	 * 멤버십 충전내역 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListMembershipCharge(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipCharge START");
		String sqlId = "MobileMembership.selectListMembershipCharge";
		logger.debug("MobileMembershipSqlMapDAO selectListMembershipCharge END");
		return getSqlSession().selectList(sqlId, paramMap);
	}



	/**
	 * 멤버십 가입 정보 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateMembershipYn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO updateMembershipYn START");
		String sqlId = "MobileMembership.updateMembershipYn";
		logger.debug("MobileMembershipSqlMapDAO updateMembershipYn END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 멤버십 정보 수정
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateMembership(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO updateMembership START");
		String sqlId = "MobileMembership.updateMembership";
		logger.debug("MobileMembershipSqlMapDAO updateMembership END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 멤버십 내역 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertMembership(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO insertMembership START");
		String sqlId = "MobileMembership.insertMembership";
		logger.debug("MobileMembershipSqlMapDAO insertMembership END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 멤버십 내역 정보 등록
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertDevice(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("MobileMembershipSqlMapDAO insertDevice START");
		String sqlId = "MobileMembership.insertDevice";
		logger.debug("MobileMembershipSqlMapDAO insertDevice END");
		return getSqlSession().insert(sqlId, paramMap);
	}

}
