package com.storlead.sales.service.impl.systemrule;

import com.storlead.framework.mybatis.service.impl.MyBaseServiceImpl;
import com.storlead.sales.pojo.entity.customer.CustomerEntity;
import com.storlead.sales.pojo.entity.systemrule.CurrencySettingsEntity;
import com.storlead.sales.mapper.systemrule.CurrencySettingsMapper;
import com.storlead.sales.service.systemrule.CurrencySettingsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 * 币种设置表 服务实现类
 * </p>
 *
 * @author YPZ
 * @since 2024-04-08
 */
@Service
public class CurrencySettingsServiceImpl extends MyBaseServiceImpl<CurrencySettingsMapper, CurrencySettingsEntity> implements CurrencySettingsService {

    @Override
    public Map<Long, CurrencySettingsEntity> getCurrencyMap(Set<Long> currencyIdList) {
        if (!CollectionUtils.isEmpty(currencyIdList)){
            Collection<CurrencySettingsEntity> currencySettingsList = listByIds(currencyIdList);
            if (!CollectionUtils.isEmpty(currencySettingsList)){
                Map<Long, CurrencySettingsEntity> currencySettingsEntityMap = currencySettingsList.stream().collect(Collectors.toMap(CurrencySettingsEntity::getId, currencySettingsEntity -> currencySettingsEntity));
                return currencySettingsEntityMap;
            }
        }
        return null;

    }
}
