package com.cool.store.dao;

import com.cool.store.entity.HyPartnerUserChannelDO;
import com.cool.store.mapper.HyPartnerUserChannelMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author suzhuhong
 * @Date 2023/8/21 11:38
 * @Version 1.0
 */
@Repository
public class HyPartnerUserChannelDAO {

    @Resource
    HyPartnerUserChannelMapper hyPartnerUserChannelMapper;

    public Map<Integer, String> getChannelMapByIds(List<Integer> userChannelIds){
        if (CollectionUtils.isEmpty(userChannelIds)){
            return new HashMap<>(1);
        }
        List<HyPartnerUserChannelDO> userChannelList = hyPartnerUserChannelMapper.getUserChannelByIds(userChannelIds);
        Map<Integer, String> channelMap = userChannelList.stream().filter(date->date.getChannelId()!=null).collect(Collectors.toMap(x->x.getChannelId().intValue(), HyPartnerUserChannelDO::getChannelName));
        return channelMap;
    }




}
