From 5826bfa3f502f47f46b37b2e18f0b2f90af691a0 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 30 十月 2024 17:00:11 +0800
Subject: [PATCH] 1

---
 src/main/java/com/se/simu/controller/WaterController.java |   63 +++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java
index f8a1bb9..d9b633f 100644
--- a/src/main/java/com/se/simu/controller/WaterController.java
+++ b/src/main/java/com/se/simu/controller/WaterController.java
@@ -2,6 +2,8 @@
 
 import com.se.simu.helper.WebHelper;
 import com.se.simu.service.WaterService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -13,11 +15,12 @@
 import javax.servlet.http.HttpServletResponse;
 
 /**
- * 鍐呮稘鎺у埗鍣�
+ * 鍐呮稘绠$悊
  *
  * @author WWW
  * @date   2024-07-16
  */
+@Api(tags = "鍐呮稘绠$悊")
 @Slf4j
 @RestController
 @RequestMapping("/waterlogging")
@@ -31,17 +34,7 @@
 
     private final static long Y2000 = 949334400000L;
 
-    /**
-     * 鑾峰彇褰撳墠鏃堕棿
-     */
-    @GetMapping("/getTime")
-    public Object getTime() {
-        return System.currentTimeMillis();
-    }
-
-    /**
-     * 鑾峰彇鍏冩暟鎹俊鎭�
-     */
+    @ApiOperation(value = "鑾峰彇鍏冩暟鎹俊鎭�")
     @GetMapping("/{serviceName}/layer.json")
     public void getLayer(@PathVariable String serviceName, HttpServletResponse res) {
         try {
@@ -58,9 +51,7 @@
         }
     }
 
-    /**
-     * 鑾峰彇鍦板舰楂樺害鍥�
-     */
+    @ApiOperation(value = "鑾峰彇鍦板舰楂樺害鍥�")
     @GetMapping("/{serviceName}/terrain")
     public void getTerraMap(@PathVariable String serviceName, Integer width, Integer height, HttpServletResponse res) {
         try {
@@ -77,9 +68,7 @@
         }
     }
 
-    /**
-     * 鑾峰彇姘撮潰楂樺害鍥�
-     */
+    @ApiOperation(value = "鑾峰彇姘撮潰楂樺害鍥�")
     @GetMapping("/{serviceName}/waterMap")
     public void getWaterMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) {
         try {
@@ -96,9 +85,7 @@
         }
     }
 
-    /**
-     * 鑾峰彇姘存祦鍚戞祦閫熷浘
-     */
+    @ApiOperation(value = "鑾峰彇姘存祦鍚戞祦閫熷浘")
     @GetMapping("/{serviceName}/flowMap")
     public void getFlowMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) {
         try {
@@ -115,6 +102,40 @@
         }
     }
 
+    @ApiOperation(value = "鑾峰彇闄嶆按鏇茬嚎鏂囦欢鏇茬嚎鍥�")
+    @GetMapping("/{serviceName}/rainfall.json")
+    public void getRainfall(@PathVariable String serviceName, HttpServletResponse res) {
+        try {
+            if (!validate(serviceName, res)) {
+                return;
+            }
+
+            byte[] bytes = waterService.getRainfall(serviceName);
+
+            WebHelper.writeBytes(bytes, res);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
+        }
+    }
+
+    @ApiOperation(value = "鏍规嵁鍧愭爣鏌ヨ绉按娣卞害")
+    @GetMapping("/{serviceName}/getWaterHeight")
+    public Double getWaterHeight(@PathVariable String serviceName, Double x, Double y, Long timestamp, HttpServletResponse res) {
+        try {
+            if (!validate(serviceName, res)) {
+                return null;
+            }
+
+            // 鏍规嵁鏈嶅姟鍚�+鏃堕棿鎴�+鍧愭爣锛屾煡璇㈠搴旂殑绉按娣卞害
+
+            return 0.0;
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return null;
+        }
+    }
+
     private boolean validate(String serviceName, HttpServletResponse res) {
         if (WebHelper.isEmpty(serviceName)) {
             return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏈嶅姟鍚嶄笉鑳戒负绌�");

--
Gitblit v1.9.3