From a9d6ea06bc8e12fa9f9c78e8c7ce5538b83c6373 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期二, 03 九月 2024 16:08:49 +0800
Subject: [PATCH] 批量操作

---
 src/main/java/com/whyc/util/TestparamHttpUtil.java |   44 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/whyc/util/TestparamHttpUtil.java b/src/main/java/com/whyc/util/TestparamHttpUtil.java
index 9c2e880..af641df 100644
--- a/src/main/java/com/whyc/util/TestparamHttpUtil.java
+++ b/src/main/java/com/whyc/util/TestparamHttpUtil.java
@@ -1,23 +1,61 @@
 package com.whyc.util;
 
 import com.whyc.dto.ResultA200Dto;
+import com.whyc.dto.ResultActmDto;
 import org.springframework.http.*;
 import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestClientException;
 import org.springframework.web.client.RestTemplate;
 
 public class TestparamHttpUtil {
 
 
+
     //post璇锋眰浼犲叆form-data 鏍煎紡
-    public static Object postforform_data( RestTemplate restTemplate,String url,  MultiValueMap<String, Object> paramMap){
+    public static Object postforform_dataA200( RestTemplate restTemplate,String url,  MultiValueMap<String, Object> paramMap){
         HttpHeaders headers = new HttpHeaders();
         HttpMethod method = HttpMethod.POST;
         // 璁剧疆浠ヨ〃鍗曠殑鏂瑰紡鎻愪氦
         headers.add("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE);
         HttpEntity< MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(paramMap, headers);
-        ResponseEntity<String> response = restTemplate.exchange(url, method, requestEntity,String.class );
-        String results= response.getBody();
+        String results= null;
+        try {
+            ResponseEntity<String> response = restTemplate.exchange(url, method, requestEntity,String.class );
+            results = response.getBody();
+        } catch (RestClientException  e) {
+            results=" {\n" +
+                    "      \"code\": \"210\",\n" +
+                    "      \"msg\": \"failed in setting test parameters\",\n" +
+                    "      \"data\": null,\n" +
+                    "      \"count\": 0\n" +
+                    "    }";
+        }
         Object dto= ActionUtil.getGson().fromJson(results, ResultA200Dto.class);
         return dto;
     }
+
+    //post璇锋眰浼犲叆form-data 鏍煎紡
+    public static Object postforform_dataActm( RestTemplate restTemplate,String url,  MultiValueMap<String, Object> paramMap){
+        HttpHeaders headers = new HttpHeaders();
+        HttpMethod method = HttpMethod.POST;
+        // 璁剧疆浠ヨ〃鍗曠殑鏂瑰紡鎻愪氦
+        headers.add("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE);
+        HttpEntity< MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(paramMap, headers);
+        String results= null;
+        try {
+            ResponseEntity<String> response = restTemplate.exchange(url, method, requestEntity,String.class );
+            results = response.getBody();
+        } catch (RestClientException e) {
+            results=" {\n" +
+                    "      \"code\": \"210\",\n" +
+                    "      \"msg\": \"failed in setting test parameters\",\n" +
+                    "      \"data\": null,\n" +
+                    "      \"count\": 0\n" +
+                    "    }";
+        }
+        Object dto= ActionUtil.getGson().fromJson(results, ResultActmDto.class);
+        return dto;
+    }
+
+
 }
\ No newline at end of file

--
Gitblit v1.9.1