package com.friday.custody.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.friday.custody.entity.PayFeeDetailInfoEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 费用支付明细表（pay_fee_detail_info）
 * 
 * @author K2511571
 * @date 2022-07-14 15:52:59
 */
@Mapper
public interface PayFeeDetailInfoDao extends BaseMapper<PayFeeDetailInfoEntity> {
    boolean insertOrUpdate(PayFeeDetailInfoEntity entity);

    default Set<String> queryUniqueKeyList(List<String> rawUniqueKeyList){
        LambdaQueryWrapper<PayFeeDetailInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(PayFeeDetailInfoEntity::getUniqueKey).in(PayFeeDetailInfoEntity::getUniqueKey, rawUniqueKeyList);
        List<PayFeeDetailInfoEntity> entityList = this.selectList(queryWrapper);
        Set<String> result = entityList.stream().map(PayFeeDetailInfoEntity::getUniqueKey).collect(Collectors.toSet());
        return result;
    }

    default int deleteByUniqueKeys(Set<String> uniqueKeySet){
        LambdaQueryWrapper<PayFeeDetailInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(PayFeeDetailInfoEntity::getUniqueKey, uniqueKeySet);
        return delete(queryWrapper);
    }
}
