Skip to content

Commit

Permalink
解决pr#138支持kebabcase但是不支持扩展的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
abel533 committed Sep 15, 2022
1 parent d6c04a0 commit 5682d6d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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.Import;
import org.springframework.context.annotation.Lazy;

import java.util.List;
Expand All @@ -45,19 +44,19 @@
*/
@Configuration
@ConditionalOnBean(SqlSessionFactory.class)
@EnableConfigurationProperties(PageHelperPropertiesProcessKebabCase.class)
@EnableConfigurationProperties({PageHelperProperties.class, PageHelperStandardProperties.class})
@AutoConfigureAfter(MybatisAutoConfiguration.class)
@Import(PageHelperProperties.class)
//@Import(PageHelperProperties.class)
@Lazy(false)
public class PageHelperAutoConfiguration implements InitializingBean {

private final List<SqlSessionFactory> sqlSessionFactoryList;

private final PageHelperProperties properties;

public PageHelperAutoConfiguration(List<SqlSessionFactory> sqlSessionFactoryList, PageHelperProperties properties, PageHelperPropertiesProcessKebabCase propertiesKC) {
public PageHelperAutoConfiguration(List<SqlSessionFactory> sqlSessionFactoryList, PageHelperStandardProperties standardProperties) {
this.sqlSessionFactoryList = sqlSessionFactoryList;
this.properties = properties;
this.properties = standardProperties.getProperties();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

package com.github.pagehelper.autoconfigure;

import org.springframework.stereotype.Component;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Properties;

Expand All @@ -33,8 +33,9 @@
*
* @author liuzh
*/
@Component
@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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
*
* @author showen
*/
@ConfigurationProperties(prefix = PageHelperPropertiesProcessKebabCase.PAGEHELPER_PREFIX)
public class PageHelperPropertiesProcessKebabCase {

public static final String PAGEHELPER_PREFIX = "pagehelper";

@ConfigurationProperties(prefix = PageHelperProperties.PAGEHELPER_PREFIX)
public class PageHelperStandardProperties {
private final PageHelperProperties properties;
private Boolean offsetAsPageNum;
private Boolean rowBoundsWithCount;
Expand All @@ -41,10 +38,14 @@ public class PageHelperPropertiesProcessKebabCase {
private String autoDialectClass;

@Autowired
public PageHelperPropertiesProcessKebabCase(PageHelperProperties properties) {
public PageHelperStandardProperties(PageHelperProperties properties) {
this.properties = properties;
}

public PageHelperProperties getProperties() {
return properties;
}

public Boolean getOffsetAsPageNum() {
return offsetAsPageNum;
}
Expand Down

0 comments on commit 5682d6d

Please sign in to comment.