Просмотр исходного кода

防止表格最后页最后项删除变成暂无数据

RuoYi лет назад: 4
Родитель
Сommit
bb30ae7086

+ 16 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java

@@ -64,6 +64,22 @@ public class ServletUtils
64 64
     }
65 65
 
66 66
     /**
67
+     * 获取Boolean参数
68
+     */
69
+    public static Boolean getParameterToBool(String name)
70
+    {
71
+        return Convert.toBool(getRequest().getParameter(name));
72
+    }
73
+
74
+    /**
75
+     * 获取Boolean参数
76
+     */
77
+    public static Boolean getParameterToBool(String name, Boolean defaultValue)
78
+    {
79
+        return Convert.toBool(getRequest().getParameter(name), defaultValue);
80
+    }
81
+
82
+    /**
67 83
      * 获取request
68 84
      */
69 85
     public static HttpServletRequest getRequest()

+ 2 - 1
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java

@@ -55,7 +55,8 @@ public class BaseController
55 55
         if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
56 56
         {
57 57
             String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
58
-            PageHelper.startPage(pageNum, pageSize, orderBy);
58
+            Boolean reasonable = pageDomain.getReasonable();
59
+            PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
59 60
         }
60 61
     }
61 62
 

+ 17 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java

@@ -21,6 +21,9 @@ public class PageDomain
21 21
     /** 排序的方向desc或者asc */
22 22
     private String isAsc = "asc";
23 23
 
24
+    /** 分页参数合理化 */
25
+    private Boolean reasonable = true;
26
+
24 27
     public String getOrderBy()
25 28
     {
26 29
         if (StringUtils.isEmpty(orderByColumn))
@@ -81,4 +84,18 @@ public class PageDomain
81 84
             this.isAsc = isAsc;
82 85
         }
83 86
     }
87
+
88
+    public Boolean getReasonable()
89
+    {
90
+        if (StringUtils.isNull(reasonable))
91
+        {
92
+            return Boolean.TRUE;
93
+        }
94
+        return reasonable;
95
+    }
96
+
97
+    public void setReasonable(Boolean reasonable)
98
+    {
99
+        this.reasonable = reasonable;
100
+    }
84 101
 }

+ 6 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/TableSupport.java

@@ -30,6 +30,11 @@ public class TableSupport
30 30
     public static final String IS_ASC = "isAsc";
31 31
 
32 32
     /**
33
+     * 分页参数合理化
34
+     */
35
+    public static final String REASONABLE = "reasonable";
36
+
37
+    /**
33 38
      * 封装分页对象
34 39
      */
35 40
     public static PageDomain getPageDomain()
@@ -39,6 +44,7 @@ public class TableSupport
39 44
         pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE));
40 45
         pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
41 46
         pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
47
+        pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
42 48
         return pageDomain;
43 49
     }
44 50