package com.ningdatech.pmapi.meeting.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.common.model.entity.CountGroupByDTO;
import com.ningdatech.pmapi.meeting.entity.domain.Meeting;
import com.ningdatech.pmapi.meeting.entity.enumeration.MeetingStatusByDashboard;
import com.ningdatech.pmapi.meeting.mapper.MeetingMapper;
import com.ningdatech.pmapi.meeting.service.IMeetingService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 会议 服务实现类
 * </p>
 *
 * @author WendyYang
 * @since 2022-07-26
 */
@Service
public class MeetingServiceImpl extends ServiceImpl<MeetingMapper, Meeting> implements IMeetingService {

    @Override
    public void stopRandomInvite(Long meetingId) {
        Meeting meeting = new Meeting();
        meeting.setId(meetingId);
        meeting.setInviteStatus(Boolean.TRUE);
        baseMapper.updateById(meeting);
    }

    @Override
    public Map<MeetingStatusByDashboard, Integer> meetingCountSummary(Long createBy) {
        List<CountGroupByDTO<String>> meetingCountSummary = baseMapper.meetingCountSummary(createBy);
        return CollUtils.listToMap(meetingCountSummary, w -> MeetingStatusByDashboard.valueOf(w.getGroupKey()),
                CountGroupByDTO::getTotal);
    }

}
