package com.friday.custody.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.friday.custody.entity.FundProfitInfoEntity;
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-04 16:12:06
 */
@Mapper
public interface FundProfitInfoDao extends BaseMapper<FundProfitInfoEntity> {
    boolean insertOrUpdate(FundProfitInfoEntity entity);
    default int deleteByUniqueKeys(Set<String> uniqueKeySet){
        LambdaQueryWrapper<FundProfitInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(FundProfitInfoEntity::getUniqueKey, uniqueKeySet);
        return delete(queryWrapper);
    }

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