package com.madeu.dao.web.webuser;

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 WebUserSqlMapDAO extends SqlSessionDaoSupport{
    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

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

    /**
     * 고객 확인 (추천인)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Map<String, Object> checkUser(String recommendId)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO checkUser START");
        String sqlId = "WebUser.checkUser";
        logger.debug("WebUserSqlMapDAO checkUser END");
        return getSqlSession().selectOne(sqlId, recommendId);
    }
    /**
     * 고객 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Integer selectTotalUserCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectTotalUserCount START");
        String sqlId = "WebUser.selectTotalUserCount";
        logger.debug("WebUserSqlMapDAO selectTotalUserCount END");
        return getSqlSession().selectOne(sqlId, paramMap);
    }
    /**
     * 고객 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListUser(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectListUser START");
        String sqlId = "WebUser.selectListUser";
        logger.debug("WebUserSqlMapDAO selectListUser END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 마케팅 - 고객 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Integer selectTotalUserMarketingCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectTotalUserMarketingCount START");
        String sqlId = "WebUser.selectTotalUserMarketingCount";
        logger.debug("WebUserSqlMapDAO selectTotalUserMarketingCount END");
        return getSqlSession().selectOne(sqlId, paramMap);
    }
    /**
     * 마케팅 - 고객 정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListUserMarketing(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectListUserMarketing START");
        String sqlId = "WebUser.selectListUserMarketing";
        logger.debug("WebUserSqlMapDAO selectListUserMarketing END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 마케팅 - 고객 정보 총 갯수 조회 (total count) (푸시)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Integer selectTotalUserMarketingPushCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectTotalUserMarketingPushCount START");
        String sqlId = "WebUser.selectTotalUserMarketingPushCount";
        logger.debug("WebUserSqlMapDAO selectTotalUserMarketingPushCount END");
        return getSqlSession().selectOne(sqlId, paramMap);
    }
    /**
     * 마케팅 - 고객 정보 리스트 조회 (List) (푸시)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListUserMarketingPush(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectListUserMarketingPush START");
        String sqlId = "WebUser.selectListUserMarketingPush";
        logger.debug("WebUserSqlMapDAO selectListUserMarketingPush END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 고객 정보 리스트 조회 (List, Excel)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListUserExcel(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectListUserExcel START");
        String sqlId = "WebUser.selectListUserExcel";
        logger.debug("WebUserSqlMapDAO selectListUserExcel END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 고객 정보 리스트 조회 (List) - (pid)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListUserPid(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectListUserPid START");
        String sqlId = "WebUser.selectListUserPid";
        logger.debug("WebUserSqlMapDAO selectListUserPid END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 고객 정보 체크
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserCheck(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserCheck START");
        String sqlId = "WebUser.selectUserCheck";
        logger.debug("WebUserSqlMapDAO selectUserCheck END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 고객 등록
     *
     * @param Map
     * @throws DataAccessException
     */
    public void insertUser(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO insertUser START");
        String sqlId = "WebUser.insertUser";
        logger.debug("WebUserSqlMapDAO insertUser END");
        getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 고객 등록 배치
     *
     * @param Map
     * @throws DataAccessException
     */
    public void insertUserBatch(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO insertUserBatch START");
        String sqlId = "WebUser.insertUserBatch";
        logger.debug("WebUserSqlMapDAO insertUserBatch END");
        getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 고객 등록 (간편예약고객)
     *
     * @param Map
     * @throws DataAccessException
     */
    public void insertUserTemp(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO insertUserTemp START");
        String sqlId = "WebUser.insertUserTemp";
        logger.debug("WebUserSqlMapDAO insertUserTemp END");
        getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 고객 정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUser(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUser START");
        String sqlId = "WebUser.selectUser";
        logger.debug("WebUserSqlMapDAO selectUser END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 고객 신체정보 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Map<String, Object> selectUserPhysical(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserPhysical START");
        String sqlId = "WebUser.selectUserPhysical";
        logger.debug("WebUserSqlMapDAO selectUserPhysical END");
        return getSqlSession().selectOne(sqlId, paramMap);
    }
    /**
     * 고객 신체정보 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserPhysicalList(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserPhysicalList START");
        String sqlId = "WebUser.selectUserPhysicalList";
        logger.debug("WebUserSqlMapDAO selectUserPhysicalList END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    /**
     * 신체 정보 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Integer selectTotalPhysicalCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectTotalPhysicalCount START");
        String sqlId = "WebUser.selectTotalPhysicalCount";
        logger.debug("WebUserSqlMapDAO selectTotalPhysicalCount END");
        return getSqlSession().selectOne(sqlId, paramMap);
    }
    /**
     * 고객 신체정보 리스트 조회 (List, Excel)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserPhysicalListExcel(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserPhysicalListExcel START");
        String sqlId = "WebUser.selectUserPhysicalListExcel";
        logger.debug("WebUserSqlMapDAO selectUserPhysicalListExcel END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 신체정보 상세 조회 (one)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserPhysical2(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserPhysical2 START");
        String sqlId = "WebUser.selectUserPhysical2";
        logger.debug("WebUserSqlMapDAO selectUserPhysical2 END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 식별자 조회 (one, 고객명/전화번호로 조회)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserId(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserId START");
        String sqlId = "WebUser.selectUserId";
        logger.debug("WebUserSqlMapDAO selectUserId END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 최근 한달 내 내원 고객 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectListUserVisitLastMonthAll(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectListUserVisitLastMonthAll START");
        String sqlId = "WebUser.selectListUserVisitLastMonthAll";
        logger.debug("WebUserSqlMapDAO selectListUserVisitLastMonthAll END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 검색 (상단)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserSearch(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserSearch START");
        String sqlId = "WebUser.selectUserSearch";
        logger.debug("WebUserSqlMapDAO selectUserSearch END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 - 동의서 서명 조회
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserAgreementFile(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserAgreementFile START");
        String sqlId = "WebUser.selectUserAgreementFile";
        logger.debug("WebUserSqlMapDAO selectUserAgreementFile END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 - 인바디 신체정보 등록여부 확인
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserPhysicalInbodyDateTimes(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserPhysicalInbodyDateTimes START");
        String sqlId = "WebUser.selectUserPhysicalInbodyDateTimes";
        logger.debug("WebUserSqlMapDAO selectUserPhysicalInbodyDateTimes END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateUser(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO updateUser START");
        String sqlId = "WebUser.updateUser";
        logger.debug("WebUserSqlMapDAO updateUser END");
        return getSqlSession().update(sqlId, paramMap);
    }
    
    /**
     * 고객 최근내원일자 정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateUserLastVisitDate(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO updateUserLastVisitDate START");
        String sqlId = "WebUser.updateUserLastVisitDate";
        logger.debug("WebUserSqlMapDAO updateUserLastVisitDate END");
        return getSqlSession().update(sqlId, paramMap);
    }
    
    /**
     * 고객 멤버십정보 수정
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateMembershipYn(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO updateMembershipYn START");
        String sqlId = "WebUser.updateMembershipYn";
        logger.debug("WebUserSqlMapDAO updateMembershipYn END");
        return getSqlSession().update(sqlId, paramMap);
    }

    /**
     * 고객 멤버십정보 수정 (배치)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateMembershipYnBatch(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO updateMembershipYnBatch START");
        String sqlId = "WebUser.updateMembershipYnBatch";
        logger.debug("WebUserSqlMapDAO updateMembershipYnBatch END");
        return getSqlSession().update(sqlId, paramMap);
    }
    /**
     * 고객 신체정보 등록
     *
     * @param Map
     * @throws DataAccessException
     */
    public void insertPhysical(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO insertPhysical START");
        String sqlId = "WebUser.insertPhysical";
        logger.debug("WebUserSqlMapDAO insertPhysical END");
        getSqlSession().insert(sqlId, paramMap);
    }
    
    /**
     * 고객 신체정보 수정 (담당자)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public int updateUserPhysical(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO updateUserPhysical START");
        String sqlId = "WebUser.updateUserPhysical";
        logger.debug("WebUserSqlMapDAO updateUserPhysical END");
        return getSqlSession().update(sqlId, paramMap);
    }
    
    /**
     * 고객 동의서 등록
     *
     * @param Map
     * @throws DataAccessException
     */
    public void insertUserAgreement(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO insertUserAgreement START");
        String sqlId = "WebUser.insertUserAgreement";
        logger.debug("WebUserSqlMapDAO insertUserAgreement END");
        getSqlSession().insert(sqlId, paramMap);
    }

    /**
     * 고객 동의서 리스트 조회 (List)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserAgreementList(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserAgreementList START");
        String sqlId = "WebUser.selectUserAgreementList";
        logger.debug("WebUserSqlMapDAO selectUserAgreementList END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
    
    /**
     * 고객 동의서 총 갯수 조회 (total count)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public Integer selectTotalAgreementCount(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectTotalAgreementCount START");
        String sqlId = "WebUser.selectTotalAgreementCount";
        logger.debug("WebUserSqlMapDAO selectTotalAgreementCount END");
        return getSqlSession().selectOne(sqlId, paramMap);
    }
    
    /**
     * 고객 동의서 리스트 조회 (List, Excel)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserAgreementListExcel(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserAgreementListExcel START");
        String sqlId = "WebUser.selectUserAgreementListExcel";
        logger.debug("WebUserSqlMapDAO selectUserAgreementListExcel END");
        return getSqlSession().selectList(sqlId, paramMap);
    }

    /**
     * 고객 동의서 상세 조회 (one)
     *
     * @param Map
     * @return
     * @throws DataAccessException
     */
    public List<Map<String, Object>> selectUserAgreement(HashMap<String, Object> paramMap)
            throws DataAccessException {
        logger.debug("WebUserSqlMapDAO selectUserAgreement START");
        String sqlId = "WebUser.selectUserAgreement";
        logger.debug("WebUserSqlMapDAO selectUserAgreement END");
        return getSqlSession().selectList(sqlId, paramMap);
    }
}
