mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
优化代码
This commit is contained in:
parent
69713b1c39
commit
0df22e3adf
@ -147,22 +147,23 @@ public abstract class AptAbstractWrapper<T, Children extends AptAbstractWrapper<
|
||||
*/
|
||||
public Children pageByMain() {
|
||||
this.pageByMain = true;
|
||||
this.pageInfo = new PageInfo();
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主表分页
|
||||
*/
|
||||
public Children pageByMain(MFunction<PageInfo.PageInfoBuilder> function) {
|
||||
public Children pageByMain(MFunction<PageInfo> function) {
|
||||
this.pageByMain = true;
|
||||
PageInfo.PageInfoBuilder apply = function.apply(PageInfo.builder());
|
||||
this.pageInfo = apply.build();
|
||||
function.apply(getPageInfo());
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
public PageInfo getPageInfo() {
|
||||
return pageInfo == null ? new PageInfo() : pageInfo;
|
||||
if (pageInfo == null) {
|
||||
pageInfo = new PageInfo();
|
||||
}
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,22 +182,23 @@ public abstract class KtAbstractLambdaWrapper<T, Children extends KtAbstractLamb
|
||||
*/
|
||||
public Children pageByMain() {
|
||||
this.pageByMain = true;
|
||||
this.pageInfo = new PageInfo();
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主表分页
|
||||
*/
|
||||
public Children pageByMain(MFunction<PageInfo.PageInfoBuilder> function) {
|
||||
public Children pageByMain(MFunction<PageInfo> function) {
|
||||
this.pageByMain = true;
|
||||
PageInfo.PageInfoBuilder apply = function.apply(PageInfo.builder());
|
||||
this.pageInfo = apply.build();
|
||||
function.apply(getPageInfo());
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
public PageInfo getPageInfo() {
|
||||
return pageInfo == null ? new PageInfo() : pageInfo;
|
||||
if (pageInfo == null) {
|
||||
pageInfo = new PageInfo();
|
||||
}
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import com.github.yulichang.adapter.AdapterHelper;
|
||||
import com.github.yulichang.config.ConfigProperties;
|
||||
import com.github.yulichang.interceptor.MPJInterceptor;
|
||||
import com.github.yulichang.interceptor.pagination.PageInnerInterceptor;
|
||||
import org.apache.ibatis.logging.Log;
|
||||
|
@ -182,22 +182,23 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
*/
|
||||
public Children pageByMain() {
|
||||
this.pageByMain = true;
|
||||
this.pageInfo = new PageInfo();
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主表分页
|
||||
*/
|
||||
public Children pageByMain(MFunction<PageInfo.PageInfoBuilder> function) {
|
||||
public Children pageByMain(MFunction<PageInfo> function) {
|
||||
this.pageByMain = true;
|
||||
PageInfo.PageInfoBuilder apply = function.apply(PageInfo.builder());
|
||||
this.pageInfo = apply.build();
|
||||
function.apply(getPageInfo());
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
public PageInfo getPageInfo() {
|
||||
return pageInfo == null ? new PageInfo() : pageInfo;
|
||||
if (pageInfo == null) {
|
||||
pageInfo = new PageInfo();
|
||||
}
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -12,6 +13,7 @@ import java.io.Serializable;
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageInfo implements Serializable {
|
||||
@ -19,32 +21,4 @@ public class PageInfo implements Serializable {
|
||||
private IPage<?> innerPage;
|
||||
|
||||
private String countSelectSql;
|
||||
|
||||
public static PageInfoBuilder builder() {
|
||||
return new PageInfoBuilder();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static class PageInfoBuilder {
|
||||
private IPage<?> innerPage;
|
||||
private String countSelectSql;
|
||||
|
||||
PageInfoBuilder() {
|
||||
}
|
||||
|
||||
public PageInfoBuilder innerPage(IPage<?> innerPage) {
|
||||
this.innerPage = innerPage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PageInfoBuilder countSelectSql(String countSelectSql) {
|
||||
this.countSelectSql = countSelectSql;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PageInfo build() {
|
||||
return new PageInfo(this.innerPage, this.countSelectSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class PageByMainTest {
|
||||
.orderByDesc(UserDO::getId)
|
||||
.groupBy(UserDO::getId)
|
||||
.logicDelToOn()
|
||||
.pageByMain(f -> f.countSelectSql("1"));
|
||||
.pageByMain(f -> f.setCountSelectSql("1"));
|
||||
|
||||
Page<UserDTO> page = wrapper.page(new Page<>(1, 8), UserDTO.class);
|
||||
page.getRecords().forEach(System.out::println);
|
||||
|
Loading…
x
Reference in New Issue
Block a user