package com.pcloud.book.personalstage.dao.impl;

import com.pcloud.book.personalstage.dao.UserReplaceCodeDao;
import com.pcloud.book.personalstage.entity.UserReplaceCode;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Component("userReplaceCodeDao")
public class UserReplaceCodeDaoImpl extends BaseDaoImpl<UserReplaceCode> implements UserReplaceCodeDao {
    @Override
    public List<UserReplaceCode> getLastUserReplace(String wxId, String robotId) {
        Map<String,Object> map=new HashMap<>();
        map.put("wxId",wxId);
        map.put("robotId",robotId);
        return super.getSqlSession().selectList(getStatement("getLastUserReplace"),map);
    }

    @Override
    public List<String> getUserReplaceRecordByCodeId(String wxId, String robotId, Long codeId) {
        Map<String,Object> map=new HashMap<>();
        map.put("wxId",wxId);
        map.put("robotId",robotId);
        map.put("replaceCodeId",codeId);
        return super.getSqlSession().selectList(getStatement("getUserReplaceRecordByCodeId"),map);
    }

    @Override
    public UserReplaceCode getLastUserReplaceByCodeId(String wxId, String robotId, Long replaceCodeId) {
        Map<String,Object> map=new HashMap<>();
        map.put("wxId",wxId);
        map.put("robotId",robotId);
        map.put("replaceCodeId",replaceCodeId);
        return super.getSqlSession().selectOne(getStatement("getLastUserReplaceByCodeId"),map);
    }

    @Override
    public UserReplaceCode getLastOneUserReplace(String wxId, String robotId, Integer replaceCodeId) {
        Map<String,Object> map=new HashMap<>();
        map.put("wxId",wxId);
        map.put("robotId",robotId);
        map.put("replaceCodeId",replaceCodeId);
        return super.getSqlSession().selectOne(getStatement("getLastOneUserReplace"),map);
    }

}
