package com.friday.custody.dao;

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

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

/**
 * 费用计提明细表（charge_fee_detail_info）
 * 
 * @author chenyy K2511571
 * @date 2022-07-14 15:52:59
 */
@Mapper
public interface ChargeFeeDetailInfoDao extends BaseMapper<ChargeFeeDetailInfoEntity> {

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

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