diff --git a/README.md b/README.md index fa675d323611194dbe44c14730538c65c937753b..e2a68bb92bfdc5a947bb26fb37201855b3b30af9 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ 基于`Spring Boot`框架,集成其他框架开发的`Starter` +[使用指南](https://yunjiao-source.github.io) + ## 发布版本 | 项目版本 | String Boot 版本 | @@ -86,15 +88,6 @@ mvn install ``` -## 使用指南 - -* starter-apijson-fastjson2 [使用指南](./doc/md/STARTER-APIJSON-FASTJSON2.md) -* starter-apijson-gson [使用指南](./doc/md/STARTER-APIJSON-GSON.md) -* starter-captcha [使用指南](./doc/md/STARTER-CAPTCHA.md) -* starter-id [使用指南](./doc/md/STARTER-ID.md) -* starter-querydsl-jpa [使用指南](./doc/md/STARTER-QUERYDSL-JPA.md) -* starter-querydsl-sql [使用指南](./doc/md/STARTER-QUERYDSL-SQL.md) - ## 参考 * [开发过程中遇到的问题](./FAQ.md) diff --git a/bin/set-git-user.cmd b/bin/set-git-user.cmd new file mode 100644 index 0000000000000000000000000000000000000000..31f573c381e2930e80378c98fd625df2576f346b --- /dev/null +++ b/bin/set-git-user.cmd @@ -0,0 +1,5 @@ +chcp 65001 +git config user.name "杨运交" +git config user.email "1290308475@qq.com" +git config --local --list +pause \ No newline at end of file diff --git a/bin/sync-github.cmd b/bin/sync-github.cmd index d3af8e46ebaa023f9c804c92b939ac0735c6bb75..cc62833b09791342d8b51690ecd03e435317cc8c 100644 --- a/bin/sync-github.cmd +++ b/bin/sync-github.cmd @@ -1,3 +1,3 @@ -git checkout master +sygit checkout master git pull origin master git push github master \ No newline at end of file diff --git a/doc/md/STARTER-APIJSON-FASTJSON2.md b/doc/md/STARTER-APIJSON-FASTJSON2.md deleted file mode 100644 index 5e64d1c76ec2fd47d462d10f214057ce079ad6ad..0000000000000000000000000000000000000000 --- a/doc/md/STARTER-APIJSON-FASTJSON2.md +++ /dev/null @@ -1,37 +0,0 @@ -# starter-apijson-fastjson2 - -集成`APIJSON`框架的启动器, 使用`apijson-fastjson2`插件 - -* 方便配置。在`application.yml`中配置参数,避免写死在程序中。所有的配置属性参考[application-all.yaml](../../examples/example-apijson-fastjson2/src/main/resources/application-all.yml) -* 支持数据库连接池 -* 提供多个接口,如:CRUD,登录, 登出等 - -详细使用参考示例[example-apijson-fastjson2](../../examples/example-apijson-fastjson2) - -## 使用Maven -在`pom.xml`中添加依赖 -```xml - - io.gitee.yunjiao-source.spring-boot - starter-apijson-fastjson2 - ${version} - -``` - -## 支持的接口 - - -| 接口url | 方法 | 说明 | -|-----------------------|------|--------------------------------------------------| -| common/{method} | POST | 支持GET,HEAD,GETS,HEADS,POST,PUT,DELETE,CRUD等 | -| common/{method}/{tag} | POST | 增删改查统一接口,这个一个接口可替代 7 个万能通用接口,牺牲一些路由解析性能来提升一点开发效率 | -| ext/reload | POST | 重新加载配置 | -| ext/post/verify | POST | 生成验证码 | -| ext/gets/verify | POST | 获取验证码 | -| ext/heads/verify | POST | 校验验证码 | -| ext/login | POST | 用户登录 | -| ext/logout | POST | 退出登录,清空session | -| ext/register | POST | 注册 | -| ext/put/password | POST | 设置密码 | - - diff --git a/doc/md/STARTER-APIJSON-GSON.md b/doc/md/STARTER-APIJSON-GSON.md deleted file mode 100644 index 96f5e762a7f404b9f11fdf0550df64085502d6f2..0000000000000000000000000000000000000000 --- a/doc/md/STARTER-APIJSON-GSON.md +++ /dev/null @@ -1,37 +0,0 @@ -# starter-apijson-gson - -集成`APIJSON`框架的启动器, 使用`apijson-gson`插件 - -* 方便配置。在`application.yml`中配置参数,避免写死在程序中。所有的配置属性参考[application-all.yaml](../../examples/example-apijson-gson/src/main/resources/application-all.yml) -* 支持数据库连接池 -* 提供多个接口,如:CRUD,登录, 登出等 - -详细使用参考示例[example-apijson-gson](../../examples/example-apijson-gson) - -## 使用Maven -在`pom.xml`中添加依赖 -```xml - - io.gitee.yunjiao-source.spring-boot - starter-apijson-gson - ${version} - -``` - -## 支持的接口 - - -| 接口url | 方法 | 说明 | -|-----------------------|------|--------------------------------------------------| -| common/{method} | POST | 支持GET,HEAD,GETS,HEADS,POST,PUT,DELETE,CRUD等 | -| common/{method}/{tag} | POST | 增删改查统一接口,这个一个接口可替代 7 个万能通用接口,牺牲一些路由解析性能来提升一点开发效率 | -| ext/reload | POST | 重新加载配置 | -| ext/post/verify | POST | 生成验证码 | -| ext/gets/verify | POST | 获取验证码 | -| ext/heads/verify | POST | 校验验证码 | -| ext/login | POST | 用户登录 | -| ext/logout | POST | 退出登录,清空session | -| ext/register | POST | 注册 | -| ext/put/password | POST | 设置密码 | - - diff --git a/doc/md/STARTER-CAPTCHA.md b/doc/md/STARTER-CAPTCHA.md deleted file mode 100644 index 1f6161b45d73a7bdee902c049be89d962e24a03d..0000000000000000000000000000000000000000 --- a/doc/md/STARTER-CAPTCHA.md +++ /dev/null @@ -1,23 +0,0 @@ -# start-captcha - -验证码生成启动器,集成`Hutool`,`aj-captcha`等框架 - -* 零配置。无需在yaml中配置参数,框架提供默认值 -* 支持多种验证码,包括:线段干扰验证码,圆圈干扰验证码,扭曲干扰验证码,GIF验证码,滑块拼图验证码,文字点选验证码,旋转拼图验证码 -* 提供丰富的配置参数,支持用户自定义。所有的配置参数参考[application-all.yml](../../examples/example-captcha/src/main/resources/application-all.yml) - -详细使用参考示例[example-captcha](../../examples/example-captcha) - -## 使用Maven - -在`pom.xml`中添加依赖 -```xml - - io.gitee.yunjiao-source.spring-boot - starter-captcha - ${version} - -``` - - - diff --git a/doc/md/STARTER-ID.md b/doc/md/STARTER-ID.md deleted file mode 100644 index 1cecd336907a8233551b56db2437eb029c14cb5c..0000000000000000000000000000000000000000 --- a/doc/md/STARTER-ID.md +++ /dev/null @@ -1,25 +0,0 @@ -## start-id - -ID生成启动器,集成`Hutool`, `Uid-Generator`等框架 - - -* Snowflake: `Hutool`实现的雪花算法。 -* UidGeneratorCached,UidGeneratorDefault:分别包装了`Uid-Generator`框架的`CachedUidGenerator`与`DefaultUidGenerator`,实现雪花算法。包装是因为这样可以方便的注入 - -详细使用参考示例[example-id](../../examples/example-id) - -## 使用Maven - -在`pom.xml`中添加依赖 -```xml - - io.gitee.yunjiao-source.spring-boot - starter-id - ${version} - -``` - - - - - diff --git a/doc/md/STARTER-QUERYDSL-JPA.md b/doc/md/STARTER-QUERYDSL-JPA.md deleted file mode 100644 index ef0706c7b38893542606a17881bc55ec119753e5..0000000000000000000000000000000000000000 --- a/doc/md/STARTER-QUERYDSL-JPA.md +++ /dev/null @@ -1,21 +0,0 @@ -## start-querydsl-jpa - -集成`QueryDSL JPA`框架的启动器。 - -* `JPAQueryRepositorySupport`仓库类,用户继承此类,集成功能:单个查询,列表查询,查询分页,查询Tuple,统计记录数,更新,删除等。支持数据库事务 -* `QSpecification`接口,用于复杂条件查询,支持:and, or, not等。类似`Spring`框架的`Specification` - - -详细使用参考示例[example-querydsl-jpa](../../examples/example-querydsl-jpa) - -## 使用Maven - -在`pom.xml`中添加依赖 -```xml - - io.gitee.yunjiao-source.spring-boot - starter-querydsl-jpa - ${version} - -``` - diff --git a/doc/md/STARTER-QUERYDSL-SQL.md b/doc/md/STARTER-QUERYDSL-SQL.md deleted file mode 100644 index 43d48d6376ec70e6ec44acba9316312c865e2d2f..0000000000000000000000000000000000000000 --- a/doc/md/STARTER-QUERYDSL-SQL.md +++ /dev/null @@ -1,21 +0,0 @@ -## start-querydsl-sql - -集成`QueryDSL SQL`框架的启动器。 - -* `SQLQueryRepositorySupport`仓库类,用户继承此类,集成功能:单个查询,列表查询,查询分页,查询Tuple,统计记录数,更新,删除等。支持数据库事务 -* `QSpecification`接口,用于复杂条件查询,支持:and, or, not等。类似`Spring`框架的`Specification` - - -详细使用参考示例[example-querydsl-sql](../../examples/example-querydsl-sql) - -## 使用Maven - -在`pom.xml`中添加依赖 -```xml - - io.gitee.yunjiao-source.spring-boot - starter-querydsl-sql - ${version} - -``` - diff --git a/doc/apijson/apifox.json b/docs/apijson/apifox.json similarity index 100% rename from doc/apijson/apifox.json rename to docs/apijson/apifox.json diff --git a/doc/apijson/postman.json b/docs/apijson/postman.json similarity index 100% rename from doc/apijson/postman.json rename to docs/apijson/postman.json diff --git a/doc/adoc/chapter/1.introduction.adoc b/docs/chapter/1.introduction.adoc similarity index 100% rename from doc/adoc/chapter/1.introduction.adoc rename to docs/chapter/1.introduction.adoc diff --git a/doc/adoc/chapter/2.id.adoc b/docs/chapter/2.id.adoc similarity index 100% rename from doc/adoc/chapter/2.id.adoc rename to docs/chapter/2.id.adoc diff --git a/doc/adoc/chapter/3.apijson.adoc b/docs/chapter/3.apijson.adoc similarity index 100% rename from doc/adoc/chapter/3.apijson.adoc rename to docs/chapter/3.apijson.adoc diff --git a/doc/adoc/chapter/4.captcha.adoc b/docs/chapter/4.captcha.adoc similarity index 100% rename from doc/adoc/chapter/4.captcha.adoc rename to docs/chapter/4.captcha.adoc diff --git a/doc/adoc/chapter/5.querydsl.adoc b/docs/chapter/5.querydsl.adoc similarity index 100% rename from doc/adoc/chapter/5.querydsl.adoc rename to docs/chapter/5.querydsl.adoc diff --git a/doc/adoc/index.adoc b/docs/index.adoc similarity index 100% rename from doc/adoc/index.adoc rename to docs/index.adoc diff --git a/examples/example-apijson-multipledatasource/pom.xml b/examples/example-apijson-multipledatasource/pom.xml index 5285fb38d4bcd4e85f2553508cce8606c66eb2c2..438c203048601b8c76695125111f0c505fc59cce 100644 --- a/examples/example-apijson-multipledatasource/pom.xml +++ b/examples/example-apijson-multipledatasource/pom.xml @@ -32,7 +32,6 @@ org.springframework spring-webflux - test diff --git a/examples/example-apijson-multipledatasource/src/main/java/yunjiao/springboot/example/apijson/ApijsonMultipleDataSourceConfiguration.java b/examples/example-apijson-multipledatasource/src/main/java/yunjiao/springboot/example/apijson/ApijsonMultipleDataSourceConfiguration.java index 014d85584cdd4e89ae03e11132ed75d5462c6e35..8e2574bb7f2a67b3d5d3bf45da51b7280a384ed2 100644 --- a/examples/example-apijson-multipledatasource/src/main/java/yunjiao/springboot/example/apijson/ApijsonMultipleDataSourceConfiguration.java +++ b/examples/example-apijson-multipledatasource/src/main/java/yunjiao/springboot/example/apijson/ApijsonMultipleDataSourceConfiguration.java @@ -9,10 +9,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import yunjiao.springboot.autoconfigure.apijson.MultipleDataSource; +import yunjiao.springboot.extension.common.spring.jdbc.MultipleDataSource; import yunjiao.springboot.autoconfigure.apijson.ApijsonSqlProperties; import yunjiao.springboot.example.apijson.fastjson2.CustomFastjson2Creator; -import yunjiao.springboot.extension.apjson.orm.DataSourceContextHolder; +import yunjiao.springboot.extension.common.spring.jdbc.DataSourceContextHolder; import yunjiao.springboot.extension.apjson.util.ApijsonConsts; import javax.sql.DataSource; diff --git a/examples/example-apijson-multipledatasource/src/test/java/yunjiao/springboot/example/apijson/MultipleDataSourceDemoTestIT.java b/examples/example-apijson-multipledatasource/src/test/java/yunjiao/springboot/example/apijson/MultipleDataSourceDemoTestIT.java index cf7236c98e1b82268a79d0c115a45e425ccdb7b6..88f4831a7fa19cbd925d0696bf8dc3c9b5c22373 100644 --- a/examples/example-apijson-multipledatasource/src/test/java/yunjiao/springboot/example/apijson/MultipleDataSourceDemoTestIT.java +++ b/examples/example-apijson-multipledatasource/src/test/java/yunjiao/springboot/example/apijson/MultipleDataSourceDemoTestIT.java @@ -17,14 +17,14 @@ import java.nio.charset.StandardCharsets; * @author yangyunjiao */ public class MultipleDataSourceDemoTestIT { - private WebClient commont = WebClient.builder() + private final WebClient commonClient = WebClient.builder() .baseUrl("http://localhost:8080/api-json/common") .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .build(); @Test void test1() { - String data = commont.post() + String data = commonClient.post() .uri("/get") .contentType(MediaType.APPLICATION_JSON) .bodyValue(readJson("1. 第一个查询.json")) @@ -37,7 +37,7 @@ public class MultipleDataSourceDemoTestIT { @Test void test2() { - String data = commont.post() + String data = commonClient.post() .uri("/get") .contentType(MediaType.APPLICATION_JSON) .bodyValue(readJson("2. 指定数据源查询.json")) diff --git a/extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/SqlConnectProvider.java b/extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/SqlConnectProvider.java index cfb7a7bc5ade178444bee4416b86e9fe3ad65aa8..301abbeaa7947920c904c6930958ade2a980cd05 100644 --- a/extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/SqlConnectProvider.java +++ b/extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/SqlConnectProvider.java @@ -4,6 +4,7 @@ import apijson.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; +import yunjiao.springboot.extension.common.spring.jdbc.DataSourceContextHolder; import javax.sql.DataSource; import java.sql.Connection; diff --git a/extensions/extension-common/pom.xml b/extensions/extension-common/pom.xml index 201b2589e703d33a8f40f8a42be9d3eb3be2b1e1..09b1dc2e55a0d14b9892571b16244bfe553bdddc 100644 --- a/extensions/extension-common/pom.xml +++ b/extensions/extension-common/pom.xml @@ -23,6 +23,10 @@ org.springframework spring-core + + org.springframework + spring-jdbc + cn.hutool hutool-core diff --git a/extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/DataSourceContextHolder.java b/extensions/extension-common/src/main/java/yunjiao/springboot/extension/common/spring/jdbc/DataSourceContextHolder.java similarity index 73% rename from extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/DataSourceContextHolder.java rename to extensions/extension-common/src/main/java/yunjiao/springboot/extension/common/spring/jdbc/DataSourceContextHolder.java index d0df3b2680ebc1b4f5f8c845528f45f5eacda25f..54826e6738108c94726ead5685bbc7006a5d8e2e 100644 --- a/extensions/extension-apijson/src/main/java/yunjiao/springboot/extension/apjson/orm/DataSourceContextHolder.java +++ b/extensions/extension-common/src/main/java/yunjiao/springboot/extension/common/spring/jdbc/DataSourceContextHolder.java @@ -1,4 +1,4 @@ -package yunjiao.springboot.extension.apjson.orm; +package yunjiao.springboot.extension.common.spring.jdbc; import org.springframework.util.StringUtils; @@ -13,10 +13,12 @@ public class DataSourceContextHolder { private static final ThreadLocal contextHolder = new ThreadLocal<>(); public static void setDataSourceType(String dsType) { - if(!StringUtils.hasText(dsType) || "null".equals(dsType)) { - dsType = DEFAULT; + if (!StringUtils.hasText(dsType)) { + contextHolder.set(DEFAULT); + } else { + contextHolder.set(dsType); } - contextHolder.set(dsType); + } public static String getDataSourceType() { diff --git a/autoconfigure/src/main/java/yunjiao/springboot/autoconfigure/apijson/MultipleDataSource.java b/extensions/extension-common/src/main/java/yunjiao/springboot/extension/common/spring/jdbc/MultipleDataSource.java similarity index 73% rename from autoconfigure/src/main/java/yunjiao/springboot/autoconfigure/apijson/MultipleDataSource.java rename to extensions/extension-common/src/main/java/yunjiao/springboot/extension/common/spring/jdbc/MultipleDataSource.java index 8d074a76865ca2b49f6f655610f564c3a8a1856f..88bf7eb6591175c8c63baa54d4062a4dfff739d1 100644 --- a/autoconfigure/src/main/java/yunjiao/springboot/autoconfigure/apijson/MultipleDataSource.java +++ b/extensions/extension-common/src/main/java/yunjiao/springboot/extension/common/spring/jdbc/MultipleDataSource.java @@ -1,7 +1,6 @@ -package yunjiao.springboot.autoconfigure.apijson; +package yunjiao.springboot.extension.common.spring.jdbc; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; -import yunjiao.springboot.extension.apjson.orm.DataSourceContextHolder; /** * 多数据源 diff --git a/pom.xml b/pom.xml index e61c7e199ef95f4d2f3f902a8a3afc183b986abc..a700e742ca5fb92707fae8ed674f9405ec1282a2 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 1.7.2 3.2.0 - yangyunjiao + 杨运交 1290308475@qq.com @@ -114,8 +114,8 @@ html - doc/adoc - doc/build/html + docs + docs/build/html @@ -126,8 +126,8 @@ pdf - doc/adoc - doc/build/pdf + docs + docs/build/pdf