package com.kri.contact.server.service; import static com.kri.contact.server.common.consts.ContactConstant.REQUEST_SERVICE; import com.kri.common.feature.web.BusinessException; import com.kri.common.feature.web.RequestUserContext; import com.kri.contact.server.common.enums.ListHeaderType; import com.kri.contact.server.common.enums.ListIsUse; import com.kri.contact.server.common.external.notihub.ChannelType; import com.kri.contact.server.common.external.notihub.NotiHubApiClient; import com.kri.contact.server.common.external.notihub.NotiHubBulkSendCreateRequestDto; import com.kri.contact.server.common.external.notihub.NotiHubBulkSendResponseDto; import com.kri.contact.server.common.external.notihub.NotiHubDestInfoDto; import com.kri.contact.server.common.external.notihub.NotiHubSendRequestBulkDto; import com.kri.contact.server.common.external.notihub.NotiHubSendRequestSingleDto; import com.kri.contact.server.common.external.notihub.NotiHubTemplateDto; import com.kri.contact.server.dto.list.ListHeaderDto; import com.kri.contact.server.dto.list.ListSendResultDto; import com.kri.contact.server.dto.message.MessageBulkSendResponseDto; import com.kri.contact.server.dto.message.MessageFailedChunkDto; import com.kri.contact.server.dto.message.MessageSendBulkRequestDto; import com.kri.contact.server.dto.message.MessageSendSingleRequestDto; import com.kri.contact.server.dto.project.ProjectInfoDto; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class MessageResultService { private final NotiHubApiClient notiHubApiClient; public Map findSendResultMap( ChannelType channelTy, String prjctCd, List sids ) { if (sids == null || sids.isEmpty()) { return Collections.emptyMap(); } List sidValues = sids.stream() .filter(Objects::nonNull) .map(String::valueOf) .toList(); if (sidValues.isEmpty()) { return Collections.emptyMap(); } return notiHubApiClient.getLastSendResults(channelTy, REQUEST_SERVICE, prjctCd, sidValues) .stream() .collect(Collectors.toMap( dto -> dto.getSid(), ListSendResultDto::from, (left, right) -> left, LinkedHashMap::new )); } }