|
|
@@ -17,13 +17,14 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class MessageServiceImpl implements MessageService {
|
|
|
+ private final static String BASE_URL = "/message/";
|
|
|
@Autowired
|
|
|
private ServiceUtils serviceUtils;
|
|
|
|
|
|
@Override
|
|
|
public ApiResponseCommon<List<SendMessageResult>> sendTextMessage(Long accountId) {
|
|
|
SendTextMessageRequest request = new SendTextMessageRequest();
|
|
|
- ApiResponseCommon<List<SendMessageResult>> response = serviceUtils.sendPost("/message/SendTextMessage", RequestBaseVo.builder().accountId(accountId).data(request).build(), new TypeReference<ApiResponseCommon<List<SendMessageResult>>>() {});
|
|
|
+ ApiResponseCommon<List<SendMessageResult>> response = serviceUtils.sendPost(BASE_URL + "SendTextMessage", RequestBaseVo.builder().accountId(accountId).data(request).build(), new TypeReference<ApiResponseCommon<List<SendMessageResult>>>() {});
|
|
|
// 第二层:检查每条消息是否真正发送成功
|
|
|
List<SendMessageResult> results = response.getData();
|
|
|
List<String> failedRecipients = new ArrayList<>();
|
|
|
@@ -32,12 +33,10 @@ public class MessageServiceImpl implements MessageService {
|
|
|
failedRecipients.add(result.getToUserName());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (!failedRecipients.isEmpty()) {
|
|
|
String errorMsg = "部分消息发送失败,失败接收人: " + String.join(", ", failedRecipients);
|
|
|
throw new CustomException("发送文本消息部分失败: " + errorMsg);
|
|
|
}
|
|
|
-
|
|
|
return response;
|
|
|
}
|
|
|
}
|