|
@@ -2,7 +2,10 @@ package com.nokia.dingtalkapi.service.impl;
|
|
|
|
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Map.Entry;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
@@ -267,4 +270,39 @@ public class DingTalkServiceImpl implements DingtalkService {
|
|
}
|
|
}
|
|
return (String) token;
|
|
return (String) token;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void recallMessage(String conversationId, List<String> messageIdList) {
|
|
|
|
+ // 请求url
|
|
|
|
+ String url = "https://api.dingtalk.com/v1.0/robot/groupMessages/recall";
|
|
|
|
+ // 请求头
|
|
|
|
+ HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
+ httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
+ httpHeaders.set("x-acs-dingtalk-access-token", getApiToken());
|
|
|
|
+
|
|
|
|
+ Map<String, Object> request = new HashMap<>();
|
|
|
|
+ request.put("openConversationId", conversationId);
|
|
|
|
+ request.put("robotCode", properties.getAppKey());
|
|
|
|
+ request.put("processQueryKeys", messageIdList);
|
|
|
|
+
|
|
|
|
+ HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(request, httpHeaders);
|
|
|
|
+ JsonNode node = restTemplate.postForObject(url, httpEntity, JsonNode.class);
|
|
|
|
+ if (node == null) {
|
|
|
|
+ throw new RuntimeException("钉钉API调用失败,返回值为空...");
|
|
|
|
+ }
|
|
|
|
+ Iterator<JsonNode> elements = node.get("successResult").elements();
|
|
|
|
+ StringBuffer stringBuffer = new StringBuffer();
|
|
|
|
+ stringBuffer.append("撤回成功的列表:");
|
|
|
|
+ while (elements.hasNext()) {
|
|
|
|
+ stringBuffer.append(elements.next()).append(",");
|
|
|
|
+ }
|
|
|
|
+ stringBuffer.deleteCharAt(stringBuffer.length() - 1).append(" === 撤回失败的列表及原因:");
|
|
|
|
+ Iterator<Entry<String, JsonNode>> fields = node.get("failedResult").fields();
|
|
|
|
+ while (fields.hasNext()) {
|
|
|
|
+ Entry<String, JsonNode> entry = fields.next();
|
|
|
|
+ stringBuffer.append(entry.getKey()).append("-->").append(entry.getValue().toString()).append(",");
|
|
|
|
+ }
|
|
|
|
+ stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
|
|
|
+ log.info(stringBuffer.toString());
|
|
|
|
+ }
|
|
}
|
|
}
|