From c7abd55db79517ccb91c421b7a153781c8f1c2cc Mon Sep 17 00:00:00 2001 From: liujun Date: Sat, 13 Apr 2024 12:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E9=A1=B5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../zcloud/controller/dw/DwController.java | 24 ++++++++++++------- src/main/java/com/zcloud/util/HttpUtil.java | 6 +++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 31ef9d76..235ecb1e 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ javax.servlet javax.servlet-api - 3.1.0 + 4.0.1 provided diff --git a/src/main/java/com/zcloud/controller/dw/DwController.java b/src/main/java/com/zcloud/controller/dw/DwController.java index a8428c27..b520591d 100644 --- a/src/main/java/com/zcloud/controller/dw/DwController.java +++ b/src/main/java/com/zcloud/controller/dw/DwController.java @@ -3,15 +3,16 @@ package com.zcloud.controller.dw; import com.alibaba.fastjson.JSONObject; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.PageData; +import com.zcloud.entity.Page; import com.zcloud.service.dw.DwService; import com.zcloud.service.dw.dto.*; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -@Controller -@RequestMapping(value = "/dw") +@RestController +@RequestMapping(value = "/dingWei") public class DwController extends BaseController { @Resource @@ -28,9 +29,11 @@ public class DwController extends BaseController { public Object getMapList(Page page) throws Exception { PageData pd = this.getPageData(); MapGet mapGet = JSONObject.parseObject(JSONObject.toJSONString(pd), MapGet.class); - mapGet.getPage().setPage(page.getPage()); - mapGet.getPage().setCurrent(page.getCurrent()); - mapGet.getPage().setSize(page.getSize()); + if (mapGet.getPage() == null){ + mapGet.setPage(new com.zcloud.service.dw.dto.Page()); + } + mapGet.getPage().setCurrent(String.valueOf(page.getCurrentPage())); + mapGet.getPage().setSize(String.valueOf(page.getShowCount())); return dwService.getMapList(mapGet); } @@ -45,9 +48,11 @@ public class DwController extends BaseController { public Object getAlarmList(Page page) throws Exception { PageData pd = this.getPageData(); AlarmGet mapGet = JSONObject.parseObject(JSONObject.toJSONString(pd), AlarmGet.class); - mapGet.getPage().setPage(page.getPage()); - mapGet.getPage().setCurrent(page.getCurrent()); - mapGet.getPage().setSize(page.getSize()); + if (mapGet.getPage() == null){ + mapGet.setPage(new com.zcloud.service.dw.dto.Page()); + } + mapGet.getPage().setCurrent(String.valueOf(page.getCurrentPage())); + mapGet.getPage().setSize(String.valueOf(page.getShowCount())); return dwService.getAlarmList(mapGet); } @@ -62,4 +67,5 @@ public class DwController extends BaseController { public Object getDictionary() throws Exception { return dwService.getDictionary(); } + } diff --git a/src/main/java/com/zcloud/util/HttpUtil.java b/src/main/java/com/zcloud/util/HttpUtil.java index 96527907..2cac2b63 100644 --- a/src/main/java/com/zcloud/util/HttpUtil.java +++ b/src/main/java/com/zcloud/util/HttpUtil.java @@ -41,4 +41,10 @@ public class HttpUtil { String result = restTemplate.postForEntity(url, info, String.class).getBody(); return JSONObject.parseObject(result, Map.class); } + + public static Object post(String url) { + RestTemplate restTemplate = new RestTemplate(); + String result = restTemplate.getForObject(url, String.class); + return JSONObject.parseObject(result, Map.class); + } }