Переглянути джерело

【CHG】不使用分页全理化

zhaomn 3 роки тому
батько
коміт
a19ae70fa3

+ 1 - 1
pom.xml

@@ -33,7 +33,7 @@
     <swagger.version>3.0.0</swagger.version>
     <swagger-annotations.version>1.6.2</swagger-annotations.version>
     <mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
-    <pagehelper.boot.version>1.3.1</pagehelper.boot.version>
+    <pagehelper.boot.version>1.4.1</pagehelper.boot.version>
     <fastjson.version>1.2.78</fastjson.version>
     <oshi.version>5.8.0</oshi.version>
     <jna.version>5.8.0</jna.version>

+ 1 - 0
railway-admin/src/main/resources/application-dev.yml

@@ -158,6 +158,7 @@ pagehelper:
   helperDialect: mysql
   supportMethodsArguments: true
   params: count=countSql
+  reasonable: false
 
 # Swagger配置
 swagger:

+ 1 - 0
railway-admin/src/main/resources/application-local.yml

@@ -159,6 +159,7 @@ pagehelper:
   #使用方法可以参考测试代码中的com.github.pagehelper.test.basic包下的 ArgumentsMapTest和ArgumentsObjTest。
   supportMethodsArguments: true
   params: count=countSql
+  reasonable: false
 
 # Swagger配置
 swagger:

+ 1 - 0
railway-admin/src/main/resources/application-prod.yml

@@ -163,6 +163,7 @@ pagehelper:
   #影响:自定义分页排序时,会自动取 orderBy 字段值作为排序字段,如果与表字段不一致,需要在程序中显式调整
   supportMethodsArguments: true
   params: count=countSql
+  reasonable: false
 
 # Swagger配置
 swagger:

+ 3 - 3
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcabServiceImpl.java

@@ -75,7 +75,7 @@ public abstract class BusJcabServiceImpl {
     Field[] fields = BusJcab.class.getDeclaredFields();
     List<String> fieldList = Arrays.stream(fields).map(Field::getName).collect(Collectors.toList());
     // 如果排序字段不是BusJcab类的属性时,取默认排序字段
-    log.debug("前端指定的排序字段 - {}", jcab.getOrderBy());
+    // log.debug("前端指定的排序字段 - {}", jcab.getOrderBy())
     if (StringUtils.isNotEmpty(jcab.getOrderBy())) {
       if (JcebOrderFieldEnum.OPERATION_DATE.getAttribute().equals(jcab.getOrderBy())
           || JcebOrderFieldEnum.OPERATION_DATE.getField().equals(jcab.getOrderBy())
@@ -85,7 +85,7 @@ public abstract class BusJcabServiceImpl {
       } else if (fieldList.contains(jcab.getOrderBy())) {
         jcab.setOrderBy(SqlUtil.humpToLine(jcab.getOrderBy()));
       } else {
-        log.info("排序字段名在当前表不存在 - {}", jcab.getOrderBy());
+        // log.info("排序字段名在当前表不存在 - {}", jcab.getOrderBy())
         jcab.setOrderBy(JcebOrderFieldEnum.CHECK_DATE.getField());
       }
     } else {
@@ -93,7 +93,7 @@ public abstract class BusJcabServiceImpl {
       jcab.setOrderBy(JcebOrderFieldEnum.CHECK_DATE.getField());
       jcab.setIsAsc(SortTypeEnum.DESC.getCode());
     }
-    log.debug("最终使用的排序字段 - {}", jcab.getOrderBy());
+    // log.debug("最终使用的排序字段 - {}", jcab.getOrderBy())
   }
 
   /**

+ 3 - 1
railway-common/src/main/java/com/railway/common/core/controller/BaseController.java

@@ -1,5 +1,6 @@
 package com.railway.common.core.controller;
 
+import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.railway.common.constant.HttpStatus;
@@ -49,7 +50,8 @@ public class BaseController {
     if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
       String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
       Boolean reasonable = pageDomain.getReasonable();
-      PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
+      Page page = PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
+      System.out.println(page.getPageNum());
     }
   }
 

+ 3 - 3
railway-common/src/main/java/com/railway/common/core/page/PageDomain.java

@@ -39,9 +39,9 @@ public class PageDomain {
   private String isAsc = "asc";
 
   /**
-   * 分页参数合理化
+   * 设置默认值为true时,执行分页参数合理化
    */
-  private Boolean reasonable = true;
+  private Boolean reasonable = false;
 
   public String getOrderBy() {
     if (StringUtils.isEmpty(orderByColumn)) {
@@ -64,7 +64,7 @@ public class PageDomain {
 
   public Boolean getReasonable() {
     if (StringUtils.isNull(reasonable)) {
-      return Boolean.TRUE;
+      return Boolean.FALSE;
     }
     return reasonable;
   }