Selaa lähdekoodia

微信消息发送

lin 4 vuotta sitten
vanhempi
commit
1eccc4950e

+ 1 - 2
src/main/java/com/zoniot/ccrc/controller/common/CommonController.java

@@ -38,7 +38,7 @@ import java.util.List;
 @Api(tags = "公共模块")
 public class CommonController {
 
-
+    private RestTemplate restTemplate = new RestTemplate();
     @Autowired
     private DeviceTypeService deviceTypeService;
 
@@ -92,7 +92,6 @@ public class CommonController {
             HttpServletRequest httpServletRequest,
             HttpServletResponse httpServletResponse
     ) throws URISyntaxException, IOException {
-        RestTemplate restTemplate=new RestTemplate();
         URI uri = new URI("http", null, server, port, httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), null);
         ResponseEntity<String> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
 

+ 3 - 3
src/main/java/com/zoniot/ccrc/controller/system/DeviceController.java

@@ -38,6 +38,9 @@ import java.util.List;
 @RequestMapping("device")
 @Api(tags = "设备管理")
 public class DeviceController {
+
+    private RestTemplate restTemplate = new RestTemplate();
+
     @Autowired
     private DeviceService deviceService;
 
@@ -131,8 +134,6 @@ public class DeviceController {
             HttpServletRequest httpServletRequest,
             HttpServletResponse httpServletResponse
     ) throws URISyntaxException, IOException {
-        //http://114.135.61.188:58088/api/device/getData
-        RestTemplate restTemplate=new RestTemplate();
         URI uri = new URI("http", null, server, port, httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), null);
         ResponseEntity<String> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
 
@@ -157,7 +158,6 @@ public class DeviceController {
             HttpServletRequest httpServletRequest,
             HttpServletResponse httpServletResponse
     ) throws URISyntaxException, IOException {
-        RestTemplate restTemplate=new RestTemplate();
         URI uri = new URI("http", null, server, port, httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), null);
         ResponseEntity<byte[]> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, byte[].class);