Procházet zdrojové kódy

更新分页相关

tags/v2.5.0
xiaoying před 1 rokem
rodič
revize
39299bd7e4
2 změnil soubory, kde provedl 16 přidání a 25 odebrání
  1. +6
    -2
      tuoheng_oidc_admin/pom.xml
  2. +10
    -23
      tuoheng_oidc_admin/src/main/java/com/tuoheng/config/MybatisPlusConfig.java

+ 6
- 2
tuoheng_oidc_admin/pom.xml Zobrazit soubor

@@ -35,7 +35,7 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
<version>3.3.0</version>
</dependency>

<dependency>
@@ -128,7 +128,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>

<!-- 构建环境变量 -->

+ 10
- 23
tuoheng_oidc_admin/src/main/java/com/tuoheng/config/MybatisPlusConfig.java Zobrazit soubor

@@ -1,36 +1,23 @@
package com.tuoheng.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement(proxyTargetClass = true)
public class MybatisPlusConfig {

/**
* 插件注册
* 分页插件
*
* @param paginationInnerInterceptor 分页插件
* @return MybatisPlus拦截器
* @return
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(PaginationInnerInterceptor paginationInnerInterceptor) {
MybatisPlusInterceptor mp = new MybatisPlusInterceptor();
mp.addInnerInterceptor(paginationInnerInterceptor);
return mp;
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}

//分页插件
@Bean
public PaginationInnerInterceptor paginationInnerInterceptor() {
PaginationInnerInterceptor pii = new PaginationInnerInterceptor();
pii.setMaxLimit(20L);
pii.setDbType(DbType.MYSQL);
//当超过最大页数时不会报错
pii.setOverflow(true);
return pii;
}

}

Načítá se…
Zrušit
Uložit