From 69b9a4db2b76d201f92c2f98114fd13cf6ef4e71 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期六, 15 五月 2021 14:27:29 +0800
Subject: [PATCH] update 通用Service接口 增加自定义vo转换函数

---
 ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java |   93 +++++++++++++++++++++++++++-------------------
 1 files changed, 55 insertions(+), 38 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java
index 7200fc5..889d549 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java
@@ -1,6 +1,5 @@
 package com.ruoyi.common.core.page;
 
-import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import lombok.Data;
@@ -10,34 +9,67 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Data
 @Accessors(chain = true)
 public class PagePlus<T,K> implements IPage<T> {
 
-    protected List<T> records;
-    protected List<K> recordsVo;
-    protected long total;
-    protected long size;
-    protected long current;
-    protected List<OrderItem> orders;
-    protected boolean optimizeCountSql;
-    protected boolean isSearchCount;
-    protected boolean hitCount;
-    protected String countId;
-    protected Long maxLimit;
+    /**
+     * domain瀹炰綋鍒楄〃
+     */
+    private List<T> records = Collections.emptyList();
+
+    /**
+     * vo瀹炰綋鍒楄〃
+     */
+    private List<K> recordsVo = Collections.emptyList();
+
+    /**
+     * 鎬绘暟
+     */
+    private long total = 0L;
+
+    /**
+     * 椤甸暱搴�
+     */
+    private long size = 10L;
+
+    /**
+     * 褰撳墠椤�
+     */
+    private long current = 1L;
+
+    /**
+     * 鎺掑簭瀛楁淇℃伅
+     */
+    private List<OrderItem> orders = new ArrayList<>();
+
+    /**
+     * 鑷姩浼樺寲 COUNT SQL
+     */
+    private boolean optimizeCountSql = true;
+
+    /**
+     * 鏄惁杩涜 count 鏌ヨ
+     */
+    private boolean isSearchCount = true;
+
+    /**
+     * 鏄惁鍛戒腑count缂撳瓨
+     */
+    private boolean hitCount = false;
+
+    /**
+     * countId
+     */
+    private String countId;
+
+    /**
+     * 鏈�澶imit
+     */
+    private Long maxLimit;
 
     public PagePlus() {
-        this.records = Collections.emptyList();
-        this.recordsVo = Collections.emptyList();
-        this.total = 0L;
-        this.size = 10L;
-        this.current = 1L;
-        this.orders = new ArrayList();
-        this.optimizeCountSql = true;
-        this.isSearchCount = true;
-        this.hitCount = false;
     }
 
     public PagePlus(long current, long size) {
@@ -53,18 +85,9 @@
     }
 
     public PagePlus(long current, long size, long total, boolean isSearchCount) {
-        this.records = Collections.emptyList();
-        this.total = 0L;
-        this.size = 10L;
-        this.current = 1L;
-        this.orders = new ArrayList();
-        this.optimizeCountSql = true;
-        this.isSearchCount = true;
-        this.hitCount = false;
         if (current > 1L) {
             this.current = current;
         }
-
         this.size = size;
         this.total = total;
         this.isSearchCount = isSearchCount;
@@ -76,12 +99,6 @@
 
     public boolean hasNext() {
         return this.current < this.getPages();
-    }
-
-    public void recordsToVo(Class<K> kClass) {
-        this.recordsVo = this.records.stream()
-                .map(any -> BeanUtil.toBean(any, kClass))
-                .collect(Collectors.toList());
     }
 
     @Override
@@ -116,7 +133,7 @@
 
     @Override
     public boolean isSearchCount() {
-        return this.total < 0L ? false : this.isSearchCount;
+        return this.total >= 0L && this.isSearchCount;
     }
 
     public PagePlus<T, K> setSearchCount(boolean isSearchCount) {

--
Gitblit v1.9.3