package com.friday.custody.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.friday.custody.entity.FundValuationEntity;
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 2023-04-19 17:33:17
 */
@Mapper
public interface FundValuationDao extends BaseMapper<FundValuationEntity> {

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

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