From fb9b8e5fb4311a10a77aa7664616f8c41534c160 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 06 十月 2023 15:00:04 +0800
Subject: [PATCH] 解决查询为空报错

---
 src/main/resources/mybatis.xml                                      |    2 +-
 src/main/java/com/smartearth/poiexcel/controller/EntController.java |   24 +++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 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..2d31470 100644
--- a/src/main/java/com/smartearth/poiexcel/controller/EntController.java
+++ b/src/main/java/com/smartearth/poiexcel/controller/EntController.java
@@ -130,6 +130,28 @@
         }
     }
 
+    @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;
+            }
+            List<EntEntity> list = qiYeMapper.selectByPage(pageSize, StaticData.I100 * (pageIndex - 1));
+
+            return success(null == list || list.isEmpty() ? 0 : list.size(), list);
+        } catch (Exception ex) {
+            return fail(ex, -1);
+        }
+    }
+
     @ApiOperation(value = "鎵归噺鏇存柊浼佷笟鍧愭爣")
     @GetMapping({"/updateCoords"})
     public ResponseMsg<Object> updateCoords() {
@@ -141,7 +163,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;
diff --git a/src/main/resources/mybatis.xml b/src/main/resources/mybatis.xml
index f5d64a8..9809915 100644
--- a/src/main/resources/mybatis.xml
+++ b/src/main/resources/mybatis.xml
@@ -29,7 +29,7 @@
         <!--鎸囧畾褰撶粨鏋滈泦涓�间负 null 鏃讹紝鏄惁璋冪敤鏄犲皠瀵硅薄鐨� setter锛坢ap 瀵硅薄鏃朵负 put锛夋柟娉�-->
         <setting name="callSettersOnNulls" value="true"/>
         <!--鎸囧畾 MyBatis 鎵�鐢ㄦ棩蹇楃殑鍏蜂綋瀹炵幇锛歀OG4J/LOG4J2/SLF4J/STDOUT_LOGGING/NO_LOGGING-->
-        <setting name="logImpl" value="STDOUT_LOGGING" />
+        <setting name="logImpl" value="NO_LOGGING" />
     </settings>
     <typeAliases>
         <package name="com.smartearth.poiexcel.entity"/>

--
Gitblit v1.9.3