package com.ningdatech.kqapi.zzsfw.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.kqapi.admin.model.dto.MatterCountByWindowIdDTO;
import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu;
import com.ningdatech.kqapi.zzsfw.mapper.KqZzsfwMenuMapper;
import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ZPF
 * @since 2023-10-27
 */
@Service
public class KqZzsfwMenuServiceImpl extends ServiceImpl<KqZzsfwMenuMapper, KqZzsfwMenu> implements IKqZzsfwMenuService {

    @Override
    public Map<Integer, Integer> matterCountByWindowIds(Collection<Integer> windowIds) {
        if (CollUtil.isEmpty(windowIds)) {
            return Collections.emptyMap();
        }
        List<MatterCountByWindowIdDTO> matterCountByWindowIds = baseMapper.selectMatterCountByWindowIds(windowIds);
        return CollUtils.listToMap(matterCountByWindowIds,
                MatterCountByWindowIdDTO::getWindowId,
                MatterCountByWindowIdDTO::getMatterCount);
    }
}
