package com.ningdatech.carapi.safe.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.carapi.safe.entity.NdInsureInfo;
import com.ningdatech.carapi.safe.mapper.NdInsureInfoMapper;
import com.ningdatech.carapi.safe.service.INdInsureInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-10-12
 */
@Service
public class NdInsureInfoServiceImpl extends ServiceImpl<NdInsureInfoMapper, NdInsureInfo>
        implements INdInsureInfoService {

    @Override
    public Map<Long, NdInsureInfo> listInsureCompanyByCompanyIds(Collection<Long> companyIds) {
        if(CollectionUtils.isEmpty(companyIds)){
            return Collections.emptyMap();
        }
        List<NdInsureInfo> ndInsureInfos = list(Wrappers.lambdaQuery(NdInsureInfo.class)
                .in(NdInsureInfo::getCompanyId, companyIds));
        return CollUtils.listToMap(ndInsureInfos,NdInsureInfo::getCompanyId);
    }
}
