From 064f5ccaa9c589a9deeea3d0a859ff381b88b2ff Mon Sep 17 00:00:00 2001 From: yulichang <570810310@qq.com> Date: Sun, 25 Aug 2024 21:17:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96first?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/yulichang/wrapper/interfaces/Chain.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java index ce50591..f964357 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Chain.java @@ -22,8 +22,6 @@ import java.util.Optional; @SuppressWarnings("unused") public interface Chain extends MPJBaseJoin { - Page FIRST_PAGE = new Page<>(1, 1).setSearchCount(false); - Class getEntityClass(); boolean isResultMapCollection(); @@ -68,9 +66,9 @@ public interface Chain extends MPJBaseJoin { * new MPJLambdaWrapper(User.class)
* JoinWrappers.lambda(User.class)
*/ - @SuppressWarnings("unchecked") default T first() { - List list = this.isResultMapCollection() ? list() : page((Page) FIRST_PAGE).getRecords(); + List list = this.isResultMapCollection() ? list() : + page(new Page(1, 1).setSearchCount(false)).getRecords(); return Optional.of(list).filter(CollectionUtils::isNotEmpty).map(m -> m.get(0)).orElse(null); } @@ -81,9 +79,9 @@ public interface Chain extends MPJBaseJoin { * new MPJLambdaWrapper(User.class)
* JoinWrappers.lambda(User.class)
*/ - @SuppressWarnings("unchecked") default R first(Class resultType) { - List list = this.isResultMapCollection() ? list(resultType) : page((Page) FIRST_PAGE, resultType).getRecords(); + List list = this.isResultMapCollection() ? list(resultType) : + page(new Page(1, 1).setSearchCount(false), resultType).getRecords(); return Optional.of(list).filter(CollectionUtils::isNotEmpty).map(m -> m.get(0)).orElse(null); }