Преглед изворни кода

Merge pull request #6 from hs-web/2.1-SNAPSHOT

2.1 snapshot
zhou hao пре 8 година
родитељ
комит
166d6a5100
100 измењених фајлова са 1626 додато и 2002 уклоњено
  1. 53 21
      README.md
  2. 49 0
      doc/1.安装使用.md
  3. 17 0
      hsweb-web-bean/README.md
  4. 1 1
      hsweb-web-bean/pom.xml
  5. 115 0
      hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/system/SystemVersion.java
  6. 0 3
      hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/template/Template.java
  7. 1 1
      hsweb-web-concurrent/hsweb-web-concurrent-cache/pom.xml
  8. 1 1
      hsweb-web-concurrent/hsweb-web-concurrent-lock/pom.xml
  9. 1 1
      hsweb-web-concurrent/pom.xml
  10. 1 1
      hsweb-web-controller/pom.xml
  11. 2 5
      hsweb-web-controller/src/main/java/org/hsweb/web/controller/AopAccessLoggerResolverAutoConfiguration.java
  12. 0 4
      hsweb-web-controller/src/main/java/org/hsweb/web/controller/AopAuthorizeValidatorAutoConfiguration.java
  13. 31 0
      hsweb-web-controller/src/main/resources/META-INF/spring-configuration-metadata.json
  14. 1 1
      hsweb-web-core/pom.xml
  15. 19 31
      hsweb-web-core/src/main/java/org/hsweb/web/core/Install.java
  16. 81 0
      hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DataSourceHolder.java
  17. 65 0
      hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DatabaseType.java
  18. 39 5
      hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DynamicDataSource.java
  19. 0 39
      hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DynamicDataSourceHolder.java
  20. 0 4
      hsweb-web-core/src/main/java/org/hsweb/web/core/logger/Slf4jAccessLoggerPersisting.java
  21. 22 31
      hsweb-web-core/src/main/java/org/hsweb/web/core/session/redis/RedisHttpSessionManager.java
  22. 1 1
      hsweb-web-dao/hsweb-web-dao-api/pom.xml
  23. 1 1
      hsweb-web-dao/hsweb-web-dao-mybatis/README.md
  24. 20 6
      hsweb-web-dao/hsweb-web-dao-mybatis/pom.xml
  25. 15 11
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/dynamic/DynamicDataSourceMyBatisAutoConfiguration.java
  26. 4 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/MybatisDaoAutoConfiguration.java
  27. 108 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/MybatisProperties.java
  28. 43 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/builder/SqlBuilder.java
  29. 1 1
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/dynamic/DynamicDataSourceSqlSessionFactoryBuilder.java
  30. 2 2
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/dynamic/DynamicSqlSessionFactory.java
  31. 3 23
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/plgins/pager/PagerInterceptor.java
  32. 151 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/META-INF/spring-configuration-metadata.json
  33. 5 5
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/basic/BasicMapper.xml
  34. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/classified/ClassifiedMapper.xml
  35. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/config/ConfigMapper.xml
  36. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/datasource/DataSourceMapper.xml
  37. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/form/FormMapper.xml
  38. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/history/HistoryMapper.xml
  39. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/module/ModuleMapper.xml
  40. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/module/ModuleMetaMapper.xml
  41. 0 74
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/basic/BasicMapper.xml
  42. 0 214
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/basic/BasicMapper.xml.old
  43. 0 93
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/form/FormMapper.xml
  44. 0 53
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/module/ModuleMapper.xml
  45. 0 62
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/user/UserMapper.xml
  46. 0 245
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/basic/BasicMapper.xml.old
  47. 0 52
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/classified/ClassifiedMapper.xml
  48. 0 49
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/config/ConfigMapper.xml
  49. 0 52
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/datasource/DataSourceMapper.xml
  50. 0 53
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/history/HistoryMapper.xml
  51. 0 51
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/module/ModuleMetaMapper.xml
  52. 0 65
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/plan/QueryPlanMapper.xml
  53. 0 48
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/profile/UserProfileMapper.xml
  54. 0 63
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/quartz/QuartzJobHistoryMapper.xml
  55. 0 67
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/quartz/QuartzJobMapper.xml
  56. 0 53
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/resource/ResourcesMapper.xml
  57. 0 48
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/role/RoleMapper.xml
  58. 0 62
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/role/RoleModuleMapper.xml
  59. 0 57
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/role/UserRoleMapper.xml
  60. 0 52
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/script/DynamicScriptMapper.xml
  61. 0 97
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/template/TemplateMapper.xml
  62. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/plan/QueryPlanMapper.xml
  63. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/profile/UserProfileMapper.xml
  64. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/quartz/QuartzJobHistoryMapper.xml
  65. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/quartz/QuartzJobMapper.xml
  66. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/resource/ResourcesMapper.xml
  67. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/role/RoleMapper.xml
  68. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/role/RoleModuleMapper.xml
  69. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/role/UserRoleMapper.xml
  70. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/script/DynamicScriptMapper.xml
  71. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/template/TemplateMapper.xml
  72. 0 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/user/UserMapper.xml
  73. 29 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/java/org/hsweb/web/mybatis/AbstractTestCase.java
  74. 64 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/java/org/hsweb/web/mybatis/SpringApplication.java
  75. 53 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/java/org/hsweb/web/mybatis/user/UserMapperTest.java
  76. 10 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/application.yml
  77. 19 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/logback.xml
  78. 56 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/mybatis-config.xml
  79. 19 0
      hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/transactions.properties
  80. 1 1
      hsweb-web-dao/pom.xml
  81. 1 1
      hsweb-web-datasource/pom.xml
  82. 11 11
      hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceAutoConfiguration.java
  83. 303 0
      hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceProperties.java
  84. 38 29
      hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceServiceImpl.java
  85. 23 10
      hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicXaDataSourceImpl.java
  86. 120 0
      hsweb-web-datasource/src/main/resources/META-INF/spring-configuration-metadata.json
  87. 1 1
      hsweb-web-oauth2/hsweb-web-oauth2-controller/pom.xml
  88. 1 1
      hsweb-web-oauth2/hsweb-web-oauth2-core/pom.xml
  89. 1 1
      hsweb-web-oauth2/hsweb-web-oauth2-mybatis/pom.xml
  90. 0 0
      hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/OAuth2AccessMapper.xml
  91. 0 0
      hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/OAuth2ClientMapper.xml
  92. 0 59
      hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/OAuth2AccessMapper.xml
  93. 0 64
      hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/OAuth2ClientMapper.xml
  94. 1 1
      hsweb-web-oauth2/hsweb-web-oauth2-service-simple/pom.xml
  95. 1 1
      hsweb-web-oauth2/hsweb-web-oauth2-simple/pom.xml
  96. 1 1
      hsweb-web-oauth2/pom.xml
  97. 1 1
      hsweb-web-service/hsweb-web-service-api/pom.xml
  98. 3 1
      hsweb-web-service/hsweb-web-service-api/src/main/java/org/hsweb/web/service/datasource/DynamicDataSourceService.java
  99. 16 10
      hsweb-web-service/hsweb-web-service-simple/pom.xml
  100. 0 0
      hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/DataBaseAutoConfiguration.java

+ 53 - 21
README.md

