Browse Source

code style

miemie 4 years ago
parent
commit
500ce8467c

+ 3 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/IPage.java

@@ -195,8 +195,10 @@ public interface IPage<T> extends Serializable {
 
     /**
      * 老分页插件不支持
+     * <p>
+     * MappedStatement 的 id
      *
-     * @return count的method
+     * @return id
      * @since 3.3.3 @2020-06-19
      */
     default String countId() {

+ 15 - 3
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/PaginationInnerInterceptor.java

@@ -122,7 +122,7 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
         }
 
         BoundSql countSql;
-        MappedStatement countMs = buildCountMappedStatement(ms, page);
+        MappedStatement countMs = buildCountMappedStatement(ms, page.countId());
         if (countMs != null) {
             countSql = countMs.getBoundSql(parameter);
         } else {
@@ -194,8 +194,14 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
         return DialectFactory.getDialect(JdbcUtils.getDbType(executor));
     }
 
-    protected MappedStatement buildCountMappedStatement(MappedStatement ms, IPage<?> page) {
-        String countId = page.countId();
+    /**
+     * 获取指定的 id 的 MappedStatement
+     *
+     * @param ms      MappedStatement
+     * @param countId id
+     * @return MappedStatement
+     */
+    protected MappedStatement buildCountMappedStatement(MappedStatement ms, String countId) {
         if (StringUtils.isNotBlank(countId)) {
             final String id = ms.getId();
             if (!countId.contains(StringPool.DOT)) {
@@ -211,6 +217,12 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
         return null;
     }
 
+    /**
+     * 构建 mp 自用自动的 MappedStatement
+     *
+     * @param ms MappedStatement
+     * @return MappedStatement
+     */
     protected MappedStatement buildAutoCountMappedStatement(MappedStatement ms) {
         final String countId = ms.getId() + "_mpCount";
         final Configuration configuration = ms.getConfiguration();

+ 2 - 8
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/Page.java

@@ -59,6 +59,8 @@ public class Page<T> implements IPage<T> {
     /**
      * 排序字段信息
      */
+    @Getter
+    @Setter
     protected List<OrderItem> orders = new ArrayList<>();
 
     /**
@@ -309,14 +311,6 @@ public class Page<T> implements IPage<T> {
         return getOrders();
     }
 
-    public List<OrderItem> getOrders() {
-        return orders;
-    }
-
-    public void setOrders(List<OrderItem> orders) {
-        this.orders = orders;
-    }
-
     @Override
     public boolean optimizeCountSql() {
         return optimizeCountSql;