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

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.kqapi.admin.mapper.WindowMapper;
import com.ningdatech.kqapi.admin.model.dto.WindowCountByZoneIdDTO;
import com.ningdatech.kqapi.admin.model.entity.Window;
import com.ningdatech.kqapi.admin.service.IWindowService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author WendyYang
 * @since 2024-04-20
 */
@Service
public class WindowServiceImpl extends ServiceImpl<WindowMapper, Window> implements IWindowService {

    @Override
    public Map<Integer, Integer> windowCountByZoneIds(Collection<Integer> zoneIds) {
        if (CollUtil.isEmpty(zoneIds)) {
            return Collections.emptyMap();
        }
        List<WindowCountByZoneIdDTO> counts = baseMapper.selectWindowCountByZoneIds(zoneIds);
        return CollUtils.listToMap(counts, WindowCountByZoneIdDTO::getZoneId,
                WindowCountByZoneIdDTO::getWindowCount);
    }

}
