REQ-3828: 更新卡片
This commit is contained in:
parent
53e9035ba5
commit
331ad20d83
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.dal;
|
||||
|
||||
import cn.axzo.im.center.api.vo.PersonAccountAttribute;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageTaskResp;
|
||||
import cn.axzo.im.center.api.vo.resp.UpdatableMessageSendResult;
|
||||
import cn.axzo.msg.center.dal.mapper.CardMapper;
|
||||
@ -15,9 +16,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
@ -51,15 +54,24 @@ public class CardDao extends ServiceImpl<CardMapper, Card> {
|
||||
public void setSendSuccess(List<Card> cards, MessageTaskResp imResponse) {
|
||||
ArrayList<Card> updates = new ArrayList<>();
|
||||
List<UpdatableMessageSendResult> sendResults = imResponse.getUpdatableMessageSendResults();
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
Card card = cards.get(i);
|
||||
Map<PersonAccountAttribute, String> account2BizMessageId = sendResults.stream()
|
||||
.collect(toMap(UpdatableMessageSendResult::getAccount, UpdatableMessageSendResult::getBizMessageId));
|
||||
for (Card card : cards) {
|
||||
PersonAccountAttribute key = new PersonAccountAttribute();
|
||||
key.setPersonId(card.getReceiverPersonId() + "");
|
||||
key.setOuId(card.getReceiverOuId());
|
||||
key.setWorkspaceId(card.getReceiverWorkspaceId());
|
||||
key.setAppType(card.getReceiverAppType());
|
||||
|
||||
String bizMessageId = account2BizMessageId.get(key);
|
||||
if (bizMessageId == null) {
|
||||
log.info("setSendSuccess: card[{}] not found bizMessageId", card.getId());
|
||||
continue;
|
||||
}
|
||||
Card update = new Card();
|
||||
update.setId(card.getId());
|
||||
update.setImTaskId(imResponse.getId());
|
||||
if (sendResults != null && i < sendResults.size()) {
|
||||
UpdatableMessageSendResult sendResult = sendResults.get(i);
|
||||
update.setBizMessageId(sendResult.getBizMessageId());
|
||||
}
|
||||
update.setBizMessageId(bizMessageId);
|
||||
updates.add(update);
|
||||
}
|
||||
updateBatchById(updates);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user