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.SysApprovalBusinessSend;
import com.hzs.common.domain.system.sys.ext.SysApprovalBusinessSendExt;
import com.hzs.system.sys.mapper.SysApprovalBusinessSendMapper;
import com.hzs.system.sys.service.ISysApprovalBusinessSendService;
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 SysApprovalBusinessSendServiceImpl extends ServiceImpl<SysApprovalBusinessSendMapper, SysApprovalBusinessSend> implements ISysApprovalBusinessSendService {

    @Override
    public int insertBatch(Long pkApprovalBusiness, List<Long> sendIdList) {
        return baseMapper.insertBatch(pkApprovalBusiness, sendIdList);
    }

    @Override
    public Map<Long, List<SysApprovalBusinessSendExt>> approvalSendMap(List<Long> pkIdList) {
        Map<Long, List<SysApprovalBusinessSendExt>> resultMap = new HashMap<>();

        List<SysApprovalBusinessSendExt> list = baseMapper.approvalSendList(pkIdList);
        if (CollectionUtil.isNotEmpty(list)) {
            resultMap = list.stream().collect(Collectors.groupingBy(SysApprovalBusinessSendExt::getPkApprovalBusiness));
        }

        return resultMap;
    }

}
