From 8853292babb2ad94de4a3207966f1e83b767cd2d Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Sun, 17 Sep 2023 16:38:34 +0800
Subject: [PATCH] 新增流程节点进程查询接口
---
src/main/java/org/springblade/common/utils/HttpReqUtil.java | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/common/utils/HttpReqUtil.java b/src/main/java/org/springblade/common/utils/HttpReqUtil.java
index 39f99a0..3242d0d 100644
--- a/src/main/java/org/springblade/common/utils/HttpReqUtil.java
+++ b/src/main/java/org/springblade/common/utils/HttpReqUtil.java
@@ -107,6 +107,21 @@
return postJson(url, json, header);
}
+ public String doPostJsons(String url, Map<String, Object> params, Map<String, String> header) throws Exception {
+ String json = null;
+ if (params != null && !params.isEmpty()) {
+ for (Iterator<Entry<String, Object>> it = params.entrySet().iterator(); it.hasNext();) {
+ Entry<String, Object> entry = (Entry<String, Object>) it.next();
+ Object object = entry.getValue();
+ if (object == null) {
+ it.remove();
+ }
+ }
+ json = JSON.toJSONString(params);
+ }
+ return postJsons(url, json, header);
+ }
+
public String doPostJson(String url, String json) throws Exception {
return doPostJson(url, json, null);
}
@@ -144,6 +159,35 @@
return body;
}
+ private String postJsons(String url, String json, Map<String, String> header) throws Exception {
+ String body = null;
+ try {
+ // Post请求
+ LOG.debug(" protocol: POST");
+ LOG.debug(" url: " + url);
+ HttpPost httpPost = new HttpPost(url.trim());
+ // 设置参数
+ LOG.debug(" params: " + json);
+ httpPost.setEntity(new StringEntity(json, ContentType.DEFAULT_TEXT.withCharset(charset)));
+ httpPost.setHeader(new BasicHeader("Content-Type", "application/json"));
+ LOG.debug(" type: JSON");
+ // 设置Header
+ if (header != null && !header.isEmpty()) {
+ LOG.debug(" header: " + JSON.toJSONString(header));
+ for (Iterator<Entry<String, String>> it = header.entrySet().iterator(); it.hasNext();) {
+ Entry<String, String> entry = (Entry<String, String>) it.next();
+ httpPost.setHeader(new BasicHeader(entry.getKey(), entry.getValue()));
+ }
+ }
+ // 发送请求,获取返回数据
+ body = execute(httpPost);
+ } catch (Exception e) {
+ throw e;
+ }
+ LOG.debug(" result: " + body);
+ return body;
+ }
+
/**
* get请求
*/
--
Gitblit v1.9.3