优化测试代码

This commit is contained in:
yulichang 2023-02-23 17:06:26 +08:00
parent bb5c5df261
commit c5a1ec397e
23 changed files with 447 additions and 146 deletions

View File

@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.session.Configuration;
/**
* @author yulichang
* @since 1.4.3
*/
public interface IAdapter {
boolean mpjHasLogic(TableInfo tableInfo);

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress ALL -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-adapter</artifactId>
<version>1.4.2.2</version>
</parent>
<artifactId>mybatis-plus-join-adapter-v33x</artifactId>
<version>1.4.2.2</version>
<name>mybatis-plus-join-adapter-v33x</name>
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
<url>https://github.com/yulichang/mybatis-plus-join</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<id>mybatis-plus-join</id>
<name>yulichang</name>
<email>yu_lichang@qq.com</email>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/yulichang/mybatis-plus-join.git</connection>
<developerConnection>scm:git:https://github.com/yulichang/mybatis-plus-join.git</developerConnection>
<url>https://github.com/yulichang/mybatis-plus-join</url>
</scm>
<properties>
<jdkVersion>1.8</jdkVersion>
<jdkVersion.test>1.8</jdkVersion.test>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<github.global.server>github</github.global.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-adapter-base</artifactId>
<version>1.4.2.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -8,6 +8,10 @@ import org.apache.ibatis.session.Configuration;
import java.util.Objects;
/**
* @author yulichang
* @since 1.4.3
*/
public class AdapterV33x implements IAdapter {
@Override

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-root</artifactId>
<version>1.4.2.2</version>
</parent>
<packaging>pom</packaging>
<version>1.4.2.2</version>
<artifactId>mybatis-plus-join-adapter</artifactId>
<name>mybatis-plus-join-adapter</name>
<modules>
<module>mybatis-plus-join-adapter-base</module>
<module>mybatis-plus-join-adapter-v33x</module>
</modules>
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
<url>https://github.com/yulichang/mybatis-plus-join</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<id>mybatis-plus-join</id>
<name>yulichang</name>
<email>yu_lichang@qq.com</email>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/yulichang/mybatis-plus-join.git</connection>
<developerConnection>scm:git:https://github.com/yulichang/mybatis-plus-join.git</developerConnection>
<url>https://github.com/yulichang/mybatis-plus-join</url>
</scm>
<properties>
<jdkVersion>1.8</jdkVersion>
<jdkVersion.test>1.8</jdkVersion.test>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<github.global.server>github</github.global.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -5,6 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.github.yulichang.adapter.base.IAdapter;
import org.apache.ibatis.session.Configuration;
/**
* @author yulichang
* @since 1.4.3
*/
public class Adapter implements IAdapter {
@Override

View File

@ -16,6 +16,7 @@
<name>mybatis-plus-join-test</name>
<modules>
<module>test-base</module>
<module>test-join</module>
<module>test-collection</module>
<module>test-mapping</module>
@ -97,7 +98,6 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<!-- <version>3.3.0</version>-->
<version>3.5.2</version>
</dependency>
<dependency>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-test</artifactId>
<version>1.4.2.2</version>
</parent>
<artifactId>test-base</artifactId>
<version>1.4.2.2</version>
<name>test-base</name>
<description>test-base</description>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,105 @@
//package com.github.yulichang.test.config;
//
//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
//import com.github.yulichang.test.util.ThreadLocalUtils;
//import org.apache.ibatis.cache.CacheKey;
//import org.apache.ibatis.executor.Executor;
//import org.apache.ibatis.executor.statement.StatementHandler;
//import org.apache.ibatis.mapping.BoundSql;
//import org.apache.ibatis.mapping.MappedStatement;
//import org.apache.ibatis.plugin.*;
//import org.apache.ibatis.session.ResultHandler;
//import org.apache.ibatis.session.RowBounds;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.stereotype.Component;
//
//import java.sql.Connection;
//import java.util.Objects;
//import java.util.StringTokenizer;
//
///**
// * mp 3.3.x
// */
//@Configuration
//public class MPConfig {
//
// @Bean
// public PaginationInterceptor mybatisPlusInterceptor() {
// return new PaginationInterceptor();
// }
//
// @Component
// @Intercepts({
// @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class}),
// @Signature(type = StatementHandler.class, method = "getBoundSql", args = {}),
// @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}),
// @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
// @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
// })
// public static class SqlInterceptor implements Interceptor {
//
// @Override
// public Object intercept(Invocation invocation) throws Throwable {
// Object target = invocation.getTarget();
// BoundSql boundSql = null;
// if (target instanceof StatementHandler) {
// boundSql = ((StatementHandler) target).getBoundSql();
// String sql = boundSql.getSql();
// String s = ThreadLocalUtils.get();
// if (sql != null && s != null) {
// String s1 = formatSql(sql);
// String s2 = formatSql(s);
// if (StringUtils.isNotBlank(s) && !Objects.equals(s1.toLowerCase(), s2.toLowerCase())) {
// System.err.println("执行sql: " + removeExtraWhitespaces(sql));
// System.err.println("预期sql: " + removeExtraWhitespaces(s));
// throw new RuntimeException("sql error");
// }
// }
// }
// System.out.println(boundSql);
// return invocation.proceed();
// }
//
// @Override
// public Object plugin(Object target) {
// if (target instanceof Executor || target instanceof StatementHandler) {
// return Plugin.wrap(target, this);
// }
// return target;
// }
//
// private String formatSql(String sql) {
// if (StringUtils.isBlank(sql)) {
// return sql;
// }
// sql = sql.replaceAll("\n", "");
// sql = sql.replaceAll("\r", "");
// sql = sql.replaceAll("\t", "");
// return dg(sql);
// }
//
// private String dg(String str) {
// if (str.contains(" ")) {
// str = str.replaceAll(" ", "");
// return dg(str);
// }
// return str;
// }
//
// private String removeExtraWhitespaces(String original) {
// StringTokenizer tokenizer = new StringTokenizer(original);
// StringBuilder builder = new StringBuilder();
// boolean hasMoreTokens = tokenizer.hasMoreTokens();
// while (hasMoreTokens) {
// builder.append(tokenizer.nextToken());
// hasMoreTokens = tokenizer.hasMoreTokens();
// if (hasMoreTokens) {
// builder.append(' ');
// }
// }
// return builder.toString();
// }
// }
//}

View File

@ -0,0 +1,92 @@
package com.github.yulichang.test.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
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.test.util.ThreadLocalUtils;
import org.apache.ibatis.builder.SqlSourceBuilder;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.sql.Connection;
import java.util.Objects;
/**
* mybatis-plus配置
*/
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor page = new PaginationInnerInterceptor(DbType.H2);
page.setOptimizeJoin(false);
interceptor.addInnerInterceptor(page);
interceptor.addInnerInterceptor(new SqlInterceptor());
return interceptor;
}
/**
* 校验sql
*/
public static class SqlInterceptor implements InnerInterceptor {
@Override
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
String sql = boundSql.getSql();
String s = ThreadLocalUtils.get();
if (StringUtils.isNotBlank(s) && !Objects.equals(formatSql(sql), formatSql(s))) {
System.err.println("执行sql: " + SqlSourceBuilder.removeExtraWhitespaces(sql));
System.err.println("预期sql: " + SqlSourceBuilder.removeExtraWhitespaces(s));
throw new RuntimeException("sql error");
}
}
@Override
public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
BoundSql boundSql = sh.getBoundSql();
if (boundSql != null && StringUtils.isNotBlank(boundSql.getSql())) {
String sql = boundSql.getSql();
if (sql.toUpperCase().startsWith("SELECT")) {
return;
}
String s = ThreadLocalUtils.get();
if (StringUtils.isNotBlank(s) && !Objects.equals(formatSql(sql), formatSql(s))) {
System.err.println("执行sql: " + SqlSourceBuilder.removeExtraWhitespaces(sql));
System.err.println("预期sql: " + SqlSourceBuilder.removeExtraWhitespaces(s));
throw new RuntimeException("sql error");
}
}
}
private String formatSql(String sql) {
if (StringUtils.isBlank(sql)) {
return sql;
}
sql = sql.replaceAll("\n", "");
sql = sql.replaceAll("\r", "");
sql = sql.replaceAll("\t", "");
return dg(sql);
}
private String dg(String str) {
if (str.contains(" ")) {
str = str.replaceAll(" ", "");
return dg(str);
}
return str;
}
}
}

