初次提交
This commit is contained in:
parent
2c9326f1a5
commit
83184c0215
32
.gitignore
vendored
32
.gitignore
vendored
@ -1,23 +1,9 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
target
|
||||
*.iml
|
||||
out/
|
||||
.idea
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
bin/
|
||||
.myeclipse
|
||||
36
README.en.md
36
README.en.md
@ -1,36 +0,0 @@
|
||||
# ssssssss-spring-boot-starter
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
37
pom.xml
Normal file
37
pom.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.5.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<groupId>com.ssssssss</groupId>
|
||||
<artifactId>ssssssss-spring-boot-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ssssssss</groupId>
|
||||
<artifactId>ssssssss-core</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,59 @@
|
||||
package com.ssssssss.spring.boot.starter;
|
||||
|
||||
/**
|
||||
* 分页配置
|
||||
*/
|
||||
public class PageConfig {
|
||||
|
||||
/**
|
||||
* 默认page参数名
|
||||
*/
|
||||
private String page = "page";
|
||||
|
||||
/**
|
||||
* 默认size参数名
|
||||
*/
|
||||
private String size = "size";
|
||||
|
||||
/**
|
||||
* 默认首页
|
||||
*/
|
||||
private long defaultPage = 1;
|
||||
|
||||
/**
|
||||
* 默认页大小
|
||||
*/
|
||||
private long defaultSize = 10;
|
||||
|
||||
public String getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(String page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public long getDefaultPage() {
|
||||
return defaultPage;
|
||||
}
|
||||
|
||||
public void setDefaultPage(long defaultPage) {
|
||||
this.defaultPage = defaultPage;
|
||||
}
|
||||
|
||||
public long getDefaultSize() {
|
||||
return defaultSize;
|
||||
}
|
||||
|
||||
public void setDefaultSize(long defaultSize) {
|
||||
this.defaultSize = defaultSize;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.ssssssss.spring.boot.starter;
|
||||
|
||||
import com.ssssssss.executor.RequestExecutor;
|
||||
import com.ssssssss.executor.SqlExecutor;
|
||||
import com.ssssssss.executor.StatementExecutor;
|
||||
import com.ssssssss.expression.ExpressionEngine;
|
||||
import com.ssssssss.provider.PageProvider;
|
||||
import com.ssssssss.provider.impl.DefaultPageProvider;
|
||||
import com.ssssssss.session.Configuration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@org.springframework.context.annotation.Configuration
|
||||
@ConditionalOnClass({DataSource.class, RequestMappingHandlerMapping.class})
|
||||
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(S8Properties.class)
|
||||
public class S8AutoConfiguration {
|
||||
|
||||
private S8Properties properties;
|
||||
|
||||
public S8AutoConfiguration(S8Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@ConditionalOnMissingBean(PageProvider.class)
|
||||
@Bean
|
||||
public PageProvider pageProvider() {
|
||||
PageConfig pageConfig = properties.getPageConfig();
|
||||
return new DefaultPageProvider(pageConfig.getPage(), pageConfig.getSize(), pageConfig.getDefaultPage(), pageConfig.getDefaultSize());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RequestExecutor requestExecutor() {
|
||||
return new RequestExecutor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ExpressionEngine expressionEngine() {
|
||||
return new ExpressionEngine();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StatementExecutor statementExecutor(DataSource dataSource, PageProvider pageProvider) {
|
||||
SqlExecutor sqlExecutor = new SqlExecutor(dataSource);
|
||||
sqlExecutor.setMapUnderscoreToCamelCase(properties.isMapUnderscoreToCamelCase());
|
||||
return new StatementExecutor(sqlExecutor, pageProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Configuration configuration(StatementExecutor statementExecutor, ExpressionEngine expressionEngine, RequestExecutor requestExecutor, RequestMappingHandlerMapping requestMappingHandlerMapping) throws NoSuchMethodException {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.setRequestMappingHandlerMapping(requestMappingHandlerMapping);
|
||||
configuration.setRequestHandler(requestExecutor);
|
||||
configuration.setXmlLocations(properties.getXmlLocations());
|
||||
configuration.setEnableRefresh(properties.isEnableRefresh());
|
||||
configuration.setRequestHandleMethod(RequestExecutor.class.getDeclaredMethod("invoke", HttpServletRequest.class));
|
||||
requestExecutor.setConfiguration(configuration);
|
||||
requestExecutor.setExpressionEngine(expressionEngine);
|
||||
requestExecutor.setStatementExecutor(statementExecutor);
|
||||
return configuration;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.ssssssss.spring.boot.starter;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
@ConfigurationProperties(prefix = "ssssssss")
|
||||
public class S8Properties {
|
||||
|
||||
/**
|
||||
* xml文件位置
|
||||
*/
|
||||
private String[] xmlLocations;
|
||||
|
||||
/**
|
||||
* 启动自动刷新
|
||||
*/
|
||||
private boolean enableRefresh = true;
|
||||
|
||||
/**
|
||||
* 驼峰命名转换
|
||||
*/
|
||||
private boolean mapUnderscoreToCamelCase = true;
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private PageConfig pageConfig = new PageConfig();
|
||||
|
||||
public String[] getXmlLocations() {
|
||||
return xmlLocations;
|
||||
}
|
||||
|
||||
public void setXmlLocations(String[] xmlLocations) {
|
||||
this.xmlLocations = xmlLocations;
|
||||
}
|
||||
|
||||
public boolean isEnableRefresh() {
|
||||
return enableRefresh;
|
||||
}
|
||||
|
||||
public void setEnableRefresh(boolean enableRefresh) {
|
||||
this.enableRefresh = enableRefresh;
|
||||
}
|
||||
|
||||
public boolean isMapUnderscoreToCamelCase() {
|
||||
return mapUnderscoreToCamelCase;
|
||||
}
|
||||
|
||||
public void setMapUnderscoreToCamelCase(boolean mapUnderscoreToCamelCase) {
|
||||
this.mapUnderscoreToCamelCase = mapUnderscoreToCamelCase;
|
||||
}
|
||||
|
||||
public PageConfig getPageConfig() {
|
||||
return pageConfig;
|
||||
}
|
||||
|
||||
public void setPageConfig(PageConfig pageConfig) {
|
||||
this.pageConfig = pageConfig;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
{
|
||||
"groups" : [{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.S8Properties",
|
||||
"name": "ssssssss",
|
||||
"type": "com.ssssssss.spring.boot.starter.S8Properties"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.S8Properties",
|
||||
"name": "page-config",
|
||||
"sourceMethod": "getPageConfig()",
|
||||
"type": "com.ssssssss.spring.boot.starter.PageConfig"
|
||||
}],
|
||||
"properties" : [{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.PageConfig",
|
||||
"name": "ssssssss.page-config.page",
|
||||
"type": "java.lang.Long",
|
||||
"description": "page参数名"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.PageConfig",
|
||||
"name": "ssssssss.page-config.size",
|
||||
"type": "java.lang.Long",
|
||||
"defaultValue": "size",
|
||||
"description": "size参数名"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.PageConfig",
|
||||
"name": "ssssssss.page-config.defaul-page",
|
||||
"type": "java.lang.Long",
|
||||
"description": "默认首页"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.PageConfig",
|
||||
"name": "ssssssss.page-config.default-size",
|
||||
"type": "java.lang.Long",
|
||||
"description": "默认页大小"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.S8Properties",
|
||||
"name": "ssssssss.xml-locations",
|
||||
"type": "java.lang.String[]",
|
||||
"description": "XML文件位置"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.S8Properties",
|
||||
"name": "ssssssss.enableRefresh",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否启动自动刷新XML文件"
|
||||
},{
|
||||
"sourceType": "com.ssssssss.spring.boot.starter.S8Properties",
|
||||
"name": "ssssssss.mapUnderscoreToCamelCase",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否启用驼峰命名"
|
||||
}]
|
||||
}
|
||||
2
src/main/resources/META-INF/spring.factories
Normal file
2
src/main/resources/META-INF/spring.factories
Normal file
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.ssssssss.spring.boot.starter.S8AutoConfiguration
|
||||
Loading…
Reference in New Issue
Block a user