package com.hzs.system.sys.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.domain.system.sys.SysApprovalSend;
import com.hzs.common.domain.system.sys.ext.SysApprovalSendExt;
import com.hzs.system.sys.mapper.SysApprovalSendMapper;
import com.hzs.system.sys.service.ISysApprovalSendService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 审批抄送人表 服务实现类
 *
 * @author hzs
 * @since 2023-04-27
 */
@Service
public class SysApprovalSendServiceImpl extends ServiceImpl<SysApprovalSendMapper, SysApprovalSend> implements ISysApprovalSendService {

    @Override
    public List<SysApprovalSendExt> queryListByApproval(List<Integer> pkApprovalList) {
        return baseMapper.queryListByApproval(pkApprovalList);
    }

    @Override
    public Map<Integer, List<SysApprovalSendExt>> queryApprovalSendMap(List<Integer> pkApprovalList) {
        Map<Integer, List<SysApprovalSendExt>> resultMap = new HashMap<>();

        List<SysApprovalSendExt> sendList = baseMapper.queryListByApproval(pkApprovalList);

        if (CollectionUtil.isNotEmpty(sendList)) {
            resultMap = sendList.stream().collect(Collectors.groupingBy(SysApprovalSendExt::getPkApproval));
        }

        return resultMap;
    }

}
