package com.friday.custody.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.friday.custody.entity.FundTempFareInfoEntity;
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;

/**
 * 基金估值表费用信息表
 * 
 * @author lyb
 * @email k0051582@gmail.com
 * @date 2022-03-21 10:45:52
 */
@Mapper
public interface FundTempFareInfoDao extends BaseMapper<FundTempFareInfoEntity> {

    @Deprecated
    boolean insertOrUpdate(FundTempFareInfoEntity entity);

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

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

}