@@ -3,7 +3,31 @@
 [![Build Status](https://travis-ci.org/hs-web/hsweb-framework.svg?branch=master)](https://travis-ci.org/hs-web/hsweb-framework)
 [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)
 
-### 主要功能
+### 业务功能
+现在:
+
+1. 权限管理: 权限资源-角色-用户.
+2. 配置管理: kv结构,自定义配置.可通过此功能配置数据字典.
+3. 脚本管理: 动态脚本,支持javascript,groovy,java动态编译执行.
+4. 表单管理: 动态表单,可视化设计表单,自动生成数据库以及系统权限.无需重启直接生效.
+5. 模块设置: 配合动态表达没实现表格页,查询条件自定义.
+6. 数据库维护: 在线维护数据库,修改表结构,执行sql.
+7. 数据源管理: 配置多数据源.
+8. 代码生成器: 在线生成代码,打包下载.可自定义模板.
+9. 定时任务: 配置定时任务,使用动态脚本编写任务内容.
+10. 系统监控: 监控系统资源使用情况.
+11. 缓存监控: 监控缓存情况.
+12. 访问日志: 记录用户每次操作情况
+
+未来
+
+1. 组织架构管理: 地区-机构-部门-职务-人员.
+2. 工作流管理: activiti工作流,在线配置流程,配合动态表单实现自定义流程.
+3. 邮件代收: 代收指定邮箱的邮件
+
+
+### 框架功能
+0. 全局restful+json,前后分离.
 1. 通用dao,service,controller类,增删改查直接继承即可.
 2. 通用mybatis配置文件,支持多种条件查询自动生成,支持自动生成insert,update,delete语句,支持和查询相同的各种条件.
 3. 实现用户,权限管理;基于aop,注解,精确到按钮的权限控制.
@@ -14,30 +38,38 @@
 8. websocket支持.
 9. 定时调度支持,可在页面配置定时任务,编写任务脚本执行。
 
-### 其他组件
-1. [hsweb-easy-orm](https://github.com/hs-web/hsweb-easy-orm) :为动态表单设计的orm框架
-2. [hsweb-expands-compress](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-compress) :文件压缩,解压操作
-3. [hsweb-expands-office](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-office) :office文档操作( excel读写,模板导出,word模板导出)
-4. [hsweb-expands-request](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-request): 请求模拟(http,ftp)
-5. [hsweb-expands-script](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-script):动态脚本,动态编译执行java,groovy,javascript,spel,ognl....
-6. [hsweb-expands-shell](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-shell):shell执行
-7. [hsweb-expands-template](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-template):各种模板引擎
+### 演示
+1. 示例:[demo.hsweb.me](http://demo.hsweb.me)
+2. 测试用户:test (test2,test3,test4....) 密码:123456 
+3. 演示项目源码:[hsweb-platform](https://github.com/hs-web/hsweb-platform)
 
-# 安装
-```bash
-    $ git clone https://github.com/hs-web/hsweb-framework.git
-    $ cd hsweb-framework
-    $ mvn install -DskiptTests
-```
+### 文档
+1. [安装使用](doc/1.安装使用.md)
+2. [API](doc/2.API.md)
 
-# 此版本待完善功能
+### 此版本待完善功能
 1. 单元测试编写
 2. 项目文档编写
-3. 增加定时调度,支持集群,任务采用脚本方式编写.
+3. ~~增加定时调度,支持集群,任务采用脚本方式编写.~~
 4. 完善数据库持续集成,版本更新时自动更新数据库结构.
 5. 完善动态表单发布,表单发生变化后,自动重新发布(解决集群下,表单配置不一致).
 
-# 演示
-1. 示例:[demo.hsweb.me](http://demo.hsweb.me)
-2. 测试用户:test (test2,test3,test4....) 密码:123456 
-3. 演示项目源码:[hsweb-platform](https://github.com/hs-web/hsweb-platform)
+### 技术选型
+第三方:
+
+1. MVC:[spring-boot](https://github.com/spring-projects/spring-boot). 开箱即用,学习成本低,部署方便(main方法运行).
+2. ORM:[mybatis](https://github.com/mybatis/mybatis-3). 配置灵活,简单方便.
+3. JTA:[atomikos](https://www.atomikos.com/). 分布式事务,多数据源事务全靠他.
+4. Cache:[spring-cache](https://github.com/spring-projects/spring-framework/tree/master/spring-context/src/main/java/org/springframework/cache). 统一接口,注解使用,simple,redis... 自动切换.
+5. Scheduler:[quartz](https://github.com/quartz-scheduler/quartz). 开源稳定,支持集群.
+
+自家:
+
+0. [hsweb-commons](https://github.com/hs-web/hsweb-commons) :通用工具类
+1. [hsweb-easy-orm](https://github.com/hs-web/hsweb-easy-orm) :为动态表单设计的orm框架
+2. [hsweb-expands-compress](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-compress) :文件压缩,解压操作
+3. [hsweb-expands-office](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-office) :office文档操作( excel读写,模板导出,word模板导出)
+4. [hsweb-expands-request](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-request): 请求模拟(http,ftp)
+5. [hsweb-expands-script](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-script):动态脚本,动态编译执行java,groovy,javascript,spel,ognl....
+6. [hsweb-expands-shell](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-shell):shell执行
+7. [hsweb-expands-template](https://github.com/hs-web/hsweb-expands/tree/master/hsweb-expands-template):各种模板引擎

+ 49 - 0
doc/1.安装使用.md

@@ -0,0 +1,49 @@
+# 使用hsweb
+项目java8开发,使用maven进行管理.
+
+## 使用
+配置pom.xml
+```xml
+ <!--统一依赖管理-->
+ <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.hsweb</groupId>
+                <artifactId>hsweb-framework</artifactId>
+                <version>${hsweb.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+  <!--引入私服-->
+  <repositories>
+        <repository>
+            <id>hsweb-nexus</id>
+            <name>Nexus Release Repository</name>
+            <url>http://nexus.hsweb.me/content/groups/public/</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+```
+
+引入依赖
+```xml
+<!--设置了dependencyManagement,可以不指定版本号-->
+<dependency>
+        <groupId>org.hsweb</groupId>
+        <artifactId>hsweb-web-controller</artifactId>
+</dependency>
+
+<dependency>
+    <groupId>org.hsweb</groupId>
+    <artifactId>hsweb-web-service-simple</artifactId>
+</dependency>
+
+<dependency>
+    <groupId>org.hsweb</groupId>
+    <artifactId>hsweb-web-dao-mybatis</artifactId>
+</dependency>
+```

+ 17 - 0
hsweb-web-bean/README.md

@@ -0,0 +1,17 @@
+## 实体类模块,通用bean,po,和自定义验证器
+
+### 目录结构
+
+```bash
+--------src/main/java
+---------------------org.hsweb.web.bean
+----------------------------common      # 通用bean,如增删改查通用参数
+------------------------------po        # 各个功能的po实体
+----------------------------validator   # 自定义hibernate-validator
+-----------------resources/system
+---------------------------------install.sql #首次启动时执行的sql
+```
+
+### 说明
+po对象都应该继承[GenericPo](src/main/java/org/hsweb/web/bean/po/GenericPo.java)
+GenericPo 的泛型为主键的类型,hsweb建议使用String类型,通过createUID()方法手动生成id

+ 1 - 1
hsweb-web-bean/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-bean</artifactId>

+ 115 - 0
hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/system/SystemVersion.java

@@ -0,0 +1,115 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.bean.po.system;
+
+public class SystemVersion implements Comparable<SystemVersion> {
+    public String name;
+    public String comment;
+    public String website;
+    public int majorVersion    = 1;
+    public int minorVersion    = 0;
+    public int revisionVersion = 0;
+    public boolean snapshot;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public String getWebsite() {
+        return website;
+    }
+
+    public void setWebsite(String website) {
+        this.website = website;
+    }
+
+    public int getMajorVersion() {
+        return majorVersion;
+    }
+
+    public void setMajorVersion(int majorVersion) {
+        this.majorVersion = majorVersion;
+    }
+
+    public int getMinorVersion() {
+        return minorVersion;
+    }
+
+    public void setMinorVersion(int minorVersion) {
+        this.minorVersion = minorVersion;
+    }
+
+    public int getRevisionVersion() {
+        return revisionVersion;
+    }
+
+    public void setRevisionVersion(int revisionVersion) {
+        this.revisionVersion = revisionVersion;
+    }
+
+    public boolean isSnapshot() {
+        return snapshot;
+    }
+
+    public void setSnapshot(boolean snapshot) {
+        this.snapshot = snapshot;
+    }
+
+    @Override
+    public int compareTo(SystemVersion o) {
+        if (null == o) return -1;
+        if (o.getMajorVersion() > this.getMajorVersion()) return -1;
+        if (o.getMajorVersion() == this.getMajorVersion()) {
+            if (o.getMinorVersion() > this.getMinorVersion()) return -1;
+            if (o.getMinorVersion() == this.getMinorVersion()) {
+                if (o.getRevisionVersion() > this.getRevisionVersion()) return -1;
+                if (o.getRevisionVersion() == this.getRevisionVersion()) return 0;
+                return 1;
+            } else {
+                return 1;
+            }
+        } else {
+            return 1;
+        }
+    }
+
+    public static void main(String[] args) {
+        SystemVersion systemVersion = new SystemVersion();
+        systemVersion.setMajorVersion(2);
+        systemVersion.setMinorVersion(2);
+        systemVersion.setRevisionVersion(1);
+
+        SystemVersion systemVersion2 = new SystemVersion();
+        systemVersion2.setMajorVersion(3);
+        systemVersion2.setMinorVersion(2);
+        systemVersion2.setRevisionVersion(1);
+
+        System.out.println(systemVersion.compareTo(systemVersion2));
+    }
+}

+ 0 - 3
hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/template/Template.java

@@ -4,9 +4,6 @@ import org.hsweb.web.bean.po.GenericPo;
 
 import java.util.List;
 
-/**
- * Created by zhouhao on 16-5-19.
- */
 public class Template extends GenericPo<String> {
 
     private String name;

+ 1 - 1
hsweb-web-concurrent/hsweb-web-concurrent-cache/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-web-concurrent</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-concurrent-cache</artifactId>

+ 1 - 1
hsweb-web-concurrent/hsweb-web-concurrent-lock/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-web-concurrent</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-concurrent-lock</artifactId>

+ 1 - 1
hsweb-web-concurrent/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <packaging>pom</packaging>

+ 1 - 1
hsweb-web-controller/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-controller</artifactId>

+ 2 - 5
hsweb-web-controller/src/main/java/org/hsweb/web/controller/AopAccessLoggerResolverAutoConfiguration.java

@@ -21,12 +21,9 @@ import org.springframework.core.annotation.Order;
 import javax.annotation.PostConstruct;
 import java.util.List;
 
-/**
- * Created by zhouhao on 16-4-28.
- */
 @Configuration
-@ConditionalOnProperty(name = "logger.access", havingValue = "true")
-public class AopAccessLoggerResolverAutoConfiguration{
+@ConditionalOnProperty(name = "hsweb.access-logger", havingValue = "true")
+public class AopAccessLoggerResolverAutoConfiguration {
     @Bean
     public AopAccessLoggerResolverConfiguration aopAccessLoggerResolverConfiguration() {
         return new AopAccessLoggerResolverConfiguration();

+ 0 - 4
hsweb-web-controller/src/main/java/org/hsweb/web/controller/AopAuthorizeValidatorAutoConfiguration.java

@@ -11,11 +11,7 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.core.annotation.Order;
 
-/**
- * Created by zhouhao on 16-4-28.
- */
 @Configuration
-@ConditionalOnProperty(name = "login.enable", havingValue = "true")
 public class AopAuthorizeValidatorAutoConfiguration {
 
     @Bean

+ 31 - 0
hsweb-web-controller/src/main/resources/META-INF/spring-configuration-metadata.json

@@ -0,0 +1,31 @@
+{
+  "groups": [
+    {
+      "name": "hsweb.access-logger",
+      "type": "java.lang.String",
+      "sourceType": "java.lang.String"
+    }
+  ],
+  "properties": [
+    {
+      "name": "hsweb.access-logger",
+      "type": "java.lang.String",
+      "sourceType": "java.lang.String"
+    }
+  ],
+  "hints": [
+    {
+      "name": "hsweb.access-logger",
+      "values": [
+        {
+          "value": "on",
+          "description": "enable access logger."
+        },
+        {
+          "value": "off",
+          "description": "enable access logger."
+        }
+      ]
+    }
+  ]
+}

+ 1 - 1
hsweb-web-core/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-core</artifactId>

+ 19 - 31
hsweb-web-core/src/main/java/org/hsweb/web/core/Install.java

@@ -4,59 +4,39 @@ import org.hsweb.commons.file.FileUtils;
 import org.hsweb.ezorm.executor.SqlExecutor;
 import org.hsweb.ezorm.render.SqlAppender;
 import org.hsweb.ezorm.render.support.simple.SimpleSQL;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.hsweb.web.core.datasource.DataSourceHolder;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 import org.springframework.util.Assert;
 
 import javax.annotation.PostConstruct;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * Created by zhouhao on 16-4-23.
- */
 @Configuration
-@EnableConfigurationProperties({DataSourceProperties.class})
-@AutoConfigureAfter({DataSourceAutoConfiguration.class})
-@ConfigurationProperties(
-        prefix = "spring.datasource"
-)
 public class Install {
-    private static String DATABASE_TYPE = "h2";
-
     /**
      * 获取当前数据库类型
      *
      * @return
      */
     public static String getDatabaseType() {
-        return DATABASE_TYPE;
+        return DataSourceHolder.getActiveDatabaseType().name();
     }
 
-    @Autowired
-    private DataSourceProperties properties;
-
     @Autowired
     private SqlExecutor sqlExecutor;
 
-    private Logger logger = LoggerFactory.getLogger(this.getClass());
-
     @PostConstruct
     public void install() throws Exception {
-        String dc = properties.getDriverClassName();
-        String dbType = dc.contains("mysql") ? "mysql" : dc.contains("oracle") ? "oracle" : dc.contains("h2") ? "h2" : null;
-        DATABASE_TYPE = dbType;
+        String dbType = DataSourceHolder.getActiveDatabaseType().name();
         Assert.notNull(dbType, "不支持的数据库类型");
         try {
             boolean firstInstall = false;
@@ -82,14 +62,22 @@ public class Install {
         }
     }
 
-    protected void execInstallSql(InputStream sqlStream) throws UnsupportedEncodingException {
-        String username = properties.getUsername();
+    protected void execInstallSql(InputStream sqlStream) throws Exception {
+        String username = "";
+        Connection connection = null;
+        try {
+            connection = DataSourceHolder.getActiveSource().getConnection();
+            username = connection.getMetaData().getUserName();
+        } finally {
+            if (null != connection) connection.close();
+        }
         BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(sqlStream, "utf-8"));
         List<String> sqlList = new ArrayList<>();
         SqlAppender tmp = new SqlAppender();
+        String uname = username;
         bufferedReader.lines().forEach((line) -> {
             if (line.startsWith("--")) return;
-            line = line.replace("${jdbc.username}", username);
+            line = line.replace("${jdbc.username}", uname);
             //去除sql中的;
             if (line.endsWith(";"))
                 tmp.add(line.substring(0, line.length() - 1));

+ 81 - 0
hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DataSourceHolder.java

@@ -0,0 +1,81 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.core.datasource;
+
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class DataSourceHolder {
+
+    private static DynamicDataSource dynamicDataSource;
+
+    private static DataSource defaultDataSource;
+
+    private static DatabaseType defaultDatabaseType;
+
+    public void init(DataSource dataSource) throws SQLException {
+        if (null != dataSource) {
+            Connection connection = null;
+            try {
+                connection = dataSource.getConnection();
+                install(dataSource, DatabaseType.fromJdbcUrl(connection.getMetaData().getURL()));
+            } finally {
+                if (null != connection)
+                    connection.close();
+            }
+        }
+    }
+
+    public static DataSource getActiveSource() {
+        if (dynamicDataSource != null) {
+            return dynamicDataSource.getActiveDataSource();
+        }
+        return defaultDataSource;
+    }
+
+    public static DatabaseType getActiveDatabaseType() {
+        if (dynamicDataSource != null) {
+            return dynamicDataSource.getActiveDataBaseType();
+        }
+        return defaultDatabaseType;
+    }
+
+    public static DataSource getDefaultDataSource() {
+        return defaultDataSource;
+    }
+
+    public static DatabaseType getDefaultDatabaseType() {
+        return defaultDatabaseType;
+    }
+
+    public static void install(DynamicDataSource dynamicDataSource) {
+        if (DataSourceHolder.dynamicDataSource != null) {
+            throw new UnsupportedOperationException();
+        }
+        DataSourceHolder.dynamicDataSource = dynamicDataSource;
+    }
+
+    public static void install(DataSource dataSource, DatabaseType databaseType) {
+        if (DataSourceHolder.defaultDataSource != null) {
+            throw new UnsupportedOperationException();
+        }
+        DataSourceHolder.defaultDataSource = dataSource;
+        DataSourceHolder.defaultDatabaseType = databaseType;
+    }
+}

+ 65 - 0
hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DatabaseType.java

@@ -0,0 +1,65 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.core.datasource;
+
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+public enum DatabaseType {
+    unknown(null, null, null),
+    mysql("com.mysql.jdbc.Driver", "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource", "select 1"),
+    h2("org.h2.Driver", "org.h2.jdbcx.JdbcDataSource", "select 1"),
+    oracle("oracle.jdbc.driver.OracleDriver", "oracle.jdbc.xa.client.OracleXADataSource", "select 1 from dual");
+
+    DatabaseType(String driverClassName, String xaDataSourceClassName, String testQuery) {
+        this.driverClassName = driverClassName;
+        this.testQuery = testQuery;
+        this.xaDataSourceClassName = xaDataSourceClassName;
+    }
+
+    private final String testQuery;
+
+    private final String driverClassName;
+
+    private final String xaDataSourceClassName;
+
+    public String getDriverClassName() {
+        return driverClassName;
+    }
+
+    public String getXaDataSourceClassName() {
+        return xaDataSourceClassName;
+    }
+
+    public String getTestQuery() {
+        return testQuery;
+    }
+
+    public static DatabaseType fromJdbcUrl(String url) {
+        if (StringUtils.hasLength(url)) {
+            Assert.isTrue(url.startsWith("jdbc"), "URL must start with 'jdbc'");
+            String urlWithoutPrefix = url.substring("jdbc".length()).toLowerCase();
+            for (DatabaseType driver : values()) {
+                String prefix = ":" + driver.name().toLowerCase() + ":";
+                if (driver != unknown && urlWithoutPrefix.startsWith(prefix)) {
+                    return driver;
+                }
+            }
+        }
+        return unknown;
+    }
+}

+ 39 - 5
hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DynamicDataSource.java

@@ -17,42 +17,76 @@
 package org.hsweb.web.core.datasource;
 
 import org.hsweb.web.core.utils.ThreadLocalUtils;
-import org.springframework.jca.cci.connection.ConnectionHolder;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-import javax.sql.CommonDataSource;
 import javax.sql.DataSource;
 
 /**
- * @author zhouhao
+ * 动态数据源接口,此接口实现多数据源的动态切换
+ *
+ * @see DataSourceHolder
  */
 public interface DynamicDataSource extends DataSource {
     String DATA_SOURCE_FLAG = "data-source-id";
 
     String DATA_SOURCE_FLAG_LAST = "data-source-id-last";
 
-
+    /**
+     * 使用上一次调用的数据源
+     */
     static void useLast() {
         use(ThreadLocalUtils.get(DATA_SOURCE_FLAG_LAST));
     }
 
+    /**
+     * 选中参数(数据源ID)对应的数据源,如果数据源不存在,将使用默认数据源
+     *
+     * @param dataSourceId 数据源ID
+     */
     static void use(String dataSourceId) {
         ThreadLocalUtils.put(DATA_SOURCE_FLAG, dataSourceId);
     }
 
+    /**
+     * 获取当前使用的数据源ID,如果不存在则返回null
+     *
+     * @return 数据源ID
+     */
     static String getActiveDataSourceId() {
         return ThreadLocalUtils.get(DATA_SOURCE_FLAG);
     }
 
+    /**
+     * 切换为默认数据源,并指定是否记住上一次选中的数据源
+     *
+     * @param rememberLast 是否记住上一次选中的数据源
+     */
     static void useDefault(boolean rememberLast) {
         if (getActiveDataSourceId() != null && rememberLast)
             ThreadLocalUtils.put(DATA_SOURCE_FLAG_LAST, getActiveDataSourceId());
         ThreadLocalUtils.remove(DATA_SOURCE_FLAG);
     }
 
+    /**
+     * 切换为默认数据源并记住上一次使用的数据源
+     *
+     * @see this#useDefault(boolean)
+     */
     static void useDefault() {
         useDefault(true);
     }
 
+    /**
+     * 获取当前激活的数据源
+     *
+     * @return
+     */
     DataSource getActiveDataSource();
+
+    /**
+     * 获取当前激活数据源的数据库类型
+     *
+     * @return 数据库类型
+     * @see DatabaseType
+     */
+    DatabaseType getActiveDataBaseType();
 }

+ 0 - 39
hsweb-web-core/src/main/java/org/hsweb/web/core/datasource/DynamicDataSourceHolder.java

@@ -1,39 +0,0 @@
-/*
- * Copyright 2015-2016 http://hsweb.me
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.hsweb.web.core.datasource;
-
-
-import javax.sql.DataSource;
-
-public class DynamicDataSourceHolder {
-
-    private static DynamicDataSource dynamicDataSource;
-
-    public static DataSource getActiveSource() {
-        if (dynamicDataSource != null) {
-            return dynamicDataSource.getActiveDataSource();
-        }
-        return null;
-    }
-
-    public static void install(DynamicDataSource dynamicDataSource) {
-        if (DynamicDataSourceHolder.dynamicDataSource != null) {
-            throw new UnsupportedOperationException();
-        }
-        DynamicDataSourceHolder.dynamicDataSource = dynamicDataSource;
-    }
-}

+ 0 - 4
hsweb-web-core/src/main/java/org/hsweb/web/core/logger/Slf4jAccessLoggerPersisting.java

@@ -8,10 +8,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-/**
- * Created by zhouhao on 16-4-28.
- */
-@Component
 public class Slf4jAccessLoggerPersisting implements AccessLoggerPersisting {
     protected Logger logger = LoggerFactory.getLogger(this.getClass());
     @Autowired(required = false)

+ 22 - 31
hsweb-web-core/src/main/java/org/hsweb/web/core/session/redis/RedisHttpSessionManager.java

@@ -26,14 +26,12 @@ public class RedisHttpSessionManager extends AbstractHttpSessionManager {
 
     @Override
     public Set<User> tryGetAllUser() {
-        return (Set<User>) sessionRedisTemplate.execute((RedisCallback<Set<User>>) connection -> {
-            Set<byte[]> keys = connection.keys("spring:session:sessions:*".getBytes());
-            return keys.stream().map(key -> {
-                String sessionId = new String(key).split("[:]")[3];
-                ExpiringSession expiringSession = redisOperationsSessionRepository.getSession(sessionId);
-                return (User) expiringSession.getAttribute("user");
-            }).filter(user -> user != null).collect(Collectors.toSet());
-        });
+        return (Set<User>) sessionRedisTemplate.keys("spring:session:sessions:*")
+                .stream().map(key -> {
+                    String sessionId = String.valueOf(key).split("[:]")[3];
+                    ExpiringSession expiringSession = redisOperationsSessionRepository.getSession(sessionId);
+                    return expiringSession.getAttribute("user");
+                }).filter(user -> user != null).collect(Collectors.toSet());
     }
 
     @Override
@@ -59,40 +57,33 @@ public class RedisHttpSessionManager extends AbstractHttpSessionManager {
     @Override
     public HttpSession getSessionBySessionId(String sessionId) {
         ExpiringSession redisSession = redisOperationsSessionRepository.getSession(sessionId);
-        if(redisSession==null)return null;
+        if (redisSession == null) return null;
         return new HttpSessionWrapper(redisSession);
     }
 
     @Override
     public void removeUser(String userId) {
-        sessionRedisTemplate.execute((RedisCallback) connection -> {
-            String key = "http.session.user:" + userId;
-            String sessionId = getSessionIdByUserId(userId);
-            ExpiringSession redisSession = redisOperationsSessionRepository.getSession(sessionId);
-            HttpSession session = new HttpSessionWrapper(redisSession);
-            onUserLoginOut(userId, session);
-            removeSession(sessionId);
-            return connection.del(key.getBytes());
-        });
+        String key = "http.session.user:" + userId;
+        String sessionId = getSessionIdByUserId(userId);
+        ExpiringSession redisSession = redisOperationsSessionRepository.getSession(sessionId);
+        HttpSession session = new HttpSessionWrapper(redisSession);
+        onUserLoginOut(userId, session);
+        removeSession(sessionId);
+        sessionRedisTemplate.delete(key);
     }
 
     @Override
     public void removeSession(String sessionId) {
-        sessionRedisTemplate.execute((RedisCallback) connection ->
-                        connection.del(("spring:session:sessions:" + sessionId).getBytes())
-        );
+        sessionRedisTemplate.delete("spring:session:sessions:".concat(sessionId));
     }
 
     @Override
     public void addUser(User user, HttpSession session) {
         removeUser(user.getId());
-        sessionRedisTemplate.execute((RedisCallback) connection -> {
-            String key = "http.session.user:" + user.getId();
-            String value = session.getId();
-            connection.set(key.getBytes(), value.getBytes());
-            onUserLogin(user, session);
-            return null;
-        });
+        String key = "http.session.user:" + user.getId();
+        String value = session.getId();
+        sessionRedisTemplate.opsForValue().set(key, value);
+        onUserLogin(user, session);
     }
 
     @Override
@@ -131,7 +122,7 @@ public class RedisHttpSessionManager extends AbstractHttpSessionManager {
     @Override
     public boolean isLogin(String userId) {
         return (Boolean) sessionRedisTemplate.execute((RedisCallback) connection ->
-                        connection.exists(("http.session.user:" + userId).getBytes())
+                connection.exists(("http.session.user:" + userId).getBytes())
         );
     }
 
@@ -145,8 +136,8 @@ public class RedisHttpSessionManager extends AbstractHttpSessionManager {
 
     private final class HttpSessionWrapper implements HttpSession {
         private ExpiringSession session;
-        private boolean invalidated;
-        private boolean old;
+        private boolean         invalidated;
+        private boolean         old;
 
         public HttpSessionWrapper(ExpiringSession session) {
             this.session = session;

+ 1 - 1
hsweb-web-dao/hsweb-web-dao-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-web-dao</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-dao-api</artifactId>

+ 1 - 1
hsweb-web-dao/hsweb-web-dao-mybatis/README.md

@@ -10,7 +10,7 @@
      <dependency>
         <groupId>org.hsweb</groupId>
         <artifactId>hsweb-web-dao-mybatis</artifactId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </dependency>
 ```
 

+ 20 - 6
hsweb-web-dao/hsweb-web-dao-mybatis/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-web-dao</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-dao-mybatis</artifactId>
@@ -17,6 +17,20 @@
     </properties>
 
     <dependencies>
+
+        <!--test-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.0.26</version>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.hsweb</groupId>
             <artifactId>hsweb-web-dao-api</artifactId>
@@ -32,11 +46,11 @@
             <artifactId>spring-boot-starter-jdbc</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.hsweb</groupId>
-            <artifactId>hsweb-web-datasource</artifactId>
-            <optional>true</optional>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.hsweb</groupId>-->
+            <!--<artifactId>hsweb-web-datasource</artifactId>-->
+            <!--<optional>true</optional>-->
+        <!--</dependency>-->
 
         <!-- mybatis start-->
         <dependency>

+ 15 - 11
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/dynamic/DynamicDataSourceMyBatisAutoConfiguration.java

@@ -14,18 +14,17 @@
  * limitations under the License.
  */
 
-package org.hsweb.web.mybatis.dynamic;
+package org.hsweb.web.mybatis;
 
 import org.apache.ibatis.mapping.DatabaseIdProvider;
 import org.apache.ibatis.plugin.Interceptor;
 import org.apache.ibatis.session.SqlSessionFactory;
-import org.hsweb.web.datasource.dynamic.DynamicDataSourceAutoConfiguration;
+import org.hsweb.web.mybatis.dynamic.DynamicDataSourceSqlSessionFactoryBuilder;
 import org.mybatis.spring.SqlSessionFactoryBean;
-import org.mybatis.spring.boot.autoconfigure.MybatisProperties;
 import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -36,10 +35,9 @@ import org.springframework.util.StringUtils;
 import javax.sql.DataSource;
 
 @Configuration
-@AutoConfigureAfter(DynamicDataSourceAutoConfiguration.class)
 @EnableConfigurationProperties(MybatisProperties.class)
-@ConditionalOnProperty(prefix = "mybatis", value = "dynamic-datasource")
-public class DynamicDataSourceMyBatisAutoConfiguration {
+@ConditionalOnClass({SqlSessionFactory.class, SqlSessionFactoryBean.class})
+public class MyBatisAutoConfiguration {
 
     @Autowired
     private MybatisProperties properties;
@@ -54,9 +52,10 @@ public class DynamicDataSourceMyBatisAutoConfiguration {
     private DatabaseIdProvider databaseIdProvider;
 
     @Bean(name = "sqlSessionFactory")
-    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
+    public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
         SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
-        factory.setSqlSessionFactoryBuilder(new DynamicDataSourceSqlSessionFactoryBuilder());
+        if (properties.isDynamicDatasource())
+            factory.setSqlSessionFactoryBuilder(new DynamicDataSourceSqlSessionFactoryBuilder());
         factory.setDataSource(dataSource);
         factory.setVfs(SpringBootVFS.class);
         if (StringUtils.hasText(this.properties.getConfig())) {
@@ -70,8 +69,13 @@ public class DynamicDataSourceMyBatisAutoConfiguration {
             factory.setDatabaseIdProvider(this.databaseIdProvider);
         }
         factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
-        factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
+        String typeHandlers = "org.hsweb.web.mybatis.handler";
+        if (this.properties.getTypeHandlersPackage() != null) {
+            typeHandlers = typeHandlers + ";" + this.properties.getTypeHandlersPackage();
+        }
+        factory.setTypeHandlersPackage(typeHandlers);
         factory.setMapperLocations(this.properties.resolveMapperLocations());
         return factory.getObject();
     }
+
 }

+ 4 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/MybatisDaoAutoConfiguration.java

@@ -4,6 +4,8 @@ import org.hsweb.web.mybatis.utils.ResultMapsUtils;
 import org.mybatis.spring.SqlSessionTemplate;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 
@@ -12,6 +14,8 @@ import javax.annotation.PostConstruct;
 @Configuration
 @ComponentScan(basePackages = {"org.hsweb.web.mybatis"})
 @MapperScan(basePackages = {"org.hsweb.web.dao"})
+@AutoConfigureAfter(MyBatisAutoConfiguration.class)
+@EnableConfigurationProperties(MybatisProperties.class)
 public class MybatisDaoAutoConfiguration {
 
     @Autowired

+ 108 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/MybatisProperties.java

@@ -0,0 +1,108 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.mybatis;
+
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * mybatis配置,继承官方配置类,增加一些属性以拓展更多功能
+ * <ul>
+ * <li>是否启用动态数据源{@link this#dynamicDatasource}</li>
+ * <li>可设置不加载的配置{@link this#mapperLocationExcludes}</li>
+ * </ul>
+ *
+ * @author zhouhao
+ * @see org.mybatis.spring.boot.autoconfigure.MybatisProperties
+ * @since 2.1
+ */
+public class MybatisProperties extends org.mybatis.spring.boot.autoconfigure.MybatisProperties {
+    /**
+     * 默认支持的hsweb mapper
+     */
+    private static final String   defaultMapperLocation  = "classpath*:org/hsweb/web/dao/impl/mybatis/mapper/**/*.xml";
+    /**
+     * 是否启用动态数据源
+     * 启用后调用{@link org.hsweb.web.core.datasource.DynamicDataSource#use(String)},mybatis也会进行数据源切换
+     *
+     * @see org.hsweb.web.core.datasource.DynamicDataSource
+     */
+    private              boolean  dynamicDatasource      = false;
+    /**
+     * 排除加载的mapper.xml
+     * 想自定义mapper并覆盖原始mapper的场景下,通过设置此属性来排除配置文件。
+     * 排除使用{@link Resource#getURL()#toString()}进行对比
+     */
+    private              String[] mapperLocationExcludes = null;
+
+    public String[] getMapperLocationExcludes() {
+        return mapperLocationExcludes;
+    }
+
+    public void setMapperLocationExcludes(String[] mapperLocationExcludes) {
+        this.mapperLocationExcludes = mapperLocationExcludes;
+    }
+
+    public boolean isDynamicDatasource() {
+        return dynamicDatasource;
+    }
+
+    public void setDynamicDatasource(boolean dynamicDatasource) {
+        this.dynamicDatasource = dynamicDatasource;
+    }
+
+    public Resource[] resolveMapperLocations() {
+        Map<String, Resource> resources = new HashMap<>();
+        Set<String> locations;
+
+        if (this.getMapperLocations() == null)
+            locations = new HashSet<>();
+        else
+            locations = Arrays.stream(getMapperLocations()).collect(Collectors.toSet());
+        locations.add(defaultMapperLocation);
+        for (String mapperLocation : locations) {
+            Resource[] mappers;
+            try {
+                mappers = new PathMatchingResourcePatternResolver().getResources(mapperLocation);
+                for (Resource mapper : mappers) {
+                    resources.put(mapper.getURL().toString(), mapper);
+                }
+            } catch (IOException e) {
+            }
+        }
+        //排除不需要的配置
+        if (mapperLocationExcludes != null && mapperLocationExcludes.length > 0) {
+            for (String mapperLocationExclude : mapperLocationExcludes) {
+                try {
+                    Resource[] excludesMappers = new PathMatchingResourcePatternResolver().getResources(mapperLocationExclude);
+                    for (Resource excludesMapper : excludesMappers) {
+                        resources.remove(excludesMapper.getURL().toString());
+                    }
+                } catch (IOException e) {
+                }
+            }
+        }
+        Resource[] mapperLocations = new Resource[resources.size()];
+        mapperLocations = resources.values().toArray(mapperLocations);
+        return mapperLocations;
+    }
+
+}

+ 43 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/builder/SqlBuilder.java

@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.mybatis.builder;
+
+import org.hsweb.web.core.datasource.DataSourceHolder;
+import org.hsweb.web.core.datasource.DatabaseType;
+
+/**
+ * @author zhouhao
+ */
+public class SqlBuilder {
+    private static boolean dynamic;
+
+    public static final Object current() {
+        DatabaseType type = dynamic
+                ? DataSourceHolder.getActiveDatabaseType()
+                : DataSourceHolder.getDefaultDatabaseType();
+        switch (type) {
+            case mysql:
+                return MysqlParamBuilder.instance();
+            default:
+                return DefaultSqlParamBuilder.instance();
+        }
+    }
+
+    public static void setDynamic(boolean dynamic) {
+        SqlBuilder.dynamic = dynamic;
+    }
+}

+ 1 - 1
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/dynamic/DynamicDataSourceSqlSessionFactoryBuilder.java

@@ -23,6 +23,6 @@ import org.apache.ibatis.session.SqlSessionFactoryBuilder;
 public class DynamicDataSourceSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
     @Override
     public SqlSessionFactory build(Configuration config) {
-            return new DynamicSqlSessionFactory(config);
+        return new DynamicSqlSessionFactory(config);
     }
 }

+ 2 - 2
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/dynamic/DynamicSqlSessionFactory.java

@@ -25,7 +25,7 @@ import org.apache.ibatis.session.defaults.DefaultSqlSession;
 import org.apache.ibatis.transaction.Transaction;
 import org.apache.ibatis.transaction.TransactionFactory;
 import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
-import org.hsweb.web.core.datasource.DynamicDataSourceHolder;
+import org.hsweb.web.core.datasource.DataSourceHolder;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -91,7 +91,7 @@ public class DynamicSqlSessionFactory implements SqlSessionFactory {
         try {
             final Environment environment = getConfiguration().getEnvironment();
             final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment(environment);
-            DataSource ds = DynamicDataSourceHolder.getActiveSource();
+            DataSource ds = DataSourceHolder.getActiveSource();
             if (ds == null) ds = environment.getDataSource();
             tx = transactionFactory.newTransaction(ds, level, autoCommit);
             final Executor executor = getConfiguration().newExecutor(tx, execType);

+ 3 - 23
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/java/org/hsweb/web/mybatis/plgins/pager/PagerInterceptor.java

@@ -1,8 +1,6 @@
 package org.hsweb.web.mybatis.plgins.pager;
 
 import org.apache.ibatis.executor.Executor;
-import org.apache.ibatis.executor.resultset.ResultSetHandler;
-import org.apache.ibatis.executor.statement.RoutingStatementHandler;
 import org.apache.ibatis.executor.statement.StatementHandler;
 import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.plugin.*;
@@ -11,11 +9,8 @@ import org.apache.ibatis.reflection.SystemMetaObject;
 import org.apache.ibatis.session.ResultHandler;
 import org.apache.ibatis.session.RowBounds;
 import org.hsweb.web.bean.common.QueryParam;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.hsweb.web.core.datasource.DataSourceHolder;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
-import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;
 
@@ -28,14 +23,10 @@ import java.util.Properties;
         RowBounds.class, ResultHandler.class})})
 @Component
 public class PagerInterceptor implements Interceptor {
-    protected Logger logger = LoggerFactory.getLogger(this.getClass());
     protected Map<String, PagerHelper> pagerHelperBase = new HashMap<>();
 
-    protected String dialect = null;
     @Autowired
     private ApplicationContext context;
-    @Autowired
-    private DataSourceProperties properties;
 
     @Override
     public Object intercept(Invocation target) throws Throwable {
@@ -51,7 +42,7 @@ public class PagerInterceptor implements Interceptor {
             Object obj = statementHandler.getParameterHandler().getParameterObject();
             if (obj instanceof QueryParam) {
                 QueryParam param = (QueryParam) obj;
-                PagerHelper helper = pagerHelperBase.get(dialect);
+                PagerHelper helper = pagerHelperBase.get(getDialect());
                 if (helper != null && param.isPaging() && !sql.contains("count(0)")) {
                     String newSql = helper.doPaging(param, sql);
                     metaStatementHandler.setValue("delegate.boundSql.sql", newSql);
@@ -63,26 +54,15 @@ public class PagerInterceptor implements Interceptor {
 
     @Override
     public void setProperties(Properties properties) {
-        System.out.println(properties);
     }
 
     @PostConstruct
     public void init() {
         Map<String, PagerHelper> helperMap = context.getBeansOfType(PagerHelper.class);
         helperMap.forEach((name, helper) -> pagerHelperBase.put(helper.getDialect(), helper));
-        dialect = getDialect();
     }
 
     public String getDialect() {
-        String url = properties.getDriverClassName();
-        if (url.contains("mysql")) {
-            return "mysql";
-        } else if (url.contains("oracle")) {
-            return "oracle";
-        } else if (url.contains("h2")) {
-            return "h2";
-        } else
-            logger.error("mybatis pager dialect not found!");
-        return "undefine";
+        return DataSourceHolder.getDefaultDatabaseType().name();
     }
 }

+ 151 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/META-INF/spring-configuration-metadata.json

@@ -0,0 +1,151 @@
+{
+  "groups": [
+    {
+      "name": "mybatis",
+      "type": "org.hsweb.web.mybatis.MybatisProperties",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    }
+  ],
+  "properties": [
+    {
+      "name": "mybatis.dynamic-datasource",
+      "type": "java.lang.Boolean",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties",
+      "description": "enable dynamicDatasource."
+    },
+    {
+      "name": "mybatis.mapper-location-excludes",
+      "type": "java.lang.String[]",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties",
+      "description": "exclude mapperLocations."
+    },
+    {
+      "name": "mybatis.check-config-location",
+      "type": "java.lang.Boolean",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.check-config-location",
+      "type": "java.lang.Boolean",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.check-config-location",
+      "type": "java.lang.Boolean",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.check-config-location",
+      "type": "java.lang.Boolean",
+      "description": "Check the config file exists.",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties",
+      "defaultValue": false
+    },
+    {
+      "name": "mybatis.config",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.config",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.config",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.config",
+      "type": "java.lang.String",
+      "description": "Config file path.",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.executor-type",
+      "type": "org.apache.ibatis.session.ExecutorType",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.executor-type",
+      "type": "org.apache.ibatis.session.ExecutorType",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.executor-type",
+      "type": "org.apache.ibatis.session.ExecutorType",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.executor-type",
+      "type": "org.apache.ibatis.session.ExecutorType",
+      "description": "Execution mode.",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.mapper-locations",
+      "type": "java.lang.String[]",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.mapper-locations",
+      "type": "java.lang.String[]",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.mapper-locations",
+      "type": "java.lang.String[]",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.mapper-locations",
+      "type": "java.lang.String[]",
+      "description": "Location of mybatis mapper files.",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-aliases-package",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-aliases-package",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-aliases-package",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-aliases-package",
+      "type": "java.lang.String",
+      "description": "Package to scan domain objects.",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-handlers-package",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-handlers-package",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-handlers-package",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    },
+    {
+      "name": "mybatis.type-handlers-package",
+      "type": "java.lang.String",
+      "description": "Package to scan handlers.",
+      "sourceType": "org.hsweb.web.mybatis.MybatisProperties"
+    }
+  ],
+  "hints": []
+}

+ 5 - 5
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/basic/BasicMapper.xml

@@ -5,24 +5,24 @@
 <mapper namespace="BasicMapper">
     <!--通用查询条件-->
     <sql id="buildWhere">
-        ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildWhere(resultMapId,tableName,#this['_parameter'].terms)}
+        ${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildWhere(resultMapId,tableName,#this['_parameter'].terms)}
     </sql>
 
     <!--生成查询字段-->
     <sql id="buildSelectField">
-        ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildSelectFields(resultMapId,tableName,#this['_parameter'])}
+        ${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildSelectFields(resultMapId,tableName,#this['_parameter'])}
     </sql>
 
     <!--生成修改字段-->
     <sql id="buildUpdateField">
         <set>
-            ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildUpdateFields(resultMapId,#this['_parameter'])}
+            ${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildUpdateFields(resultMapId,#this['_parameter'])}
         </set>
     </sql>
 
     <!--生成排序字段-->
     <sql id="buildSortField">
-        ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildOrder(resultMapId,tableName,#this['_parameter'])}
+        ${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildOrder(resultMapId,tableName,#this['_parameter'])}
     </sql>
 
     <!--生成查询sql-->
@@ -49,7 +49,7 @@
 
     <!--生成InsertSql-->
     <sql id="buildInsertSql">
-        insert into ${tableName} ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildInsertSql(resultMapId,#this['_parameter'])}
+        insert into ${tableName} ${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildInsertSql(resultMapId,#this['_parameter'])}
     </sql>
 
     <!--生成UpdateSql-->

hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/classified/ClassifiedMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/classified/ClassifiedMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/config/ConfigMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/config/ConfigMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/datasource/DataSourceMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/datasource/DataSourceMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/form/FormMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/form/FormMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/history/HistoryMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/history/HistoryMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/module/ModuleMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/module/ModuleMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/module/ModuleMetaMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/module/ModuleMetaMapper.xml


+ 0 - 74
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/basic/BasicMapper.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="BasicMapper">
-    <!--通用查询条件-->
-    <sql id="buildWhere">
-        ${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildWhere(resultMapId,tableName,#this['_parameter'].terms)}
-    </sql>
-
-    <!--生成查询字段-->
-    <sql id="buildSelectField">
-        ${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildSelectFields(resultMapId,tableName,#this['_parameter'])}
-    </sql>
-
-    <!--生成修改字段-->
-    <sql id="buildUpdateField">
-        <set>
-            ${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildUpdateFields(resultMapId,#this['_parameter'])}
-        </set>
-    </sql>
-
-    <!--生成排序字段-->
-    <sql id="buildSortField">
-        ${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildOrder(resultMapId,tableName,#this['_parameter'])}
-    </sql>
-
-    <!--生成查询sql-->
-    <sql id="buildSelectSql">
-        select
-        <include refid="BasicMapper.buildSelectField"/>
-        from ${tableName}
-        <where>
-            <include refid="BasicMapper.buildWhere"/>
-        </where>
-        <include refid="BasicMapper.buildSortField"/>
-    </sql>
-
-    <!--生成删除sql-->
-    <sql id="buildDeleteSql">
-        delete ${tableName} from ${tableName}
-        <where>
-            <include refid="BasicMapper.buildWhere"/>
-            <if test="terms.size()==0">
-              1=2
-            </if>
-        </where>
-    </sql>
-
-    <!--生成InsertSql-->
-    <sql id="buildInsertSql">
-        insert into ${tableName} ${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildInsertSql(resultMapId,#this['_parameter'])}
-    </sql>
-
-    <!--生成UpdateSql-->
-    <sql id="buildUpdateSql">
-        update ${tableName}
-        <include refid="BasicMapper.buildUpdateField"/>
-        <where>
-            <include refid="BasicMapper.buildWhere"/>
-            <if test="terms.size()==0">
-                u_id=#{data.id}
-            </if>
-        </where>
-    </sql>
-
-    <!--生成查询数量sql-->
-    <sql id="buildTotalSql">
-        select count(0) as "total" from ${tableName}
-        <where>
-            <include refid="BasicMapper.buildWhere"/>
-        </where>
-    </sql>
-</mapper>

+ 0 - 214
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/basic/BasicMapper.xml.old

@@ -1,214 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="BasicMapper">
-    <sql id="buildWhereV2">
-        ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildWhere($fieldsInfo,#this['_parameter'].terms)}
-    </sql>
-    <!--通用查询条件-->
-    <sql id="buildWhere">
-        <include refid="BasicMapper.buildWhereV2"/>
-        <!--动态生成查询条件-->
-        <!--<foreach item="item" index="index" collection="$fields">-->
-            <!--<if test="#this['term.'+item]!=null">-->
-                <!--AND `${$tableName}`.`${item}`=#{term.${item}}-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$NOT']!=null">-->
-                <!--AND `${$tableName}`.`${item}`!=#{term.${item+'$NOT'}}-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$LIKE']!=null">-->
-                <!--AND ${$tableName}.${item} like #{term.${item+'$LIKE'}}-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$NOTLIKE']!=null">-->
-                <!--AND  ${$tableName}.${item} not like #{term.${item+'$LIKE'}}-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$IN']!=null">-->
-                <!--AND `${$tableName}`.`${item}` IN-->
-                <!--<foreach item="it" index="i" collection="#this['term.'+item+'$IN']" open="(" separator="," close=")">-->
-                    <!--#{it}-->
-                <!--</foreach>-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$NOTIN']!=null">-->
-                <!--AND `${$tableName}`.`${item}` NOT IN-->
-                <!--<foreach item="it" index="i" collection="#this['term.'+item+'$NOTIN']" open="(" separator="," close=")">-->
-                    <!--#{it}-->
-                <!--</foreach>-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$ISNULL']!=null">-->
-                <!--AND `${$tableName}`.`${item}` IS NULL-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$NOTNULL']!=null">-->
-                <!--AND `${$tableName}`.`${item}` IS NOT NULL-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$GT']!=null">-->
-                <!--AND `${$tableName}`.`${item}` &gt;=#{term.${item+'$GT'}}-->
-            <!--</if>-->
-            <!--<if test="#this['term.'+item+'$LT']!=null">-->
-                <!--AND `${$tableName}`.`${item}` &lt;=#{term.${item+'$LT'}}-->
-            <!--</if>-->
-        <!--</foreach>-->
-        <!--动态生成查询条件结束-->
-    </sql>
-    <!--生成查询字段-->
-    <sql id="buildSelectField">
-        <bind name="fieldHasLen" value="false"/>
-        <choose>
-            <!--指定查询的字段-->
-            <when test="includes!=null and includes.size()>0">
-                <foreach item="item" index="index" collection="includes" open="" separator="," close="">
-                    <if test="item in $fields">
-                        <bind name="fieldHasLen" value="true"/>
-                        ${$tableName}.${item} as `${item}`
-                    </if>
-                </foreach>
-            </when>
-            <!--指定不查询的字段-->
-            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
-                    <if test="!(item in excludes)">
-                        <bind name="fieldHasLen" value="true"/>
-                        ${$tableName}.${item} as `${item}`
-                    </if>
-                </foreach>
-            </when>
-            <otherwise> <bind name="fieldHasLen" value="true"/>*</otherwise>
-        </choose>
-        <if test="!fieldHasLen">*</if>
-    </sql>
-
-    <!--生成修改字段-->
-    <sql id="buildUpdateField">
-        <set>
-            <choose>
-                <!--指定要修改的字段-->
-                <when test="includes!=null and includes.size()>0">
-                    <foreach item="item" index="index" collection="includes" open="" separator="," close="">
-                        <if test="item in $fields">
-                            `${item}`=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                        </if>
-                    </foreach>
-                </when>
-                <!--指定不修改的字段-->
-                <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                    <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
-                        <if test="!(item in excludes)">
-                            `${item}`= #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                        </if>
-                    </foreach>
-                </when>
-                <!--修改所有-->
-                <otherwise>
-                    <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
-                        <if test="data[item] != null">
-                            `${item}`=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                        </if>
-                    </foreach>
-                </otherwise>
-            </choose>
-        </set>
-    </sql>
-
-    <!--生成插入字段-->
-    <sql id="buildInsertField">
-        <choose>
-            <when test="includes!=null and includes.size()>0">
-                <foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
-                    <if test="item in $fields">`${item}`</if>
-                </foreach>
-            </when>
-            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
-                    <if test="!(item in excludes)">`${item}`</if>
-                </foreach>
-            </when>
-            <otherwise>
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">`${item}`</foreach>
-            </otherwise>
-        </choose>
-    </sql>
-
-    <!--生成插入值-->
-    <sql id="buildInsertValues">
-        <choose>
-            <when test="includes!=null and includes.size()>0">
-                <foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
-                    <if test="item in $fields">
-                        #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                    </if>
-                </foreach>
-            </when>
-            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
-                    <if test="!(item in excludes)">
-                        #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                    </if>
-                </foreach>
-            </when>
-            <otherwise>
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
-                    #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                </foreach>
-            </otherwise>
-        </choose>
-    </sql>
-
-    <!--生成排序字段-->
-    <sql id="buildSortField">
-        <bind name="fieldHasLen" value="false"/>
-        <choose>
-            <!--指定排序的字段-->
-            <when test="sortField!=null and sortField.size()>0">
-                <foreach item="item" index="index" collection="sortField" open="" separator="," close="">
-                    <if test="item in $fields">
-                        <if test="!fieldHasLen"> order by </if>${$tableName}.${item}
-                        <bind name="fieldHasLen" value="true"/>
-                    </if>
-                </foreach>
-                <if test="fieldHasLen"> ${sortOrder}</if>
-            </when>
-        </choose>
-    </sql>
-
-    <!--生成查询sql-->
-    <sql id="buildSelectSql">
-        select
-        <include refid="BasicMapper.buildSelectField"/>
-        from ${$tableName}
-        <where>
-            <include refid="BasicMapper.buildWhereV2"/>
-            <!--<include refid="BasicMapper.buildWhere"/>-->
-        </where>
-        <include refid="BasicMapper.buildSortField"/>
-    </sql>
-
-    <!--生成InsertSql-->
-    <sql id="buildInsertSql">
-        insert into ${$tableName}
-        <include refid="BasicMapper.buildInsertField"/>
-        values
-        <include refid="BasicMapper.buildInsertValues"/>
-    </sql>
-
-    <!--生成UpdateSql-->
-    <sql id="buildUpdateSql">
-        update ${$tableName}
-        <include refid="BasicMapper.buildUpdateField"/>
-        <where>
-            <include refid="BasicMapper.buildWhereV2"/>
-            <!--<include refid="BasicMapper.buildWhere"/>-->
-            <if test="term.size()==0">
-                u_id=#{data.u_id}
-            </if>
-        </where>
-    </sql>
-
-    <!--生成查询数量sql-->
-    <sql id="buildTotalSql">
-        select count(0) as "total" from ${$tableName}
-        <where>
-            <include refid="BasicMapper.buildWhereV2"/>
-            <!--<include refid="BasicMapper.buildWhere"/>-->
-        </where>
-    </sql>
-</mapper>

+ 0 - 93
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/form/FormMapper.xml

@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.form.FormMapper">
-    <resultMap id="FormResultMap" type="org.hsweb.web.bean.po.form.Form">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="html" column="html" javaType="String" jdbcType="VARCHAR"/>
-        <result property="meta" column="meta" javaType="String" jdbcType="VARCHAR"/>
-        <result property="config" column="config" javaType="String" jdbcType="VARCHAR"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="version" column="version" javaType="int" jdbcType="INTEGER"/>
-        <result property="revision" column="revision" javaType="int" jdbcType="INTEGER"/>
-        <result property="release" column="release" javaType="int" jdbcType="INTEGER"/>
-        <result property="using" column="using" javaType="boolean" jdbcType="INTEGER"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="updateDate" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="classifiedId" column="classified_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'FormResultMap'"/>
-        <bind name="tableName" value="'s_form'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="FormResultMap">
-        select * from s_form WHERE u_id=#{id}
-    </select>
-
-    <select id="selectUsing" parameterType="string" resultMap="FormResultMap">
-        select * from s_form WHERE `using`=1 and `name`=#{name}
-    </select>
-
-    <select id="selectLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">
-        <include refid="config"/>
-        <!--定义字段配置-->
-        <bind name="tableName" value="'t2'"/>
-        <!--定义表名-->
-        select
-        <!--动态生成要查询的字段-->
-        <include refid="BasicMapper.buildSelectField"/>
-        from (
-        select s_form.name,max(s_form.version) as version from s_form s_form
-        <bind name="tableName" value="'s_form'"/>
-        <where>
-            <!--动态查询条件-->
-            <include refid="BasicMapper.buildWhere"/>
-        </where>
-        group by name) t1
-        left join s_form t2 on t1.name=t2.name and t1.version =t2.version
-        <bind name="tableName" value="'t2'"/>
-        <include refid="BasicMapper.buildSortField"/>
-    </select>
-
-    <select id="countLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        select count(0) as total from (
-        select s_form.name,max(s_form.version) as version from s_form s_form
-        <where>
-            <include refid="BasicMapper.buildWhere"/>
-        </where>
-        group by name) t1
-        left join s_form t2 on t1.name=t2.name and t1.version =t2.version
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 53
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/module/ModuleMapper.xml

@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.module.ModuleMapper">
-    <resultMap id="ModuleResultMap" type="org.hsweb.web.bean.po.module.Module">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="uri" column="uri" javaType="String" jdbcType="VARCHAR"/>
-        <result property="icon" column="icon" javaType="String" jdbcType="VARCHAR"/>
-        <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
-        <result property="optional" column="optional" javaType="String" jdbcType="VARCHAR"/>
-        <result property="sortIndex" column="sort_index" javaType="long" jdbcType="INTEGER"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'ModuleResultMap'"/>
-        <bind name="tableName" value="'s_modules'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="ModuleResultMap">
-        select * from s_modules WHERE u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ModuleResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 62
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/user/UserMapper.xml

@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.user.UserMapper">
-    <resultMap id="UserResultMap" type="org.hsweb.web.bean.po.user.User">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="username" column="username" javaType="String" jdbcType="VARCHAR"/>
-        <result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="email" column="email" javaType="String" jdbcType="VARCHAR"/>
-        <result property="phone" column="phone" javaType="String" jdbcType="VARCHAR"/>
-        <result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="updateDate" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <collection property="userRoles" column="u_id" ofType="UserRole"
-                    select="org.hsweb.web.dao.role.UserRoleMapper.selectByUserId"/>
-    </resultMap>
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'UserResultMap'"/>
-        <bind name="tableName" value="'s_user'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="updatePassword" parameterType="org.hsweb.web.bean.po.user.User">
-        update s_user set password=#{password,jdbcType=VARCHAR} where u_id = #{id}
-    </update>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByUserName" parameterType="string" resultMap="UserResultMap">
-        select * from s_user where username=#{username}
-    </select>
-
-    <select id="selectByPk" parameterType="string" resultMap="UserResultMap">
-        select * from s_user where u_id=#{u_id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 245
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/basic/BasicMapper.xml.old

@@ -1,245 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="BasicMapper">
-    <sql id="buildWhereV2">
-        ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildWhere($fieldsInfo,#this['_parameter'].terms)}
-    </sql>
-    <sql id="buildSelectFieldV2">
-        ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildSelectFields($fieldsInfo,#this['_parameter'])}
-    </sql>
-    <!--通用查询条件-->
-    <sql id="buildWhere">
-        <include refid="BasicMapper.buildWhereV2"/>
-        <!--动态生成查询条件-->
-        <!--<foreach item="item" index="index" collection="$fields">-->
-        <!--<if test="#this['term.'+item]!=null">-->
-        <!--<choose>-->
-        <!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
-        <!--AND ${$tableName}.${item}=to_date(#{term.${item}},'YYYY-MM-DD HH24:MI:SS')-->
-        <!--</when>-->
-        <!--<otherwise>AND ${$tableName}.${item}=#{term.${item}}</otherwise>-->
-        <!--</choose>-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$NOT']!=null">-->
-        <!--<choose>-->
-        <!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
-        <!--AND ${$tableName}.${item}!=to_date(#{term.${item+'$NOT'}},'YYYY-MM-DD HH24:MI:SS')-->
-        <!--</when>-->
-        <!--<otherwise>AND ${$tableName}.${item}!=#{term.${item+'$NOT'}}</otherwise>-->
-        <!--</choose>-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$LIKE']!=null">-->
-        <!--AND ${$tableName}.${item} like #{term.${item+'$LIKE'}}-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$NOTLIKE']!=null">-->
-        <!--AND ${$tableName}.${item} not like #{term.${item+'$LIKE'}}-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$IN']!=null">-->
-        <!--AND ${$tableName}.${item} IN-->
-        <!--<foreach item="it" index="i" collection="#this['term.'+item+'$IN']" open="(" separator="," close=")">-->
-        <!--#{it}-->
-        <!--</foreach>-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$NOTIN']!=null">-->
-        <!--AND ${$tableName}.${item} NOT IN-->
-        <!--<foreach item="it" index="i" collection="#this['term.'+item+'$NOTIN']" open="(" separator="," close=")">-->
-        <!--#{it}-->
-        <!--</foreach>-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$ISNULL']!=null">-->
-        <!--AND ${$tableName}.${item} IS NULL-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$NOTNULL']!=null">-->
-        <!--AND ${$tableName}.${item} IS NOT NULL-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$GT']!=null">-->
-        <!--<choose>-->
-        <!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
-        <!--AND ${$tableName}.${item} &gt;=to_date(#{term.${item+'$GT'}},'YYYY-MM-DD HH24:MI:SS')-->
-        <!--</when>-->
-        <!--<when test="$fieldsInfo[item]['javaType'] == 'number' ">-->
-        <!--AND ${$tableName}.${item} &gt;=#{term.${item+'$GT'}}-->
-        <!--</when>-->
-        <!--<otherwise></otherwise>-->
-        <!--</choose>-->
-        <!--</if>-->
-        <!--<if test="#this['term.'+item+'$LT']!=null">-->
-        <!--<choose>-->
-        <!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
-        <!--AND ${$tableName}.${item} &lt;=to_date(#{term.${item+'$LT'}},'YYYY-MM-DD HH24:MI:SS')-->
-        <!--</when>-->
-        <!--<when test="$fieldsInfo[item]['javaType'] == 'number' ">-->
-        <!--AND ${$tableName}.${item} &lt;=#{term.${item+'$LT'}}-->
-        <!--</when>-->
-        <!--<otherwise></otherwise>-->
-        <!--</choose>-->
-        <!--</if>-->
-        <!--</foreach>-->
-        <!--动态生成查询条件结束-->
-    </sql>
-    <!--生成查询字段-->
-    <sql id="buildSelectField">
-        <include refid="BasicMapper.buildSelectFieldV2"/>
-        <!--<bind name="fieldHasLen" value="false"/>-->
-        <!--<choose>-->
-        <!--&lt;!&ndash;指定查询的字段&ndash;&gt;-->
-        <!--<when test="includes!=null and includes.size()>0">-->
-        <!--<foreach item="item" index="index" collection="includes" open="" separator="," close="">-->
-        <!--<if test="item in $fields">-->
-        <!--<bind name="fieldHasLen" value="true"/>-->
-        <!--${$tableName}.${item} as "${item}"-->
-        <!--</if>-->
-        <!--</foreach>-->
-        <!--</when>-->
-        <!--&lt;!&ndash;指定不查询的字段&ndash;&gt;-->
-        <!--<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">-->
-        <!--<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">-->
-        <!--<if test="!(item in excludes)">-->
-        <!--<bind name="fieldHasLen" value="true"/>-->
-        <!--${$tableName}.${item} as "${item}"-->
-        <!--</if>-->
-        <!--</foreach>-->
-        <!--</when>-->
-        <!--<otherwise><bind name="fieldHasLen" value="true"/>*-->
-        <!--</otherwise>-->
-        <!--</choose>-->
-        <!--<if test="!fieldHasLen">*</if>-->
-    </sql>
-
-    <!--生成修改字段-->
-    <sql id="buildUpdateField">
-        <set>
-            <choose>
-                <!--指定要修改的字段-->
-                <when test="includes!=null and includes.size()>0">
-                    <foreach item="item" index="index" collection="includes" open="" separator="," close="">
-                        <if test="item in $fields">
-                            ${item}=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                        </if>
-                    </foreach>
-                </when>
-                <!--指定不修改的字段-->
-                <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                    <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
-                        <if test="!(item in excludes)">
-                            ${item}= #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                        </if>
-                    </foreach>
-                </when>
-                <!--修改所有-->
-                <otherwise>
-                    <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
-                        <if test="data[item] != null">
-                            ${item}=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                        </if>
-                    </foreach>
-                </otherwise>
-            </choose>
-        </set>
-    </sql>
-
-    <!--生成插入字段-->
-    <sql id="buildInsertField">
-        <choose>
-            <when test="includes!=null and includes.size()>0">
-                <foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
-                    <if test="item in $fields">${item}</if>
-                </foreach>
-            </when>
-            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
-                    <if test="!(item in excludes)">${item}</if>
-                </foreach>
-            </when>
-            <otherwise>
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">${item}</foreach>
-            </otherwise>
-        </choose>
-    </sql>
-
-    <!--生成插入值-->
-    <sql id="buildInsertValues">
-        <choose>
-            <when test="includes!=null and includes.size()>0">
-                <foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
-                    <if test="item in $fields">
-                        #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                    </if>
-                </foreach>
-            </when>
-            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
-                    <if test="!(item in excludes)">
-                        #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                    </if>
-                </foreach>
-            </when>
-            <otherwise>
-                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
-                    #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
-                </foreach>
-            </otherwise>
-        </choose>
-    </sql>
-
-    <!--生成排序字段-->
-    <sql id="buildSortField">
-        <bind name="fieldHasLen" value="false"/>
-        <choose>
-            <!--指定排序的字段-->
-            <when test="sortField!=null and sortField.size()>0">
-                <foreach item="item" index="index" collection="sortField" open="" separator="," close="">
-                    <if test="item in $fields">
-                        <if test="!fieldHasLen">order by</if>${$tableName}.${item}
-                        <bind name="fieldHasLen" value="true"/>
-                    </if>
-                </foreach>
-                <if test="fieldHasLen">${sortOrder}</if>
-            </when>
-        </choose>
-    </sql>
-
-    <!--生成查询sql-->
-    <sql id="buildSelectSql">
-        select
-        <include refid="BasicMapper.buildSelectField"/>
-        from ${$tableName}
-        <where>
-            <include refid="BasicMapper.buildWhereV2"/>
-            <!--<include refid="BasicMapper.buildWhere"/>-->
-        </where>
-        <include refid="BasicMapper.buildSortField"/>
-    </sql>
-
-    <!--生成InsertSql-->
-    <sql id="buildInsertSql">
-        insert into ${$tableName}
-        <include refid="BasicMapper.buildInsertField"/>
-        values
-        <include refid="BasicMapper.buildInsertValues"/>
-    </sql>
-
-    <!--生成UpdateSql-->
-    <sql id="buildUpdateSql">
-        update ${$tableName}
-        <include refid="BasicMapper.buildUpdateField"/>
-        <where>
-            <include refid="BasicMapper.buildWhereV2"/>
-            <!--<include refid="BasicMapper.buildWhere"/>-->
-            <if test="terms.size()==0">
-                u_id=#{data.u_id}
-            </if>
-        </where>
-    </sql>
-
-    <!--生成查询数量sql-->
-    <sql id="buildTotalSql">
-        select count(0) as "total" from ${$tableName}
-        <where>
-            <include refid="BasicMapper.buildWhereV2"/>
-            <!--<include refid="BasicMapper.buildWhere"/>-->
-        </where>
-    </sql>
-</mapper>

+ 0 - 52
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/classified/ClassifiedMapper.xml

@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.classified.ClassifiedMapper">
-    <resultMap id="ClassifiedResultMap" type="org.hsweb.web.bean.po.classified.Classified">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-            <result property="name" column="name" javaType="java.lang.String" jdbcType="VARCHAR"/>
-            <result property="remark" column="remark" javaType="java.lang.String" jdbcType="VARCHAR"/>
-            <result property="type" column="type" javaType="java.lang.String" jdbcType="VARCHAR"/>
-            <result property="parentId" column="parent_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
-            <result property="icon" column="icon" javaType="java.lang.String" jdbcType="VARCHAR"/>
-            <result property="config" column="config" javaType="java.lang.String" jdbcType="CLOB"/>
-            <result property="sortIndex" column="sort_index" javaType="int" jdbcType="INTEGER"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'ClassifiedResultMap'"/>
-        <bind name="tableName" value="'s_classified'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="ClassifiedResultMap">
-        select * from s_classified where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ClassifiedResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 49
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/config/ConfigMapper.xml

@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.config.ConfigMapper">
-    <resultMap id="ConfigResultMap" type="org.hsweb.web.bean.po.config.Config">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="content" column="content" javaType="String" jdbcType="VARCHAR"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="classifiedId" column="classified_id" javaType="String" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'ConfigResultMap'"/>
-        <bind name="tableName" value="'s_config'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="ConfigResultMap">
-        select * from s_config where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ConfigResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 52
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/datasource/DataSourceMapper.xml

@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.dao.datasource.DataSourceMapper">
-    <resultMap id="DataSourceResultMap" type="org.hsweb.web.bean.po.datasource.DataSource">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="driver" column="driver" javaType="String" jdbcType="VARCHAR"/>
-        <result property="url" column="url" javaType="String" jdbcType="VARCHAR"/>
-        <result property="username" column="username" javaType="String" jdbcType="VARCHAR"/>
-        <result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
-        <result property="testSql" column="test_sql" javaType="String" jdbcType="VARCHAR"/>
-        <result property="enabled" column="enabled" javaType="int" jdbcType="NUMERIC"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="properties" column="properties" javaType="java.util.Map" jdbcType="CLOB"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'DataSourceResultMap'"/>
-        <bind name="tableName" value="'s_data_source'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="DataSourceResultMap">
-        select * from s_data_source where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="DataSourceResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 53
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/history/HistoryMapper.xml

@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.history.HistoryMapper">
-    <resultMap id="HistoryResultMap" type="org.hsweb.web.bean.po.history.History">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
-        <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
-        <result property="primaryKeyName" column="primary_key_name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="primaryKeyValue" column="primary_key_value" javaType="String" jdbcType="VARCHAR"/>
-        <result property="changeBefore" column="change_before" javaType="String" jdbcType="VARCHAR"/>
-        <result property="changeAfter" column="change_after" javaType="String" jdbcType="INTEGER"/>
-        <result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'HistoryResultMap'"/>
-        <bind name="tableName" value="'s_history'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="HistoryResultMap">
-        select * from s_history WHERE u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="HistoryResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 51
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/module/ModuleMetaMapper.xml

@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.module.ModuleMetaMapper">
-    <resultMap id="ModuleMetaResultMap" type="org.hsweb.web.bean.po.module.ModuleMeta">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="key" column="key" javaType="String" jdbcType="VARCHAR"/>
-        <result property="moduleId" column="module_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="roleId" column="role_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="meta" column="meta" javaType="String" jdbcType="CLOB"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'ModuleMetaResultMap'"/>
-        <bind name="tableName" value="'s_module_meta'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="ModuleMetaResultMap">
-        select * from s_module_meta WHERE u_id=#{u_id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ModuleMetaResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 65
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/plan/QueryPlanMapper.xml

@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Copyright 2015-2016 http://hsweb.me
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.dao.plan.QueryPlanMapper">
-    <resultMap id="QueryPlanResultMap" type="org.hsweb.web.bean.po.plan.QueryPlan">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
-        <result property="config" column="config" javaType="String" jdbcType="CLOB"/>
-        <result property="sharing" column="sharing" javaType="boolean" jdbcType="INTEGER"/>
-        <result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'QueryPlanResultMap'"/>
-        <bind name="tableName" value="'s_query_plan'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="QueryPlanResultMap">
-        select * from s_query_plan where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="QueryPlanResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 48
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/profile/UserProfileMapper.xml

@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.profile.UserProfileMapper">
-    <resultMap id="UserProfileResultMap" type="org.hsweb.web.bean.po.profile.UserProfile">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
-        <result property="userId" column="user_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="content" column="content" javaType="String" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'UserProfileResultMap'"/>
-        <bind name="tableName" value="'s_user_profile'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="UserProfileResultMap">
-        select * from s_user_profile where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserProfileResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 63
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/quartz/QuartzJobHistoryMapper.xml

@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Copyright 2015-2016 http://hsweb.me
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.dao.quartz.QuartzJobHistoryMapper">
-    <resultMap id="QuartzJobHistoryResultMap" type="org.hsweb.web.bean.po.quartz.QuartzJobHistory">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="jobId" column="job_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="startTime" column="start_time" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="endTime" column="end_time" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-        <result property="result" column="result" javaType="String" jdbcType="CLOB"/>
-        <result property="status" column="status" javaType="byte" jdbcType="NUMERIC"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'QuartzJobHistoryResultMap'"/>
-        <bind name="tableName" value="'S_QUARTZ_JOB_HIS'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="QuartzJobHistoryResultMap">
-        select * from S_QUARTZ_JOB_HIS where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="QuartzJobHistoryResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 67
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/quartz/QuartzJobMapper.xml

@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Copyright 2015-2016 http://hsweb.me
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.dao.quartz.QuartzJobMapper">
-    <resultMap id="QuartzJobResultMap" type="org.hsweb.web.bean.po.quartz.QuartzJob">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="cron" column="cron" javaType="String" jdbcType="VARCHAR"/>
-        <result property="script" column="script" javaType="String" jdbcType="CLOB"/>
-        <result property="language" column="language" javaType="String" jdbcType="VARCHAR"/>
-        <result property="enabled" column="enabled" javaType="boolean" jdbcType="NUMERIC"/>
-        <result property="parameters" column="parameters" javaType="String" jdbcType="CLOB"/>
-        <result property="type" column="type" javaType="byte" jdbcType="NUMERIC"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'QuartzJobResultMap'"/>
-        <bind name="tableName" value="'S_QUARTZ_JOB'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="QuartzJobResultMap">
-        select * from S_QUARTZ_JOB where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="QuartzJobResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 53
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/resource/ResourcesMapper.xml

@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.resource.ResourcesMapper">
-    <resultMap id="ResourcesResultMap" type="org.hsweb.web.bean.po.resource.Resources" >
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR" />
-        <result property="path" column="path" javaType="String" jdbcType="VARCHAR" />
-        <result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR" />
-        <result property="md5" column="md5" javaType="String" jdbcType="VARCHAR" />
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR" />
-        <result property="size" column="size" javaType="long" jdbcType="NUMERIC" />
-        <result property="status" column="status" javaType="int" jdbcType="INTEGER" />
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP" />
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'ResourcesResultMap'"/>
-        <bind name="tableName" value="'s_resources'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="ResourcesResultMap">
-        select * from s_resources WHERE u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ResourcesResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 48
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/role/RoleMapper.xml

@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.dao.role.RoleMapper">
-    <resultMap id="RoleResultMap" type="org.hsweb.web.bean.po.role.Role">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
-        <collection property="modules" column="u_id" ofType="RoleModule"
-                    select="org.hsweb.web.dao.role.RoleModuleMapper.selectByRoleId"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'RoleResultMap'"/>
-        <bind name="tableName" value="'s_role'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="RoleResultMap">
-        select * from s_role where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="RoleResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 62
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/role/RoleModuleMapper.xml

@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.role.RoleModuleMapper">
-    <resultMap id="RoleModuleResultMap" type="org.hsweb.web.bean.po.role.RoleModule" >
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="moduleId" column="module_id" javaType="String" jdbcType="VARCHAR" />
-        <result property="roleId" column="role_id" javaType="String" jdbcType="VARCHAR" />
-        <result property="actions" column="actions" javaType="java.util.List" jdbcType="VARCHAR"
-                typeHandler="org.hsweb.web.mybatis.handler.JsonArrayHandler" />
-        <collection property="module" column="module_id" ofType="Module" select="org.hsweb.web.dao.module.ModuleMapper.selectByPk"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'RoleModuleResultMap'"/>
-        <bind name="tableName" value="'s_role_modules'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <delete id="deleteByRoleId" parameterType="string" >
-        delete from s_role_modules where role_id=#{role_id}
-    </delete>
-
-    <delete id="deleteByModuleId" parameterType="string" >
-        delete from s_role_modules where module_id=#{module_id}
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByRoleId" parameterType="string" resultMap="RoleModuleResultMap">
-        select * from s_role_modules where role_id=#{role_id}
-    </select>
-
-    <select id="selectByPk" parameterType="string" resultMap="RoleModuleResultMap">
-        select * from s_role_modules where u_id=#{u_id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="RoleModuleResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 57
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/role/UserRoleMapper.xml

@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.role.UserRoleMapper">
-    <resultMap id="UserRoleResultMap" type="org.hsweb.web.bean.po.role.UserRole">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="userId" column="user_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="roleId" column="role_id" javaType="String" jdbcType="VARCHAR"/>
-        <collection property="role" column="role_id" jdbcType="VARCHAR" ofType="Role"
-                    select="org.hsweb.web.dao.role.RoleMapper.selectByPk"></collection>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'UserRoleResultMap'"/>
-        <bind name="tableName" value="'s_user_role'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <delete id="deleteByUserId" parameterType="String">
-        delete from s_user_role where user_id=#{userId}
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByUserId" parameterType="string" resultMap="UserRoleResultMap">
-        select * from s_user_role where user_id=#{user_id}
-    </select>
-
-    <select id="selectByPk" parameterType="string" resultMap="UserRoleResultMap">
-        select * from s_user_role where u_id=#{u_id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserRoleResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 52
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/script/DynamicScriptMapper.xml

@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.script.DynamicScriptMapper">
-    <resultMap id="DynamicScriptResultMap" type="org.hsweb.web.bean.po.script.DynamicScript" >
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR" />
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR" />
-        <result property="content" column="content" javaType="String" jdbcType="VARCHAR" />
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR" />
-        <result property="classifiedId" column="classified_id" javaType="String" jdbcType="VARCHAR" />
-        <result property="status" column="status" javaType="int" jdbcType="INTEGER" />
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'DynamicScriptResultMap'"/>
-        <bind name="tableName" value="'s_script'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="DynamicScriptResultMap">
-        select * from s_script where u_id=#{u_id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="DynamicScriptResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 97
hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/template/TemplateMapper.xml

@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.hsweb.web.dao.template.TemplateMapper">
-    <resultMap id="TemplateResultMap" type="org.hsweb.web.bean.po.template.Template">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
-        <result property="template" column="template" javaType="String" jdbcType="CLOB"/>
-        <result property="classifiedId" column="classified_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
-        <result property="script" column="script" javaType="String" jdbcType="CLOB"/>
-        <result property="css" column="css" javaType="String" jdbcType="CLOB"/>
-        <result property="cssLinks" column="css_links" javaType="java.util.List" jdbcType="CLOB"
-                typeHandler="org.hsweb.web.mybatis.handler.JsonArrayHandler"/>
-        <result property="scriptLinks" column="script_links" javaType="java.util.List" jdbcType="CLOB"
-                typeHandler="org.hsweb.web.mybatis.handler.JsonArrayHandler"/>
-        <result property="version" column="version" javaType="int" jdbcType="INTEGER"/>
-        <result property="revision" column="revision" javaType="int" jdbcType="INTEGER"/>
-        <result property="release" column="release" javaType="int" jdbcType="INTEGER"/>
-        <result property="using" column="using" javaType="boolean" jdbcType="INTEGER"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'TemplateResultMap'"/>
-        <bind name="tableName" value="'s_template'"/>
-    </sql>
-
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="TemplateResultMap">
-        select * from s_template WHERE u_id=#{id}
-    </select>
-
-    <select id="selectUsing" parameterType="string" resultMap="TemplateResultMap">
-        select * from s_template WHERE using=1 and name=#{name}
-    </select>
-
-    <select id="selectLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="TemplateResultMap">
-        <include refid="config"/>
-        <!--定义字段配置-->
-        <bind name="tableName" value="'t2'"/>
-        <!--定义表名-->
-        select
-        <!--动态生成要查询的字段-->
-        <include refid="BasicMapper.buildSelectField"/>
-        from (
-        select s_template.name,max(s_template.version) as version from s_template s_template
-        <where>
-            <!--动态查询条件-->
-            <include refid="BasicMapper.buildWhere"/>
-        </where>
-        group by name) t1
-        left join s_template t2 on t1.name=t2.name and t1.version =t2.version
-        <bind name="tableName" value="'t2'"/>
-        <include refid="BasicMapper.buildSortField"/>
-    </select>
-
-    <select id="countLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        select count(0) as total from (
-        select s_template.name,max(s_form.version) as version from s_template s_template
-        <where>
-            <include refid="BasicMapper.buildWhere"/>
-        </where>
-        group by name) t1
-        left join s_template t2 on t1.name=t2.name and t1.version =t2.version
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="TemplateResultMap">
-        <include refid="config"/>
-
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/plan/QueryPlanMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/plan/QueryPlanMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/profile/UserProfileMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/profile/UserProfileMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/quartz/QuartzJobHistoryMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/quartz/QuartzJobHistoryMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/quartz/QuartzJobMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/quartz/QuartzJobMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/resource/ResourcesMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/resource/ResourcesMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/role/RoleMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/role/RoleMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/role/RoleModuleMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/role/RoleModuleMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/role/UserRoleMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/role/UserRoleMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/script/DynamicScriptMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/script/DynamicScriptMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/template/TemplateMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/template/TemplateMapper.xml


hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/user/UserMapper.xml → hsweb-web-dao/hsweb-web-dao-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/user/UserMapper.xml


+ 29 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/java/org/hsweb/web/mybatis/AbstractTestCase.java

@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.mybatis;
+
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Created by zhouhao on 16-4-20.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SpringApplication.class)
+public abstract class AbstractTestCase {
+}

+ 64 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/java/org/hsweb/web/mybatis/SpringApplication.java

@@ -0,0 +1,64 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.mybatis;
+
+import org.hsweb.ezorm.executor.AbstractJdbcSqlExecutor;
+import org.hsweb.ezorm.executor.SqlExecutor;
+import org.hsweb.web.core.datasource.DataSourceHolder;
+import org.hsweb.web.core.datasource.DatabaseType;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Created by zhouhao on 16-4-20.
+ */
+@Configuration
+@EnableAutoConfiguration
+@ComponentScan("org.hsweb.web")
+@MapperScan("org.hsweb.web.dao")
+public class SpringApplication {
+
+    @Bean
+    public SqlExecutor sqlExecutor(DataSource dataSource) throws SQLException {
+        Connection connection = dataSource.getConnection();
+        try {
+            DataSourceHolder.install(dataSource, DatabaseType.fromJdbcUrl(connection.getMetaData().getURL()));
+        } finally {
+            connection.close();
+        }
+        return new AbstractJdbcSqlExecutor() {
+            @Override
+            public Connection getConnection() {
+                return DataSourceUtils.getConnection(dataSource);
+            }
+
+            @Override
+            public void releaseConnection(Connection connection) throws SQLException {
+                DataSourceUtils.releaseConnection(connection, dataSource);
+            }
+        };
+    }
+}

+ 53 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/java/org/hsweb/web/mybatis/user/UserMapperTest.java

@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.mybatis.user;
+
+import org.hsweb.web.bean.common.InsertParam;
+import org.hsweb.web.bean.common.QueryParam;
+import org.hsweb.web.bean.po.user.User;
+import org.hsweb.web.dao.user.UserMapper;
+import org.hsweb.web.mybatis.AbstractTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+
+/**
+ * @author zhouhao
+ */
+public class UserMapperTest extends AbstractTestCase {
+
+    @Autowired
+    private UserMapper userMapper;
+
+    @Test
+    public void testInsert() {
+        User user = new User();
+        user.setId("test");
+        user.setUsername("admin");
+        user.setName("test");
+        user.setCreateDate(new Date());
+        int i = userMapper.insert(InsertParam.build(user));
+        Assert.assertEquals(i, 1);
+    }
+
+    @Test
+    public void testQuery() {
+        userMapper.select(QueryParam.build());
+    }
+}

+ 10 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/application.yml

@@ -0,0 +1,10 @@
+logging:
+    config: classpath:logback.xml
+spring:
+    aop:
+        auto: true
+    redis:
+        host: 127.0.0.1
+        port: 6379
+mybatis:
+    config: classpath:mybatis-config.xml

+ 19 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/logback.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <!-- 控制台输出日志 -->
+    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} > %-5level %logger{35} - %m%n</pattern>
+        </encoder>
+    </appender>
+    <logger name="org.springframework" level="ERROR" />
+    <logger name="org.apache.tomcat" level="ERROR" />
+    <logger name="org.hsweb" level="DEBUG" />
+    <logger name="com.atomikos" level="ERROR" />
+    <logger name="org.h2" level="ON" />
+    <logger name="org.mybatis.spring.SqlSessionUtils" level="DEBUG" />
+    <logger name="org.hsweb.web.datasource" level="INFO" />
+    <root level="ERROR">
+        <appender-ref ref="Console"/>
+    </root>
+</configuration>

+ 56 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/mybatis-config.xml

@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <!-- 配置mybatis的缓存,延迟加载等等一系列属性 -->
+    <settings>
+        <!-- 全局映射器启用缓存 -->
+        <setting name="cacheEnabled" value="true"/>
+
+        <!-- 查询时,关闭关联对象即时加载以提高性能 -->
+        <setting name="lazyLoadingEnabled" value="true"/>
+
+        <!-- 对于未知的SQL查询,允许返回不同的结果集以达到通用的效果 -->
+        <setting name="multipleResultSetsEnabled" value="true"/>
+
+        <!-- 允许使用列标签代替列名 -->
+        <setting name="useColumnLabel" value="true"/>
+
+        <!-- 不允许使用自定义的主键值(比如由程序生成的UUID 32位编码作为键值),数据表的PK生成策略将被覆盖 -->
+        <setting name="useGeneratedKeys" value="false"/>
+
+        <!-- 给予被嵌套的resultMap以字段-属性的映射支持 FULL,PARTIAL -->
+        <setting name="autoMappingBehavior" value="PARTIAL"/>
+
+        <!-- 对于批量更新操作缓存SQL以提高性能 BATCH,SIMPLE -->
+        <!-- <setting name="defaultExecutorType" value="BATCH" /> -->
+
+        <!-- 数据库超过25000秒仍未响应则超时 -->
+        <!-- <setting name="defaultStatementTimeout" value="25000" /> -->
+
+        <!-- Allows using RowBounds on nested statements -->
+        <setting name="safeRowBoundsEnabled" value="false"/>
+
+        <!-- Enables automatic mapping from classic database column names A_COLUMN to camel case classic Java property names aColumn. -->
+        <setting name="mapUnderscoreToCamelCase" value="true"/>
+
+        <!-- MyBatis uses local cache to prevent circular references and speed up repeated nested queries. By default (SESSION) all queries executed during a session are cached. If localCacheScope=STATEMENT
+            local session will be used just for statement execution, no data will be shared between two different calls to the same SqlSession. -->
+        <setting name="localCacheScope" value="SESSION"/>
+
+        <!-- Specifies the JDBC type for null values when no specific JDBC type was provided for the parameter. Some drivers require specifying the column JDBC type but others work with generic values
+            like NULL, VARCHAR or OTHER. -->
+        <setting name="jdbcTypeForNull" value="OTHER"/>
+
+        <!-- Specifies which Object's methods trigger a lazy load -->
+        <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/>
+
+        <!-- 设置关联对象加载的形态,此处为按需加载字段(加载字段由SQL指 定),不会加载关联表的所有字段,以提高性能 -->
+        <setting name="aggressiveLazyLoading" value="false"/>
+        <setting name="proxyFactory" value="CGLIB"/>
+    </settings>
+    <typeHandlers>
+        <package name="org.hsweb.web.mybatis.handler"></package>
+    </typeHandlers>
+</configuration>

+ 19 - 0
hsweb-web-dao/hsweb-web-dao-mybatis/src/test/resources/transactions.properties

@@ -0,0 +1,19 @@
+#
+# Copyright 2015-2016 http://hsweb.me
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
+com.atomikos.icatch.serial_jta_transactions=false
+com.atomikos.icatch.output_dir=./data/atomikos
+com.atomikos.icatch.log_base_dir=./data/atomikos

+ 1 - 1
hsweb-web-dao/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <packaging>pom</packaging>

+ 1 - 1
hsweb-web-datasource/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 11 - 11
hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceAutoConfiguration.java

@@ -19,12 +19,13 @@ package org.hsweb.web.datasource.dynamic;
 import com.atomikos.icatch.jta.UserTransactionImp;
 import com.atomikos.icatch.jta.UserTransactionManager;
 import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.hsweb.web.core.datasource.DataSourceHolder;
 import org.hsweb.web.core.datasource.DynamicDataSource;
-import org.hsweb.web.core.datasource.DynamicDataSourceHolder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
@@ -36,31 +37,30 @@ import javax.transaction.SystemException;
 
 @Configuration
 @ConditionalOnMissingBean(DynamicDataSource.class)
+@EnableConfigurationProperties(DynamicDataSourceProperties.class)
 @ComponentScan("org.hsweb.web.datasource.dynamic")
 public class DynamicDataSourceAutoConfiguration {
 
     @Autowired
-    private DataSourceProperties properties;
+    private DynamicDataSourceProperties properties;
 
     /**
      * 默认数据库链接
      */
     @Primary
     @Bean(initMethod = "init", name = "dataSource", destroyMethod = "close")
+    @ConditionalOnMissingBean(DataSource.class)
+    @Cacheable
     public DataSource dataSource() {
         AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean();
-        dataSourceBean.getXaProperties().putAll(properties.getXa().getProperties());
-        dataSourceBean.setXaDataSourceClassName(properties.getXa().getDataSourceClassName());
-        dataSourceBean.setUniqueResourceName("core");
-        dataSourceBean.setMinPoolSize(5);
-        dataSourceBean.setMaxPoolSize(200);
+        properties.putProperties(dataSourceBean);
         return dataSourceBean;
     }
 
     @Bean(name = "dynamicDataSource")
     public DynamicXaDataSourceImpl dynamicXaDataSource(@Qualifier("dataSource") DataSource dataSource) {
-        DynamicXaDataSourceImpl dynamicXaDataSource = new DynamicXaDataSourceImpl(dataSource);
-        DynamicDataSourceHolder.install(dynamicXaDataSource);
+        DynamicXaDataSourceImpl dynamicXaDataSource = new DynamicXaDataSourceImpl(dataSource, properties.getType());
+        DataSourceHolder.install(dynamicXaDataSource);
         return dynamicXaDataSource;
     }
 
@@ -74,7 +74,7 @@ public class DynamicDataSourceAutoConfiguration {
     @Bean
     public UserTransactionImp userTransaction() throws SystemException {
         UserTransactionImp userTransactionImp = new UserTransactionImp();
-        userTransactionImp.setTransactionTimeout(300);
+        userTransactionImp.setTransactionTimeout(properties.getTransactionTimeout());
         return userTransactionImp;
     }
 

+ 303 - 0
hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceProperties.java

@@ -0,0 +1,303 @@
+/*
+ * Copyright 2015-2016 http://hsweb.me
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hsweb.web.datasource.dynamic;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.hsweb.web.core.datasource.DatabaseType;
+import org.springframework.beans.factory.BeanClassLoaderAware;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.StringUtils;
+
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * @author zhouhao
+ * @see com.atomikos.jdbc.AbstractDataSourceBean
+ * @since 2.1
+ */
+@ConfigurationProperties(prefix = "hsweb.dynamicDatasource")
+public class DynamicDataSourceProperties
+        implements BeanClassLoaderAware, InitializingBean {
+    private String                name                    = "core";
+    private DatabaseType          type                    = null;
+    private String                datasourceName          = null;
+    private String                username                = "sa";
+    private String                password                = "";
+    private String                url                     = "jdbc:h2:file:./data/h2db;DB_CLOSE_ON_EXIT=FALSE";
+    private String                testQuery               = null;
+    private int                   loginTimeout            = 0;
+    private int                   maxLifetime             = 0;
+    private int                   minPoolSize             = 3;
+    private int                   maxPoolSize             = 80;
+    private int                   borrowConnectionTimeout = 60;
+    private int                   reapTimeout             = 0;
+    private int                   maxIdleTime             = 60;
+    private int                   maintenanceInterval     = 60;
+    private int                   defaultIsolationLevel   = -1;
+    private int                   transactionTimeout      = 300;
+    private Properties            properties              = null;
+    private ClassLoader           classLoader             = null;
+    private DatasourceTypeSupport datasourceTypeSupport   = null;
+
+    public int getTransactionTimeout() {
+        return transactionTimeout;
+    }
+
+    public void setTransactionTimeout(int transactionTimeout) {
+        this.transactionTimeout = transactionTimeout;
+    }
+
+    public String getDatasourceName() {
+        return datasourceName;
+    }
+
+    public void setDatasourceName(String datasourceName) {
+        this.datasourceName = datasourceName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public DatabaseType getType() {
+        if (type == null) {
+            type = DatabaseType.fromJdbcUrl(getUrl());
+        }
+        return type;
+    }
+
+    public void setType(DatabaseType type) {
+        this.type = type;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getTestQuery() {
+        return testQuery;
+    }
+
+    public void setTestQuery(String testQuery) {
+        this.testQuery = testQuery;
+    }
+
+    public int getLoginTimeout() {
+        return loginTimeout;
+    }
+
+    public void setLoginTimeout(int loginTimeout) {
+        this.loginTimeout = loginTimeout;
+    }
+
+    public int getMaxLifetime() {
+        return maxLifetime;
+    }
+
+    public void setMaxLifetime(int maxLifetime) {
+        this.maxLifetime = maxLifetime;
+    }
+
+    public int getMinPoolSize() {
+        return minPoolSize;
+    }
+
+    public void setMinPoolSize(int minPoolSize) {
+        this.minPoolSize = minPoolSize;
+    }
+
+    public int getMaxPoolSize() {
+        return maxPoolSize;
+    }
+
+    public void setMaxPoolSize(int maxPoolSize) {
+        this.maxPoolSize = maxPoolSize;
+    }
+
+    public int getBorrowConnectionTimeout() {
+        return borrowConnectionTimeout;
+    }
+
+    public void setBorrowConnectionTimeout(int borrowConnectionTimeout) {
+        this.borrowConnectionTimeout = borrowConnectionTimeout;
+    }
+
+    public int getReapTimeout() {
+        return reapTimeout;
+    }
+
+    public void setReapTimeout(int reapTimeout) {
+        this.reapTimeout = reapTimeout;
+    }
+
+    public int getMaxIdleTime() {
+        return maxIdleTime;
+    }
+
+    public void setMaxIdleTime(int maxIdleTime) {
+        this.maxIdleTime = maxIdleTime;
+    }
+
+    public int getMaintenanceInterval() {
+        return maintenanceInterval;
+    }
+
+    public void setMaintenanceInterval(int maintenanceInterval) {
+        this.maintenanceInterval = maintenanceInterval;
+    }
+
+    public int getDefaultIsolationLevel() {
+        return defaultIsolationLevel;
+    }
+
+    public void setDefaultIsolationLevel(int defaultIsolationLevel) {
+        this.defaultIsolationLevel = defaultIsolationLevel;
+    }
+
+    public Properties getProperties() {
+        if (properties == null) {
+            properties = new Properties();
+        }
+        return properties;
+    }
+
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        Assert.notNull(url);
+        Assert.notNull(username);
+        if (datasourceName == null) {
+            datasourceName = lookupSupportDatasourceName();
+        }
+        if (type == null) {
+            type = DatabaseType.fromJdbcUrl(getUrl());
+        }
+        if (!StringUtils.hasText(testQuery)) testQuery = getType().getTestQuery();
+        getProperties().put(datasourceTypeSupport.usernameProperty, getUsername());
+        getProperties().put(datasourceTypeSupport.passwordProperty, getPassword());
+        getProperties().put(datasourceTypeSupport.urlProperty, getUrl());
+        initDefaultProperties();
+    }
+
+    public String lookupSupportDatasourceName() throws ClassNotFoundException {
+        for (DatasourceTypeSupport support : DatasourceTypeSupport.values()) {
+            try {
+                ClassUtils.forName(support.className, classLoader);
+                datasourceTypeSupport = support;
+                return support.className;
+            } catch (ClassNotFoundException e) {
+            }
+        }
+        return getType().getXaDataSourceClassName();
+    }
+
+    @Override
+    public void setBeanClassLoader(ClassLoader classLoader) {
+        this.classLoader = classLoader;
+    }
+
+    public void putProperties(AtomikosDataSourceBean dataSourceBean) {
+        dataSourceBean.setXaProperties(this.getProperties());
+        dataSourceBean.setXaDataSourceClassName(this.getDatasourceName());
+        dataSourceBean.setUniqueResourceName(this.getName());
+        dataSourceBean.setMinPoolSize(this.getMinPoolSize());
+        dataSourceBean.setMaxPoolSize(this.getMaxPoolSize());
+        dataSourceBean.setTestQuery(this.getTestQuery());
+        dataSourceBean.setBorrowConnectionTimeout(this.getBorrowConnectionTimeout());
+        dataSourceBean.setMaintenanceInterval(this.getMaintenanceInterval());
+        dataSourceBean.setDefaultIsolationLevel(this.getDefaultIsolationLevel());
+        dataSourceBean.setMaxLifetime(this.getMaxLifetime());
+        dataSourceBean.setMaxIdleTime(this.getMaxIdleTime());
+        dataSourceBean.setReapTimeout(this.getReapTimeout());
+        try {
+            dataSourceBean.setLoginTimeout(this.getLoginTimeout());
+        } catch (SQLException e) {
+        }
+    }
+
+    public void initDefaultProperties() {
+        datasourceTypeSupport.putDefaultProperties(getProperties());
+    }
+
+    private enum DatasourceTypeSupport {
+        druid("com.alibaba.druid.pool.xa.DruidXADataSource", "username", "password", "url") {
+            @Override
+            public void putDefaultProperties(Properties properties) {
+                super.putDefaultProperties(properties);
+                properties.putIfAbsent("filters", "stat");
+                properties.putIfAbsent("maxActive", 200);
+                properties.putIfAbsent("initialSize", 3);
+                properties.putIfAbsent("minIdle", 3);
+                properties.putIfAbsent("maxWait", 5000);
+                properties.putIfAbsent("timeBetweenEvictionRunsMillis", 60000);
+                properties.putIfAbsent("minEvictableIdleTimeMillis", 1800000);
+                properties.putIfAbsent("testWhileIdle", true);
+                properties.putIfAbsent("testOnBorrow", false);
+                properties.putIfAbsent("testOnReturn", false);
+                properties.putIfAbsent("poolPreparedStatements", true);
+                properties.putIfAbsent("maxOpenPreparedStatements", 20);
+            }
+        };
+
+        DatasourceTypeSupport(String className, String usernameProperty, String passwordProperty, String urlProperty) {
+            this.className = className;
+            this.usernameProperty = usernameProperty;
+            this.passwordProperty = passwordProperty;
+            this.urlProperty = urlProperty;
+        }
+
+        final String className;
+        final String usernameProperty;
+        final String passwordProperty;
+        final String urlProperty;
+
+        public void putDefaultProperties(Properties properties) {
+
+        }
+    }
+}

+ 38 - 29
hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceServiceImpl.java

@@ -20,6 +20,7 @@ import com.atomikos.jdbc.AtomikosDataSourceBean;
 import com.atomikos.jdbc.AtomikosSQLException;
 import org.hsweb.concurrent.lock.LockFactory;
 import org.hsweb.web.bean.po.datasource.DataSource;
+import org.hsweb.web.core.datasource.DatabaseType;
 import org.hsweb.web.core.datasource.DynamicDataSource;
 import org.hsweb.web.core.exception.NotFoundException;
 import org.hsweb.web.service.datasource.DataSourceService;
@@ -27,7 +28,6 @@ import org.hsweb.web.service.datasource.DynamicDataSourceService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
@@ -35,7 +35,7 @@ import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import java.io.Closeable;
 import java.io.IOException;
-import java.util.Properties;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -60,6 +60,11 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
         return getCache(id).getDataSource();
     }
 
+    @Override
+    public String getDataBaseType(String id) {
+        return getCache(id).getDatabaseType().name();
+    }
+
     @Override
     @PreDestroy
     public void destroyAll() throws Exception {
@@ -109,7 +114,8 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
                 }
                 //加载datasource到缓存
                 javax.sql.DataSource dataSource = createDataSource(old);
-                cacheInfo = new CacheInfo(old.getHash(), dataSource);
+                DatabaseType databaseType = DatabaseType.fromJdbcUrl(old.getUrl());
+                cacheInfo = new CacheInfo(old.getHash(), dataSource, databaseType);
                 cache.put(id, cacheInfo);
             } finally {
                 try {
@@ -123,32 +129,29 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
         }
     }
 
-    @Autowired
-    private DataSourceProperties properties;
-
     protected javax.sql.DataSource createDataSource(DataSource dataSource) {
-        AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean();
-        Properties xaProperties = new Properties();
-        if (dataSource.getProperties() != null)
-            xaProperties.putAll(dataSource.getProperties());
-        if (dataSource.getDriver().contains("mysql")) {
-            dataSourceBean.setXaDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
-            xaProperties.put("pinGlobalTxToPhysicalConnection", true);
-            xaProperties.put("user", dataSource.getUsername());
-            xaProperties.put("password", dataSource.getPassword());
-            xaProperties.put("url", dataSource.getUrl());
+        DynamicDataSourceProperties properties = new DynamicDataSourceProperties();
+        properties.setName("ds_" + dataSource.getId());
+        properties.setBeanClassLoader(this.getClass().getClassLoader());
+        properties.setUsername(dataSource.getUsername());
+        properties.setPassword(dataSource.getPassword());
+        properties.setUrl(dataSource.getUrl());
+        properties.setType(DatabaseType.fromJdbcUrl(dataSource.getUrl()));
+        properties.setTestQuery(dataSource.getTestSql());
+        Map<String, Object> otherProperties = dataSource.getProperties();
+        try {
+            properties.afterPropertiesSet();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        if (otherProperties != null) {
+            properties.getProperties().putAll(otherProperties);
         } else {
-            dataSourceBean.setXaDataSourceClassName(properties.getXa().getDataSourceClassName());
-            xaProperties.put("username", dataSource.getUsername());
-            xaProperties.put("password", dataSource.getPassword());
-            xaProperties.put("url", dataSource.getUrl());
-            xaProperties.put("driverClassName", dataSource.getDriver());
+            properties.initDefaultProperties();
         }
-        dataSourceBean.setXaProperties(xaProperties);
-        dataSourceBean.setUniqueResourceName("ds_" + dataSource.getId());
-        dataSourceBean.setMaxPoolSize(200);
-        dataSourceBean.setMinPoolSize(5);
-        dataSourceBean.setBorrowConnectionTimeout(60);
+
+        AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean();
+        properties.putProperties(dataSourceBean);
         boolean[] success = new boolean[1];
         //异步初始化
         new Thread(() -> {
@@ -156,6 +159,7 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
                 dataSourceBean.init();
                 success[0] = true;
             } catch (AtomikosSQLException e) {
+                logger.error("创建数据源失败", e);
                 closeDataSource(dataSourceBean);
                 cache.remove(dataSource.getId());
             }
@@ -183,13 +187,14 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
     }
 
     class CacheInfo {
-        int hash;
-
+        int                  hash;
+        DatabaseType         databaseType;
         javax.sql.DataSource dataSource;
 
-        public CacheInfo(int hash, javax.sql.DataSource dataSource) {
+        public CacheInfo(int hash, javax.sql.DataSource dataSource, DatabaseType type) {
             this.hash = hash;
             this.dataSource = dataSource;
+            this.databaseType = type;
         }
 
         public int getHash() {
@@ -199,6 +204,10 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
         public javax.sql.DataSource getDataSource() {
             return dataSource;
         }
+
+        public DatabaseType getDatabaseType() {
+            return databaseType;
+        }
     }
 
 }

+ 23 - 10
hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicXaDataSourceImpl.java

@@ -17,11 +17,13 @@
 package org.hsweb.web.datasource.dynamic;
 
 import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.hsweb.web.core.datasource.DatabaseType;
 import org.hsweb.web.core.datasource.DynamicDataSource;
 import org.hsweb.web.service.datasource.DynamicDataSourceService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.jdbc.datasource.AbstractDataSource;
+import org.springframework.util.Assert;
 
 import javax.sql.DataSource;
 import javax.sql.XAConnection;
@@ -31,13 +33,16 @@ import java.sql.Connection;
 import java.sql.SQLException;
 
 public class DynamicXaDataSourceImpl extends AbstractDataSource implements DynamicDataSource, XADataSource, Closeable {
-    private Logger logger = LoggerFactory.getLogger(DynamicDataSource.class);
-    private javax.sql.DataSource defaultDataSource;
-
+    private Logger               logger            = LoggerFactory.getLogger(DynamicDataSource.class);
+    private javax.sql.DataSource defaultDataSource = null;
+    private   DatabaseType             defaultDatabaseType;
     protected DynamicDataSourceService dynamicDataSourceService;
 
-    public DynamicXaDataSourceImpl(javax.sql.DataSource defaultDataSource) {
+    public DynamicXaDataSourceImpl(javax.sql.DataSource defaultDataSource, DatabaseType defaultDatabaseType) {
+        Assert.notNull(defaultDataSource);
+        Assert.notNull(defaultDatabaseType);
         this.defaultDataSource = defaultDataSource;
+        this.defaultDatabaseType = defaultDatabaseType;
     }
 
     @Override
@@ -55,10 +60,20 @@ public class DynamicXaDataSourceImpl extends AbstractDataSource implements Dynam
         logger.info("use datasource:{}", sourceId == null ? "default" : sourceId);
         if (sourceId == null || dynamicDataSourceService == null) return defaultDataSource;
         DataSource dataSource = dynamicDataSourceService.getDataSource(sourceId);
+        logger.info("use datasource:{} fail,because its not exists! use default datasource now.", sourceId);
         if (dataSource == null) return defaultDataSource;
         return dataSource;
     }
 
+    @Override
+    public DatabaseType getActiveDataBaseType() {
+        String sourceId = DynamicDataSource.getActiveDataSourceId();
+        if (sourceId == null || dynamicDataSourceService == null) return defaultDatabaseType;
+        String type = dynamicDataSourceService.getDataBaseType(sourceId);
+        if (type == null) return defaultDatabaseType;
+        return DatabaseType.valueOf(type);
+    }
+
     public XADataSource getActiveXADataSource() {
         DataSource activeDs = getActiveDataSource();
         XADataSource xaDataSource;
@@ -72,11 +87,8 @@ public class DynamicXaDataSourceImpl extends AbstractDataSource implements Dynam
         return xaDataSource;
     }
 
-    public void setDefaultDataSource(DataSource defaultDataSource) {
-        this.defaultDataSource = defaultDataSource;
-    }
-
-    public void setDynamicDataSourceService(DynamicDataSourceService dynamicDataSourceService) {
+    public synchronized void setDynamicDataSourceService(DynamicDataSourceService dynamicDataSourceService) {
+        if (this.dynamicDataSourceService != null) throw new UnsupportedOperationException();
         this.dynamicDataSourceService = dynamicDataSourceService;
     }
 
@@ -92,7 +104,8 @@ public class DynamicXaDataSourceImpl extends AbstractDataSource implements Dynam
 
     public void close() {
         try {
-            dynamicDataSourceService.destroyAll();
+            if (dynamicDataSourceService != null)
+                dynamicDataSourceService.destroyAll();
         } catch (Exception e) {
             logger.error("close datasource error", e);
         }

+ 120 - 0
hsweb-web-datasource/src/main/resources/META-INF/spring-configuration-metadata.json

@@ -0,0 +1,120 @@
+{
+  "groups": [
+    {
+      "name": "hsweb.dynamic-datasource",
+      "type": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    }
+  ],
+  "properties": [
+    {
+      "name": "hsweb.dynamic-datasource.name",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.type",
+      "type": "org.hsweb.web.core.datasource.DatabaseType",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.datasource-name",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.username",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.password",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.url",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.testQuery",
+      "type": "java.lang.String",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.login-timeout",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.max-life-time",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.min-pool-size",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.max-pool-size",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.borrow-connection-timeout",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.reap-timeout",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.max-idle-time",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.maintenance-interval",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.default-isolation-level",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.transaction-timeout",
+      "type": "java.lang.Integer",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    },
+    {
+      "name": "hsweb.dynamic-datasource.properties",
+      "type": "java.util.Properties",
+      "sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
+    }
+  ],
+  "hints": [
+    {
+      "name": "hsweb.dynamic-datasource.type",
+      "values": [
+        {
+          "value": "h2",
+          "description": "use h2 database."
+        },
+        {
+          "value": "mysql",
+          "description": "use mysql database."
+        },
+        {
+          "value": "oracle",
+          "description": "use oracle database."
+        }
+      ]
+    }
+  ]
+}

+ 1 - 1
hsweb-web-oauth2/hsweb-web-oauth2-controller/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-web-oauth2</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-web-oauth2/hsweb-web-oauth2-core/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-web-oauth2</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-web-oauth2/hsweb-web-oauth2-mybatis/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-web-oauth2</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/OAuth2AccessMapper.xml → hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/OAuth2AccessMapper.xml


hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/OAuth2ClientMapper.xml → hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/OAuth2ClientMapper.xml


+ 0 - 59
hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/OAuth2AccessMapper.xml

@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Copyright 2015-2016 http://hsweb.me
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.oauth2.dao.OAuth2AccessMapper">
-    <resultMap id="OAuth2AccessResultMap" type="org.hsweb.web.oauth2.po.OAuth2Access">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="clientId" column="client_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="userId" column="user_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="accessToken" column="access_token" javaType="String" jdbcType="VARCHAR"/>
-        <result property="refreshToken" column="refresh_token" javaType="String" jdbcType="VARCHAR"/>
-        <result property="expireIn" column="expire_in" javaType="int" jdbcType="NUMERIC"/>
-        <result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'OAuth2AccessResultMap'"/>
-        <bind name="tableName" value="'s_oauth2_access'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="deleteById" parameterType="String">
-        delete from s_oauth2_access where u_id=#{id}
-    </delete>
-
-    <select id="selectByPk" parameterType="string" resultMap="OAuth2AccessResultMap">
-        select * from s_oauth2_access where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="OAuth2AccessResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 0 - 64
hsweb-web-oauth2/hsweb-web-oauth2-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/OAuth2ClientMapper.xml

@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~ Copyright 2015-2016 http://hsweb.me
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hsweb.web.oauth2.dao.OAuth2ClientMapper">
-    <resultMap id="OAuth2ClientResultMap" type="org.hsweb.web.oauth2.po.OAuth2Client">
-        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="userId" column="user_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
-        <result property="secret" column="secret" javaType="String" jdbcType="VARCHAR"/>
-        <result property="comment" column="comment" javaType="String" jdbcType="VARCHAR"/>
-        <result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
-    </resultMap>
-
-    <!--用于动态生成sql所需的配置-->
-    <sql id="config">
-        <bind name="resultMapId" value="'OAuth2ClientResultMap'"/>
-        <bind name="tableName" value="'s_oauth2_client'"/>
-    </sql>
-    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildInsertSql"/>
-    </insert>
-
-    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildDeleteSql"/>
-    </delete>
-
-    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildUpdateSql"/>
-    </update>
-
-    <select id="selectByPk" parameterType="string" resultMap="OAuth2ClientResultMap">
-        select * from s_oauth2_client where u_id=#{id}
-    </select>
-
-    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="OAuth2ClientResultMap">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildSelectSql"/>
-    </select>
-
-    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
-        <include refid="config"/>
-        <include refid="BasicMapper.buildTotalSql"/>
-    </select>
-</mapper>

+ 1 - 1
hsweb-web-oauth2/hsweb-web-oauth2-service-simple/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-web-oauth2</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-web-oauth2/hsweb-web-oauth2-simple/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-web-oauth2</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-web-oauth2/pom.xml

@@ -21,7 +21,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-web-service/hsweb-web-service-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-web-service</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>hsweb-web-service-api</artifactId>

+ 3 - 1
hsweb-web-service/hsweb-web-service-api/src/main/java/org/hsweb/web/service/datasource/DynamicDataSourceService.java

@@ -25,6 +25,8 @@ public interface DynamicDataSourceService {
 
     DataSource getDataSource(String id);
 
-    void destroyAll()throws Exception;
+    String getDataBaseType(String id);
+
+    void destroyAll() throws Exception;
 
 }

+ 16 - 10
hsweb-web-service/hsweb-web-service-simple/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-web-service</artifactId>
         <groupId>org.hsweb</groupId>
-        <version>2.0-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -13,9 +13,15 @@
     <dependencies>
 
         <!--test-->
-        <dependency>
-            <groupId>org.hsweb</groupId>
-            <artifactId>hsweb-web-datasource</artifactId>
+        <!--<dependency>-->
+            <!--<groupId>org.hsweb</groupId>-->
+            <!--<artifactId>hsweb-web-datasource</artifactId>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
+        <!---->
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
             <scope>test</scope>
         </dependency>
 
@@ -30,11 +36,11 @@
             <artifactId>spring-context-support</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-redis</artifactId>
-            <scope>test</scope>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.springframework.boot</groupId>-->
+            <!--<artifactId>spring-boot-starter-redis</artifactId>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>javax.el</groupId>
@@ -74,7 +80,7 @@
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>druid</artifactId>
-            <version>1.0.25</version>
+            <version>1.0.26</version>
             <scope>test</scope>
         </dependency>
 

+ 0 - 0
hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/DataBaseAutoConfiguration.java


Неке датотеке нису приказане због велике количине промена