Commit 2f5637ad authored by tangwei's avatar tangwei

增加分页插件

parent 84a17a41
......@@ -3,7 +3,9 @@ package com.yeejoin.amos.boot.module.hygf.biz.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
......@@ -41,6 +43,7 @@ public class MysqlServerConfig {
return DataSourceBuilder.create().build();
}
@Bean(name = "mysqlSqlSessionFactory")
@Primary
public SqlSessionFactory mysqlSqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource, GlobalConfig globalConfig) throws Exception {
......@@ -57,11 +60,14 @@ public class MysqlServerConfig {
properties.setProperty("rowBoundsWithCount", "true");
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments","true");
properties.setProperty("params","pageNum=pageNum;pageSize=pageSize" +
properties.setProperty("params","pageNum=current;pageSize=size" +
"" +
";");
interceptor.setProperties(properties);
bean.setPlugins(new Interceptor[] {interceptor});
bean.setPlugins(new Interceptor[] {interceptor,
paginationInterceptor() });
return bean.getObject();
}
......@@ -76,4 +82,14 @@ public class MysqlServerConfig {
public SqlSessionTemplate mysqlSqlSessionTemplate(@Qualifier("mysqlSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setDialectType("mysql");
return paginationInterceptor;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
......@@ -55,7 +56,7 @@ public class TDengineServerConfig {
"" +
";");
interceptor.setProperties(properties);
bean.setPlugins(new Interceptor[] {interceptor});
bean.setPlugins(new Interceptor[] {interceptor,paginationInterceptor()});
return bean.getObject();
}
......@@ -70,5 +71,11 @@ public class TDengineServerConfig {
public SqlSessionTemplate tdengineSqlSessionTemplate(@Qualifier("tdengineSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setDialectType("mysql");
return paginationInterceptor;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment