https://www.cnblogs.com/Oliver-rebirth/p/springboot_pagehelper.html
https://www.cnblogs.com/charlypage/p/11220755.html
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments: true
pagehelper.params: pageNum=page.index;pageSize=page.rows;count=countSql;reasonable=reasonable;pageSizeZero=pageSizeZero
mavem
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
MybatisPluginConfiguration
package com.sdyy.springboot.config;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
/**
* @author g1558
* @date 2019-10-08-13:25
*/
@Configuration
public class MybatisPluginConfiguration {
@Autowired
private List<SqlSessionFactory> sqlSessionFactoryList;
@Autowired
private PageHelperProperties properties;
// @Autowired
// private ISqlBuilderSelector sqlBuilderSelector;
public MybatisPluginConfiguration() {
}
@PostConstruct
public void addPageInterceptor() {
PageInterceptor interceptor = new PageInterceptor();
Properties properties = new Properties();
properties.putAll(this.properties.getProperties());
interceptor.setProperties(properties);
// DataPermissionInterceptor permissionInterceptor = new DataPermissionInterceptor();
// permissionInterceptor.setSqlBuilderSelector(sqlBuilderSelector);
Iterator var3 = this.sqlSessionFactoryList.iterator();
while(var3.hasNext()) {
SqlSessionFactory sqlSessionFactory = (SqlSessionFactory)var3.next();
sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
// sqlSessionFactory.getConfiguration().addInterceptor(permissionInterceptor);
}
}
}
PageHelperProperties
package com.sdyy.springboot.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
* @author g1558
* @date 2019-10-08-13:26
*/
@Component
@ConfigurationProperties(prefix = "pagehelper")
public class PageHelperProperties {
public static final String PAGEHELPER_PREFIX = "pagehelper";
private Properties properties = new Properties();
public PageHelperProperties() {
}
public Properties getProperties() {
return this.properties;
}
public String getOffsetAsPageNum() {
return this.properties.getProperty("offsetAsPageNum");
}
public void setOffsetAsPageNum(String offsetAsPageNum) {
this.properties.setProperty("offsetAsPageNum", offsetAsPageNum);
}
public String getRowBoundsWithCount() {
return this.properties.getProperty("rowBoundsWithCount");
}
public void setRowBoundsWithCount(String rowBoundsWithCount) {
this.properties.setProperty("rowBoundsWithCount", rowBoundsWithCount);
}
public String getPageSizeZero() {
return this.properties.getProperty("pageSizeZero");
}
public void setPageSizeZero(String pageSizeZero) {
this.properties.setProperty("pageSizeZero", pageSizeZero);
}
public String getReasonable() {
return this.properties.getProperty("reasonable");
}
public void setReasonable(String reasonable) {
this.properties.setProperty("reasonable", reasonable);
}
public String getSupportMethodsArguments() {
return this.properties.getProperty("supportMethodsArguments");
}
public void setSupportMethodsArguments(String supportMethodsArguments) {
this.properties.setProperty("supportMethodsArguments", supportMethodsArguments);
}
public String getDialect() {
return this.properties.getProperty("dialect");
}
public void setDialect(String dialect) {
this.properties.setProperty("dialect", dialect);
}
public String getHelperDialect() {
return this.properties.getProperty("helperDialect");
}
public void setHelperDialect(String helperDialect) {
this.properties.setProperty("helperDialect", helperDialect);
}
public String getAutoRuntimeDialect() {
return this.properties.getProperty("autoRuntimeDialect");
}
public void setAutoRuntimeDialect(String autoRuntimeDialect) {
this.properties.setProperty("autoRuntimeDialect", autoRuntimeDialect);
}
public String getAutoDialect() {
return this.properties.getProperty("autoDialect");
}
public void setAutoDialect(String autoDialect) {
this.properties.setProperty("autoDialect", autoDialect);
}
public String getCloseConn() {
return this.properties.getProperty("closeConn");
}
public void setCloseConn(String closeConn) {
this.properties.setProperty("closeConn", closeConn);
}
public String getParams() {
return this.properties.getProperty("params");
}
public void setParams(String params) {
this.properties.setProperty("params", params);
}
}