|
@@ -4,6 +4,7 @@ import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.chelvc.framework.common.model.Pagination;
|
|
import com.chelvc.framework.common.model.Pagination;
|
|
import com.chelvc.framework.common.model.Paging;
|
|
import com.chelvc.framework.common.model.Paging;
|
|
@@ -80,6 +81,17 @@ public final class PagingUtils {
|
|
return convert(page, (List<T>) ObjectUtils.ifNull(page, Page::getRecords));
|
|
return convert(page, (List<T>) ObjectUtils.ifNull(page, Page::getRecords));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 将MyBatis Plus分页参数转换成分页返回参数
|
|
|
|
+ *
|
|
|
|
+ * @param page 原始分页信息
|
|
|
|
+ * @param <T> 目标对象类型泛型
|
|
|
|
+ * @return 分页返回参数
|
|
|
|
+ */
|
|
|
|
+ public static <T> Pagination<T> convert(IPage<?> page, Class<T> type) {
|
|
|
|
+ return convert(page, ObjectUtils.copying((List<?>) ObjectUtils.ifNull(page, page.getRecords()), type));
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 将MyBatis Plus分页参数转换成分页返回参数
|
|
* 将MyBatis Plus分页参数转换成分页返回参数
|
|
*
|
|
*
|
|
@@ -119,6 +131,19 @@ public final class PagingUtils {
|
|
.records(records).build();
|
|
.records(records).build();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 将MyBatis Plus分页参数转换成分页返回参数
|
|
|
|
+ *
|
|
|
|
+ * @param page MyBatis Plus分页参数
|
|
|
|
+ * @param records 分页数据列表
|
|
|
|
+ * @param <T> 目标对象类型泛型
|
|
|
|
+ * @return 分页返回参数
|
|
|
|
+ */
|
|
|
|
+ public static <T> Pagination<T> convert(IPage<?> page, List<T> records) {
|
|
|
|
+ return page == null ? null : Pagination.<T>builder().total(page.getTotal()).pages(page.getPages())
|
|
|
|
+ .records(records).build();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 分页记录转换
|
|
* 分页记录转换
|
|
*
|
|
*
|