package com.yeejoin.equipmanage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.entity.VideoImportantEquipment;
import com.yeejoin.equipmanage.common.vo.VideoImportantEquipmentVo;
import com.yeejoin.equipmanage.mapper.VideoImportantEquipmentMapper;
import com.yeejoin.equipmanage.service.IVideoImportantEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author ZeHua Li
 * @date 2020/11/25 15:49
 * @since v2.0
 */
@Service
public class VideoImportantEquipmentServiceImpl extends ServiceImpl<VideoImportantEquipmentMapper,VideoImportantEquipment> implements IVideoImportantEquipmentService {

    @Autowired
    private VideoImportantEquipmentMapper videoImportantEquipmentMapper;

    @Override
    public List<VideoImportantEquipmentVo> getVideoImportantEquipmentList(Map<String, Object> map) {
        return videoImportantEquipmentMapper.getVideoImportantEquipmentList(map);
    }

    @Override
    public List<Map<String, List<VideoImportantEquipmentVo>>> getVideoList(Map<String, Object> map) {
        List<VideoImportantEquipmentVo> videoList = videoImportantEquipmentMapper.getVideoList(map);
        return videoList.stream()
                .collect(Collectors.groupingBy(VideoImportantEquipmentVo::getAddress,LinkedHashMap::new,Collectors.toList()))
                .entrySet().stream()
                .map(entry -> Collections.singletonMap(entry.getKey(), entry.getValue()))
                .collect(Collectors.toList());

    }
}
