Merge pull request #30 from hiparker/development
fix: 升级springboot 版本为 2.7.10, 修复 CVE-2023-20860pull/33/head
commit
09fcc6d298
@ -0,0 +1,51 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>opsli-plugins</artifactId>
|
||||
<groupId>org.opsliframework.boot</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<version>1.4.6</version>
|
||||
<artifactId>opsli-plugins-pagehelper</artifactId>
|
||||
|
||||
<properties>
|
||||
<pagehelper.version>5.3.2</pagehelper.version>
|
||||
<mybatis-spring-boot.version>2.2.2</mybatis-spring-boot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>${pagehelper.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-autoconfigure</artifactId>
|
||||
<version>${mybatis-spring-boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Compile dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,69 @@
|
||||
package org.opsli.plugins.pagehelper;
|
||||
|
||||
import com.github.pagehelper.PageInterceptor;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定注入分页插件
|
||||
*
|
||||
* @author liuzh
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnBean(SqlSessionFactory.class)
|
||||
@EnableConfigurationProperties(PageHelperProperties.class)
|
||||
@AutoConfigureAfter(MybatisAutoConfiguration.class)
|
||||
@Lazy(false)
|
||||
public class PageHelperAutoConfiguration implements InitializingBean {
|
||||
|
||||
private final List<SqlSessionFactory> sqlSessionFactoryList;
|
||||
|
||||
private final PageHelperProperties properties;
|
||||
|
||||
public PageHelperAutoConfiguration(List<SqlSessionFactory> sqlSessionFactoryList, PageHelperProperties properties) {
|
||||
this.sqlSessionFactoryList = sqlSessionFactoryList;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// 关闭 Banner
|
||||
String bannerFlag = Boolean.TRUE.equals(this.properties.getBanner())?"true":"false";
|
||||
System.setProperty("pagehelper.banner", bannerFlag);
|
||||
|
||||
PageInterceptor interceptor = new PageInterceptor();
|
||||
interceptor.setProperties(this.properties);
|
||||
for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
|
||||
org.apache.ibatis.session.Configuration configuration = sqlSessionFactory.getConfiguration();
|
||||
if (!containsInterceptor(configuration, interceptor)) {
|
||||
configuration.addInterceptor(interceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否已经存在相同的拦截器
|
||||
*
|
||||
* @param configuration
|
||||
* @param interceptor
|
||||
* @return
|
||||
*/
|
||||
private boolean containsInterceptor(org.apache.ibatis.session.Configuration configuration, Interceptor interceptor) {
|
||||
try {
|
||||
// getInterceptors since 3.2.2
|
||||
return configuration.getInterceptors().contains(interceptor);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package org.opsli.plugins.pagehelper;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Configuration properties for PageHelper.
|
||||
*
|
||||
* @author liuzh
|
||||
*/
|
||||
@ConfigurationProperties(prefix = PageHelperProperties.PAGEHELPER_PREFIX)
|
||||
public class PageHelperProperties extends Properties {
|
||||
|
||||
public static final String PAGEHELPER_PREFIX = "pagehelper";
|
||||
|
||||
public Boolean getOffsetAsPageNum() {
|
||||
return Boolean.valueOf(getProperty("offsetAsPageNum"));
|
||||
}
|
||||
|
||||
public void setOffsetAsPageNum(Boolean offsetAsPageNum) {
|
||||
setProperty("offsetAsPageNum", offsetAsPageNum.toString());
|
||||
}
|
||||
|
||||
public Boolean getRowBoundsWithCount() {
|
||||
return Boolean.valueOf(getProperty("rowBoundsWithCount"));
|
||||
}
|
||||
|
||||
public void setRowBoundsWithCount(Boolean rowBoundsWithCount) {
|
||||
setProperty("rowBoundsWithCount", rowBoundsWithCount.toString());
|
||||
}
|
||||
|
||||
public Boolean getPageSizeZero() {
|
||||
return Boolean.valueOf(getProperty("pageSizeZero"));
|
||||
}
|
||||
|
||||
public void setPageSizeZero(Boolean pageSizeZero) {
|
||||
setProperty("pageSizeZero", pageSizeZero.toString());
|
||||
}
|
||||
|
||||
public Boolean getReasonable() {
|
||||
return Boolean.valueOf(getProperty("reasonable"));
|
||||
}
|
||||
|
||||
public void setReasonable(Boolean reasonable) {
|
||||
setProperty("reasonable", reasonable.toString());
|
||||
}
|
||||
|
||||
public Boolean getSupportMethodsArguments() {
|
||||
return Boolean.valueOf(getProperty("supportMethodsArguments"));
|
||||
}
|
||||
|
||||
public void setSupportMethodsArguments(Boolean supportMethodsArguments) {
|
||||
setProperty("supportMethodsArguments", supportMethodsArguments.toString());
|
||||
}
|
||||
|
||||
public String getDialect() {
|
||||
return getProperty("dialect");
|
||||
}
|
||||
|
||||
public void setDialect(String dialect) {
|
||||
setProperty("dialect", dialect);
|
||||
}
|
||||
|
||||
public String getHelperDialect() {
|
||||
return getProperty("helperDialect");
|
||||
}
|
||||
|
||||
public void setHelperDialect(String helperDialect) {
|
||||
setProperty("helperDialect", helperDialect);
|
||||
}
|
||||
|
||||
public Boolean getAutoRuntimeDialect() {
|
||||
return Boolean.valueOf(getProperty("autoRuntimeDialect"));
|
||||
}
|
||||
|
||||
public void setAutoRuntimeDialect(Boolean autoRuntimeDialect) {
|
||||
setProperty("autoRuntimeDialect", autoRuntimeDialect.toString());
|
||||
}
|
||||
|
||||
public Boolean getAutoDialect() {
|
||||
return Boolean.valueOf(getProperty("autoDialect"));
|
||||
}
|
||||
|
||||
public void setAutoDialect(Boolean autoDialect) {
|
||||
setProperty("autoDialect", autoDialect.toString());
|
||||
}
|
||||
|
||||
public Boolean getCloseConn() {
|
||||
return Boolean.valueOf(getProperty("closeConn"));
|
||||
}
|
||||
|
||||
public void setCloseConn(Boolean closeConn) {
|
||||
setProperty("closeConn", closeConn.toString());
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return getProperty("params");
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
setProperty("params", params);
|
||||
}
|
||||
|
||||
public Boolean getDefaultCount() {
|
||||
return Boolean.valueOf(getProperty("defaultCount"));
|
||||
}
|
||||
|
||||
public void setDefaultCount(Boolean defaultCount) {
|
||||
setProperty("defaultCount", defaultCount.toString());
|
||||
}
|
||||
|
||||
public String getDialectAlias() {
|
||||
return getProperty("dialectAlias");
|
||||
}
|
||||
|
||||
public void setDialectAlias(String dialectAlias) {
|
||||
setProperty("dialectAlias", dialectAlias);
|
||||
}
|
||||
|
||||
public String getAutoDialectClass() {
|
||||
return getProperty("autoDialectClass");
|
||||
}
|
||||
|
||||
public void setAutoDialectClass(String autoDialectClass) {
|
||||
setProperty("autoDialectClass", autoDialectClass);
|
||||
}
|
||||
|
||||
public Boolean getBanner() {
|
||||
return Boolean.valueOf(getProperty("banner"));
|
||||
}
|
||||
public void setBanner(Boolean banner) {
|
||||
setProperty("banner", banner.toString());
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
{
|
||||
"groups": [
|
||||
{
|
||||
"name": "pagehelper",
|
||||
"type": "org.opsli.plugins.pagehelper.PageHelperProperties",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "pagehelper.banner",
|
||||
"type": "java.lang.Boolean",
|
||||
"defaultValue": false,
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.auto-dialect",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.auto-dialect-class",
|
||||
"type": "java.lang.String",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.auto-runtime-dialect",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.close-conn",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.default-count",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.dialect",
|
||||
"type": "java.lang.String",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.dialect-alias",
|
||||
"type": "java.lang.String",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.helper-dialect",
|
||||
"type": "java.lang.String",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.offset-as-page-num",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.page-size-zero",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.params",
|
||||
"type": "java.lang.String",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.reasonable",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.row-bounds-with-count",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
},
|
||||
{
|
||||
"name": "pagehelper.support-methods-arguments",
|
||||
"type": "java.lang.Boolean",
|
||||
"sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
|
||||
}
|
||||
],
|
||||
"hints": []
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.opsli.plugins.pagehelper.PageHelperAutoConfiguration
|
Loading…
Reference in new issue