REQ-2233: 运营需求
This commit is contained in:
parent
69703c4c4b
commit
300a17685b
@ -4,12 +4,12 @@ import cn.axzo.im.center.api.vo.resp.MessageDispatchResp;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static java.util.function.Function.identity;
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
import static java.util.stream.Collectors.toMap;
|
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,7 +18,7 @@ import static java.util.stream.Collectors.toSet;
|
|||||||
public class BatchSendResult {
|
public class BatchSendResult {
|
||||||
|
|
||||||
private final Set<Long> requestPersonIds;
|
private final Set<Long> requestPersonIds;
|
||||||
private final Map<Long, MessageDispatchResp> personId2SendResult;
|
private final Map<Long, List<MessageDispatchResp>> personId2SendResult;
|
||||||
|
|
||||||
BatchSendResult(Set<String> requestPersonIds) {
|
BatchSendResult(Set<String> requestPersonIds) {
|
||||||
this(requestPersonIds, Collections.emptyList());
|
this(requestPersonIds, Collections.emptyList());
|
||||||
@ -31,10 +31,10 @@ public class BatchSendResult {
|
|||||||
this.personId2SendResult = respList.stream()
|
this.personId2SendResult = respList.stream()
|
||||||
// [2024.1.16]: im端在处理逐条发送和批量发送时的逻辑不一致, 批量发送时没有返回msgId -_-
|
// [2024.1.16]: im端在处理逐条发送和批量发送时的逻辑不一致, 批量发送时没有返回msgId -_-
|
||||||
.filter(r -> r.getPersonId() != null)
|
.filter(r -> r.getPersonId() != null)
|
||||||
.collect(toMap(r -> Long.valueOf(r.getPersonId()), identity()));
|
.collect(groupingBy(r -> Long.valueOf(r.getPersonId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<MessageDispatchResp> findSendResult(Long personId) {
|
public Optional<List<MessageDispatchResp>> findSendResult(Long personId) {
|
||||||
return Optional.ofNullable(personId2SendResult.get(personId));
|
return Optional.ofNullable(personId2SendResult.get(personId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,13 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.util.function.Function.identity;
|
import static java.util.function.Function.identity;
|
||||||
|
import static java.util.stream.Collectors.joining;
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,8 +89,10 @@ public class MessageMappingProcessor implements EventMappingProcessor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String imMessageId = batchResult.findSendResult(personId)
|
String imMessageId = batchResult.findSendResult(personId)
|
||||||
|
.orElse(new ArrayList<>())
|
||||||
|
.stream()
|
||||||
.map(MessageDispatchResp::getMsgid)
|
.map(MessageDispatchResp::getMsgid)
|
||||||
.orElse(null);
|
.collect(joining(","));
|
||||||
// 把im端的id也存起来
|
// 把im端的id也存起来
|
||||||
messageRecordV3Dao.setSendSuccess(message.getId(), imMessageId);
|
messageRecordV3Dao.setSendSuccess(message.getId(), imMessageId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package cn.axzo.msg.center.api;
|
||||||
|
|
||||||
|
import cn.axzo.msg.center.MsgCenterApplication;
|
||||||
|
import cn.axzo.msg.center.api.request.v3.MessageSendReqV3;
|
||||||
|
import cn.axzo.msg.center.service.dto.PersonV3DTO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglin
|
||||||
|
*/
|
||||||
|
@SpringBootTest(classes = MsgCenterApplication.class)
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
|
class MessageAPIV3Test {
|
||||||
|
private final MessageAPIV3 messageAPIV3;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void foo() throws Exception {
|
||||||
|
MessageSendReqV3 req = new MessageSendReqV3();
|
||||||
|
req.setSender(new PersonV3DTO(-99L));
|
||||||
|
req.setReceivers(Arrays.asList(new PersonV3DTO(2810L)));
|
||||||
|
req.setBizEventMappingCode("operator_news");
|
||||||
|
req.setBizCode("operator_news");
|
||||||
|
messageAPIV3.send(req);
|
||||||
|
|
||||||
|
Thread.sleep(100000L);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user