View File

@ -1,4 +1,4 @@
package com.github.yulichang.test.join.util;
package com.github.yulichang.test.util;
public class ThreadLocalUtils {

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress ALL -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@ -17,4 +18,12 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>test-base</artifactId>
<version>1.4.2.2</version>
</dependency>
</dependencies>
</project>

View File

@ -2,8 +2,9 @@ package com.github.yulichang.test.collection;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan(basePackages = "com.github.yulichang.test")
@SpringBootApplication
public class Application {

View File

@ -1,25 +0,0 @@
package com.github.yulichang.test.collection.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* mybatis-plus配置
*/
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public MybatisPlusInterceptor paginationInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor page = new PaginationInnerInterceptor();
interceptor.addInnerInterceptor(page);
return interceptor;
}
}

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress ALL -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@ -16,4 +17,12 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>test-base</artifactId>
<version>1.4.2.2</version>
</dependency>
</dependencies>
</project>

View File

@ -2,8 +2,9 @@ package com.github.yulichang.test.join;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan(basePackages = "com.github.yulichang.test")
@SpringBootApplication
public class Application {

View File

@ -1,17 +0,0 @@
//package com.github.yulichang.test.join.config;
//
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * mp 3.3.x
// */
//@Configuration
//public class MPConfig {
//
// @Bean
// public PaginationInterceptor mybatisPlusInterceptor() {
// return new PaginationInterceptor();
// }
//}

View File

@ -1,75 +0,0 @@
//package com.github.yulichang.test.join.config;
//
//import com.baomidou.mybatisplus.annotation.DbType;
//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
//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.test.join.util.ThreadLocalUtils;
//import org.apache.ibatis.builder.SqlSourceBuilder;
//import org.apache.ibatis.executor.Executor;
//import org.apache.ibatis.mapping.BoundSql;
//import org.apache.ibatis.mapping.MappedStatement;
//import org.apache.ibatis.session.ResultHandler;
//import org.apache.ibatis.session.RowBounds;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.sql.SQLException;
//import java.util.Objects;
//
///**
// * mybatis-plus配置
// */
//@Configuration
//public class MybatisPlusConfig {
//
// /**
// * 分页插件
// */
// @Bean
// public MybatisPlusInterceptor mybatisPlusInterceptor() {
// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// PaginationInnerInterceptor page = new PaginationInnerInterceptor(DbType.H2);
// page.setOptimizeJoin(false);
// interceptor.addInnerInterceptor(page);
// interceptor.addInnerInterceptor(new SqlInterceptor());
// return interceptor;
// }
//
// /**
// * 校验sql
// */
// public static class SqlInterceptor implements InnerInterceptor {
//
// @Override
// public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
// String sql = boundSql.getSql();
// String s = ThreadLocalUtils.get();
// if (StringUtils.isNotBlank(s) && !Objects.equals(formatSql(sql), formatSql(s))) {
// System.err.println("执行sql: " + SqlSourceBuilder.removeExtraWhitespaces(sql));
// System.err.println("预期sql: " + SqlSourceBuilder.removeExtraWhitespaces(s));
// throw new RuntimeException("sql error");
// }
// InnerInterceptor.super.beforeQuery(executor, ms, parameter, rowBounds, resultHandler, boundSql);
// }
//
// private String formatSql(String sql) {
// if (StringUtils.isBlank(sql)) {
// return sql;
// }
// sql = sql.replaceAll("\n", "");
// sql = sql.replaceAll("\r", "");
// sql = sql.replaceAll("\t", "");
// return dg(sql);
// }
//
// private String dg(String str) {
// if (str.contains(" ")) {
// str = str.replaceAll(" ", "");
// return dg(str);
// }
// return str;
// }
// }
//}

View File

@ -12,7 +12,7 @@ import com.github.yulichang.test.join.entity.UserDO;
import com.github.yulichang.test.join.entity.UserDto;
import com.github.yulichang.test.join.mapper.UserDTOMapper;
import com.github.yulichang.test.join.mapper.UserMapper;
import com.github.yulichang.test.join.util.ThreadLocalUtils;
import com.github.yulichang.test.util.ThreadLocalUtils;
import com.github.yulichang.toolkit.MPJWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.junit.jupiter.api.Test;

View File

@ -0,0 +1,69 @@
package com.github.yulichang.test.join;
import com.github.yulichang.test.join.entity.UserDO;
import com.github.yulichang.test.join.entity.UserDto;
import com.github.yulichang.test.join.mapper.UserDTOMapper;
import com.github.yulichang.test.join.mapper.UserMapper;
import com.github.yulichang.test.util.ThreadLocalUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
/**
* springboot3 & jdk17+
*/
@SuppressWarnings("unused")
@SpringBootTest
class UpdateWrapperTest {
@Autowired
private UserMapper userMapper;
@Autowired
private UserDTOMapper userDTOMapper;
/**
* 逻辑删除
*/
@Test
public void testUpdate() {
ThreadLocalUtils.set("UPDATE `user` t SET del=true WHERE t.del=false AND (t.id = ?)");
MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
.eq(UserDO::getId, 1);
userMapper.delete(wrapper);
assert userMapper.selectById(1) == null;
}
/**
* 非逻辑删除
*/
@Test
public void testUpdate1() {
MPJLambdaWrapper<UserDto> wrapper = new MPJLambdaWrapper<>();
wrapper.eq(UserDto::getId, 1);
userDTOMapper.delete(wrapper);
assert userDTOMapper.selectById(1) == null;
}
/**
* 修改
*/
@Test
public void testUpdate2() {
// MPJLambdaWrapper<UserDto> wrapper = new MPJLambdaWrapper<UserDto>()
// .leftJoin(UserDO.class, UserDO::getId, UserDto::getUserId)
// .eq(UserDto::getId, 1);
MPJLambdaWrapper<UserDto> wrapper = new MPJLambdaWrapper<>();
wrapper.eq(UserDto::getId, 1);
userDTOMapper.update(new UserDto() {{
setUserId(2222);
}}, wrapper);
}
}

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress VulnerableLibrariesLocal -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@ -17,4 +18,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>test-base</artifactId>
<version>1.4.2.2</version>
</dependency>
</dependencies>
</project>

View File

@ -1,7 +1,9 @@
package com.github.yulichang.test.mapping;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan(basePackages = "com.github.yulichang.test")
@SpringBootApplication
public class Application {

View File

@ -1,24 +0,0 @@
package com.github.yulichang.test.mapping.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* mybatis-plus配置
*/
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public MybatisPlusInterceptor paginationInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor page = new PaginationInnerInterceptor();
interceptor.addInnerInterceptor(page);
return interceptor;
}
}

View File

@ -49,6 +49,12 @@
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>test-base</artifactId>
<version>1.4.2.2</version>
</dependency>
</dependencies>
</project>