From b7f0283f5b7506013e890a55f3adf849457f7e9d Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 07 十月 2023 09:43:28 +0800
Subject: [PATCH] 支持跨域访问

---
 src/main/java/com/smartearth/poiexcel/controller/EntController.java |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/smartearth/poiexcel/controller/EntController.java b/src/main/java/com/smartearth/poiexcel/controller/EntController.java
index 025ac18..cd1bd57 100644
--- a/src/main/java/com/smartearth/poiexcel/controller/EntController.java
+++ b/src/main/java/com/smartearth/poiexcel/controller/EntController.java
@@ -15,7 +15,6 @@
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -34,6 +33,7 @@
 @Api(tags = "浼佷笟鎺у埗鍣�")
 @RestController
 @RequestMapping("/ent")
+@SuppressWarnings("ALL")
 public class EntController extends BaseController {
     @Resource
     EntService entService;
@@ -47,6 +47,21 @@
     @Value("${address.code.url}")
     private String addressCodeUrl;
 
+    @ApiOperation(value = "鏍规嵁鍚嶇О妯$硦鏌ヨ浼佷笟")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "浼佷笟鍚嶇О鎴栧湴鍧�", dataType = "String", paramType = "query", example = "")
+    })
+    @GetMapping({"/selectByName"})
+    public ResponseMsg<Object> selectByName(String name) {
+        try {
+            List<EntEntity> list = qiYeMapper.selectByName(StringHelper.getLikeStr(name));
+
+            return success(null == list ? 0 : list.size(), list);
+        } catch (Exception ex) {
+            return fail(ex, -1);
+        }
+    }
+
     @ApiOperation(value = "鏌ヨ浠ょ墝")
     @GetMapping({"/selectToken"})
     public ResponseMsg<Object> selectToken() {
@@ -59,7 +74,7 @@
         }
     }
 
-    @ApiOperation(value = "鏌ヨ浼佷笟")
+    @ApiOperation(value = "鏌ヨ浼佷笟淇℃伅")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "token", value = "浠ょ墝", dataType = "String", paramType = "query", example = ""),
             @ApiImplicitParam(name = "startDate", value = "寮�濮嬫棩鏈�", dataType = "String", paramType = "query", example = "2023-06-29"),
@@ -130,6 +145,29 @@
         }
     }
 
+    @ApiOperation(value = "鍒嗛〉鏌ヨ浼佷笟")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"),
+            @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1")
+    })
+    @GetMapping(value = "/selectByPage")
+    public ResponseMsg<Object> selectByPage(Integer pageSize, Integer pageIndex) {
+        try {
+            if (null == pageSize || pageSize < 1) {
+                pageSize = 10;
+            }
+            if (null == pageIndex || pageIndex < 1) {
+                pageIndex = 1;
+            }
+            int count = qiYeMapper.selectCount();
+            List<EntEntity> list = qiYeMapper.selectByPage(pageSize, StaticData.I100 * (pageIndex - 1));
+
+            return success(count, list);
+        } catch (Exception ex) {
+            return fail(ex, -1);
+        }
+    }
+
     @ApiOperation(value = "鎵归噺鏇存柊浼佷笟鍧愭爣")
     @GetMapping({"/updateCoords"})
     public ResponseMsg<Object> updateCoords() {
@@ -141,7 +179,7 @@
             }
 
             int pages = (count - 1) / StaticData.I100 + 1;
-            for (int i = 0; i < pages; i++) {
+            for (int i = 1; i <= pages; i++) {
                 List<EntEntity> list = qiYeMapper.selectByPage(StaticData.I100, StaticData.I100 * (i - 1));
                 if (null == list || list.isEmpty()) {
                     continue;
@@ -183,7 +221,7 @@
             }
 
             JSONObject object = jsonArray.getJSONObject(0);
-            String addr = object.getString("formatted_address");
+            /*String addr = object.getString("formatted_address");
             if (StringHelper.isEmpty(addr)) {
                 return;
             }
@@ -192,12 +230,12 @@
             if (encoding != null) {
                 addr = new String(addr.getBytes(encoding));
             }
-            // ent.setAddress(addr)
+            ent.setAddress(addr);*/
 
             String location = object.getString("location");
             String[] split = location.split(",");
-            ent.setX(Double.parseDouble(split[1]));
-            ent.setY(Double.parseDouble(split[0]));
+            ent.setX(Double.parseDouble(split[0]));
+            ent.setY(Double.parseDouble(split[1]));
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);
         }

--
Gitblit v1.9.3