Pārlūkot izejas kodu

Merge branch 'leng_dev'

# Conflicts:
#	README.md
冷冷 7 gadi atpakaļ
vecāks
revīzija
2b6d1233f0
100 mainītis faili ar 1394 papildinājumiem un 603 dzēšanām
  1. 1 0
      .editorconfig
  2. 1 0
      .gitignore
  3. 4 0
      LICENSE
  4. 13 8
      README.md
  5. 11 18
      doc/db/2pigxx.sql
  6. 36 16
      doc/db/3pigxx_ac.sql
  7. 4 4
      doc/md/codegen.md
  8. 2 1
      doc/md/modules.md
  9. 5 5
      doc/md/social.md
  10. 44 3
      doc/md/swagger.md
  11. 5 0
      docker-compose.yml
  12. 15 15
      pigx-auth/pom.xml
  13. 25 10
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java
  14. 31 70
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java
  15. 0 5
      pigx-common/pigx-common-cache/src/main/resources/META-INF/spring.factories
  16. 1 7
      pigx-common/pigx-common-core/pom.xml
  17. 7 2
      pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstants.java
  18. 8 4
      pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java
  19. 17 5
      pigx-common/pigx-common-cache/pom.xml
  20. 1 1
      pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/DefaultRedisCacheWriter.java
  21. 7 6
      pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisAutoCacheManager.java
  22. 3 5
      pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisCacheAutoConfiguration.java
  23. 1 1
      pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisCacheManagerConfig.java
  24. 1 1
      pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisTemplateConfig.java
  25. 3 2
      pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScope.java
  26. 65 16
      pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScopeInterceptor.java
  27. 60 0
      pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/enums/DataScopeTypeEnum.java
  28. 24 29
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/config/MybatisPlusConfigurer.java
  29. 1 1
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignTenantConfiguration.java
  30. 1 2
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignTenantInterceptor.java
  31. 69 0
      pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/tenant/PigxTenantHandler.java
  32. 1 1
      pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/TenantContextHolder.java
  33. 1 2
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/filter/TenantContextHolderFilter.java
  34. 7 0
      pigx-common/pigx-common-data/src/main/resources/META-INF/spring.factories
  35. 2 2
      pigx-common/pigx-common-gateway/pom.xml
  36. 4 0
      pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/support/RedisRouteDefinitionWriter.java
  37. 1 1
      pigx-common/pigx-common-job/pom.xml
  38. 3 3
      pigx-common/pigx-common-log/pom.xml
  39. 24 0
      pigx-common/pigx-common-minio/pom.xml
  40. 21 26
      pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/config/MybatisPlusConfigurer.java
  41. 18 23
      pigx-visual/pigx-daemon/src/main/java/com/pig4cloud/pigx/daemon/config/MybatisPlusConfigurer.java
  42. 122 0
      pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/http/MinioEndpoint.java
  43. 189 0
      pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/service/MinioTemplate.java
  44. 53 0
      pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/vo/MinioItem.java
  45. 53 0
      pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/vo/MinioObject.java
  46. 2 0
      pigx-common/pigx-common-minio/src/main/resources/META-INF/spring.factories
  47. 3 3
      pigx-common/pigx-common-security/pom.xml
  48. 63 0
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxPreAuthenticationChecks.java
  49. 2 2
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/ResourceAuthExceptionEntryPoint.java
  50. 0 1
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileAuthenticationFilter.java
  51. 9 3
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileAuthenticationProvider.java
  52. 14 4
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java
  53. 0 2
      pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories
  54. 1 1
      pigx-common/pigx-common-swagger/pom.xml
  55. 2 2
      pigx-common/pigx-common-transaction/pom.xml
  56. 3 2
      pigx-common/pom.xml
  57. 1 1
      pigx-config/pom.xml
  58. 1 1
      pigx-config/src/main/resources/config/pigx-auth-dev.yml
  59. 7 0
      pigx-config/src/main/resources/config/pigx-upms-biz-dev.yml
  60. 1 1
      pigx-eureka/pom.xml
  61. 5 6
      pigx-gateway/pom.xml
  62. 5 5
      pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ValidateCodeGatewayFilter.java
  63. 2 2
      pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handler/HystrixFallbackHandler.java
  64. 8 2
      pigx-upms/pigx-upms-api/pom.xml
  65. 0 1
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserInfo.java
  66. 6 0
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRole.java
  67. 2 4
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java
  68. 1 1
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java
  69. 20 9
      pigx-upms/pigx-upms-biz/pom.xml
  70. 0 103
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/MybatisPlusConfigurer.java
  71. 91 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/FileController.java
  72. 9 9
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/MenuController.java
  73. 4 2
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java
  74. 6 6
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java
  75. 5 5
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/SmsLoginHandler.java
  76. 3 3
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/WeChatLoginHandler.java
  77. 1 1
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java
  78. 2 1
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysMenuService.java
  79. 16 12
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysMenuServiceImpl.java
  80. 24 34
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java
  81. 2 2
      pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysMenuMapper.xml
  82. 2 0
      pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMapper.xml
  83. 1 1
      pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRouteConfMapper.xml
  84. 35 19
      pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml
  85. 1 1
      pigx-upms/pom.xml
  86. 25 14
      pigx-visual/pigx-activiti/pom.xml
  87. 1 1
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ActTaskServiceImpl.java
  88. 1 1
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/EditorServiceImpl.java
  89. 12 12
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ModelServiceImpl.java
  90. 1 1
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ProcessServiceImpl.java
  91. 10 4
      pigx-visual/pigx-codegen/pom.xml
  92. 1 4
      pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm
  93. 1 1
      pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm
  94. 0 3
      pigx-visual/pigx-codegen/src/main/resources/template/Mapper.java.vm
  95. 0 2
      pigx-visual/pigx-codegen/src/main/resources/template/Service.java.vm
  96. 2 3
      pigx-visual/pigx-codegen/src/main/resources/template/ServiceImpl.java.vm
  97. 0 1
      pigx-visual/pigx-codegen/src/main/resources/template/crud.js.vm
  98. 4 4
      pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm
  99. 11 5
      pigx-visual/pigx-daemon/pom.xml
  100. 0 0
      pigx-visual/pigx-monitor/pom.xml

+ 1 - 0
.editorconfig

@@ -1,3 +1,4 @@
+# 开发组IDE 编辑器标准 V2.1.0
 root = true
 
 [*.{adoc, bat, groovy, html, java, js, jsp, kt, kts, md, properties, py, rb, sh, sql, svg, txt, xml, xsd}]

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
+# 忽略匹配下列规则的Git 提交 V2.1.0
 ### gradle ###
 .gradle
 /build/

+ 4 - 0
LICENSE

@@ -14,4 +14,8 @@ pigX并非一个开源软件,作者保留全部的权利。
 将本项目的部分或全部代码和资源进行任何形式的再发行(尤其上传GitHub、Gitee )
 利用本项目的部分或全部代码和资源进行任何商业行为
 
+免责声明
+
+PigX 未对任何组织、团队,书面授权商业使用。如若出现任何商业后果、纠纷和本人无关,特此声明
+
     Author: lengleng (wangiegie@gmail.com)

+ 13 - 8
README.md

@@ -1,7 +1,9 @@
-## pigx 2.0
-[pigx 2.0 部署文档](doc/md/deploy.md)  
-[pigx 2.0 新特性说明  ](https://www.bilibili.com/video/av37786337)   
-[pigx 2.0 从检出到启动](https://www.bilibili.com/video/av37695530)  
+## 当前版本
+V2.1.0
+## pigx pro
+[pigx pro 部署文档](doc/md/deploy.md)  
+[pigx pro 新特性说明  ](https://www.bilibili.com/video/av37786337)   
+[pigx pro 从检出到启动](https://www.bilibili.com/video/av37695530)  
 [pigx pro新建微服务模块(一)](https://www.bilibili.com/video/av37737139)  
 [pigx pro新建微服务模块(二)](https://www.bilibili.com/video/av37740030)  
 [pigx pro新建微服务模块(三)](https://www.bilibili.com/video/av37743341)  
@@ -10,20 +12,23 @@
 
 ## 协议和授权
 
-pigX并非一个开源软件,作者保留全部的权利。  
-
+pigX并非一个开源软件,作者保留全部的权利。
 擅自窃用,即属严重侵权行为,与盗窃无异。产生的一切任何后果责任由侵权者自负。
 
 ### 🌹权益
 
-个人使用学习、毕设
+1. 个人使用
+2. 允许用于学习、毕设等。
 
 ### 🚫禁止  
 
 1. 将本项目的部分或全部代码和资源进行任何形式的再发行(尤其上传GitHub、Gitee )
-
 2. 利用本项目的部分或全部代码和资源进行`任何商业行为`
 
+### 免责声明
+
+PigX 未对任何组织、团队,书面授权商业使用。如若出现任何商业后果、纠纷和本人无关,特此声明
+
 ## 贡献代码
 
 pigX并非一个开源项目,也不是社区共同创造,其全部功能由作者独立完成。

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 11 - 18
doc/db/2pigxx.sql


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 36 - 16
doc/db/3pigxx_ac.sql


+ 4 - 4
doc/md/codegen.md

@@ -40,19 +40,19 @@ v 1.4.0 提供了代码图形化生成功能。
 
 1. 代码生成模块
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180803083802.png)
+![](http://a.pigx.top/20180803083802.png)
 
 2. 选择要生成的表
 
    > 以下为空则从**pigx-codegen/generator.properties** 获取
 
-   ![](http://obq1lvsd9.bkt.clouddn.com/20180803084058.png)
+   ![](http://a.pigx.top/20180803084058.png)
 
 3. 解压下载的**pigx_code_gen.zip**
 
    > 生成代码结构,安装前后端 maven 、vue-cli 目录生成,可以覆盖到指定业务模块
 
-   ![](http://obq1lvsd9.bkt.clouddn.com/20180803084524.png)
+   ![](http://a.pigx.top/20180803084524.png)
 
 4. **重点讲解生成的SQL使用**
 
@@ -72,7 +72,7 @@ v 1.4.0 提供了代码图形化生成功能。
    ├── 14
    ```
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180803084905.png)
+![](http://a.pigx.top/20180803084905.png)
 
 5. **配置路由**
 前端 index.js

+ 2 - 1
doc/md/modules.md

@@ -5,9 +5,10 @@ pigx
 ├── pigx-auth -- 授权服务提供[3000]
 ├── pigx-common -- 系统公共模块 
 ├    ├── pigx-common-core -- 公共工具类核心包
-├    ├── pigx-common-cache -- 缓存
+├    ├── pigx-common-data -- 数据相关
 ├    ├── pigx-common-job -- 定时任务
 ├    ├── pigx-common-log -- 日志服务
+├    ├── pigx-common-minio -- 文件系统
 ├    └── pigx-common-security -- 安全工具类
 ├    └── pigx-common-swagger -- Swagger Api文档生成
 ├    └── pigx-common-transaction -- 分布式事务工具包

+ 5 - 5
doc/md/social.md

@@ -12,7 +12,7 @@
 
 1. 修改为80
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180818115000.png)
+![](http://a.pigx.top/20180818115000.png)
 
 2. 使用mac 的同学,nginx 代理一下
 
@@ -30,11 +30,11 @@ http://daoweicloud.com
 
 1. 首先使用账号密码登录系统绑定微信
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180818120253.png)
+![](http://a.pigx.top/20180818120253.png)
 
 
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180818120339.png)
+![](http://a.pigx.top/20180818120339.png)
 
 2. 绑定后使用退出,使用社交等 选择微信登录即可。
 
@@ -46,8 +46,8 @@ http://daoweicloud.com
 
 1. 选择社交登录 提示回调地址错误。 请使用 http://daoweicloud.com 访问
 
-   ![](http://obq1lvsd9.bkt.clouddn.com/20180818120543.png)
+   ![](http://a.pigx.top/20180818120543.png)
 
 1. 选择微信登录提示: 未绑定账户,请使用密码登录后绑定,需要先登录后绑定微信,才可以使用微信
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180818120045.png)
+![](http://a.pigx.top/20180818120045.png)

+ 44 - 3
doc/md/swagger.md

@@ -114,7 +114,7 @@ swagger:
 
 - 通过界面的形式
 
-  ![](http://obq1lvsd9.bkt.clouddn.com/20180725132807.png)
+  ![](http://a.pigx.top/20180725132807.png)
 
 - 直接操作**sys_oauth_client_details**表
 
@@ -159,9 +159,50 @@ ignore:
     - test
 ```
 
+#### 访问swagger-ui页面
+
+从```1.6.3```版本开始,要求通过```hosts```进行访问,在pigx的默认配置下,可以访问```http://pigx-gateway:9999/swagger-ui.html```打开swagger页面。
+
 #### 填写客户端信息
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180725133119.png)
+![](http://a.pigx.top/20180725133119.png)
+
+![](http://a.pigx.top/20180725133206.png)
+
+### Swagger FAQ
+
+-   为何要进行认证的操作?
+
+认证后Spring Security的上下文对象中才会有值,很多操作如获取当前用户信息都依赖于Spring Security上下文。
+
+-   刷新页面后认证失效?
+
+官方UI比较蠢萌,虽然提供了Oauth2.0的认证功能,但是没有存储的措施,所以刷新页面后相关参数就会丢失。解决办法暴力一点的措施是修改官方UI添加存储措施,但是这个我肯定不会了。目前比较可行的就是修改代码进行swagger全局参数配置。
+
+- 切换swagger分组文档页面报错
+
+![20181121214548](http://oss1.pig4cloud.com/20181121214548.png)
+
+出现这个问题要么是你对应的服务没有启动,要么是你访问的服务还没有启动完毕,如果还没启动完毕的话,不妨等个十几二十秒再进行访问,最新的master-mp3分支支持在```pigx-gateway-dev.yml```中配置ignore.swagger-providers属性来屏蔽掉不希望生成swaager文档的微服务。
+
+-   认证过程中出现```Auth ErrorError: Upgrade Required```?
+
+这个不用怀疑,原因一般不外乎三个。
+
+一、用户名或密码错误
+
+可以打开谷歌开发者工具,观察request详情和response详情以及返回的状态码,如果是426的话,就证明获取用户信息的时候失败了,可以判断是作为缓存中间件的redis并没有启动,那么只要启动redis,另一个原因是redis中有脏数据,这个时候清空redis即可。清空的具体步骤如下:
+
+windows平台下可以打开redis-cli.exe,然后执行```flushdb```或者```flushall```命令即可。
+
+二、使用了需要验证码的客户端
+
+除了上面的原因,还有可能返回428的状态码,而会出现这个问题就是使用了需要验证码的客户端。
+
+三、跨域
+
+排除所有不可能,剩下的那个不管多不可思议,都是事实真相。除开这两个原因,还有可能会出问题的,只有一种情况,那就是出现了跨域问题。
 
-![](http://obq1lvsd9.bkt.clouddn.com/20180725133206.png)
+如果本地启动出现了问题,可以观察请求头里是否存在跨域,如果是OPTIONS请求基本就是跨域了。
 
+在目前的项目机制下,开发时解决跨域的最简单的一个方案就是不要通过```http://localhost:9999/swagger-ui.html```或者```http://127.0.0.1:9999/swagger-ui.html```去访问网关上的swagger,而是直接通过```http://pigx-gateway:9999/swagger-ui.html```去访问,这样就能避免跨域的问题。

+ 5 - 0
docker-compose.yml

@@ -1,3 +1,8 @@
+# 使用说明 V2.1.0
+# 1. 使用docker-compose  宿主机不需要配置host来发现
+# 2. 无需修改源码,根目录  docker-compose up 即可
+# 3. 静静等待服务启动
+
 version: '2'
 services:
   pigx-mysql:

+ 15 - 15
pigx-auth/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-auth</artifactId>
@@ -42,13 +42,25 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-upms-api</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--security-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-security</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
+		</dependency>
+		<!--mysql 驱动-->
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>${mysql.connector.version}</version>
+		</dependency>
+		<!--缓存操作-->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-data</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<!--JDBC相关-->
 		<dependency>
@@ -60,12 +72,6 @@
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-freemarker</artifactId>
 		</dependency>
-		<!--缓存操作相关-->
-		<dependency>
-			<groupId>com.pig4cloud</groupId>
-			<artifactId>pigx-common-cache</artifactId>
-			<version>2.0.0</version>
-		</dependency>
 		<!--spring security 、oauth、jwt依赖-->
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
@@ -83,12 +89,6 @@
 			<artifactId>spring-security-oauth2</artifactId>
 			<version>${security.oauth.version}</version>
 		</dependency>
-		<!--数据库-->
-		<dependency>
-			<groupId>mysql</groupId>
-			<artifactId>mysql-connector-java</artifactId>
-			<version>${mysql.connector.version}</version>
-		</dependency>
 		<!--web 模块-->
 		<dependency>
 			<groupId>org.springframework.boot</groupId>

+ 25 - 10
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java

@@ -20,8 +20,10 @@
 package com.pig4cloud.pigx.auth.config;
 
 import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
 import com.pig4cloud.pigx.common.security.component.PigxWebResponseExceptionTranslator;
 import com.pig4cloud.pigx.common.security.service.PigxClientDetailsService;
+import com.pig4cloud.pigx.common.security.service.PigxUser;
 import com.pig4cloud.pigx.common.security.service.PigxUserDetailsService;
 import lombok.AllArgsConstructor;
 import org.springframework.context.annotation.Bean;
@@ -35,6 +37,8 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.A
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
 import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
 import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.token.DefaultAuthenticationKeyGenerator;
 import org.springframework.security.oauth2.provider.token.TokenEnhancer;
 import org.springframework.security.oauth2.provider.token.TokenStore;
 import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
@@ -68,20 +72,20 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 	@Override
 	public void configure(AuthorizationServerSecurityConfigurer oauthServer) {
 		oauthServer
-			.allowFormAuthenticationForClients()
-			.checkTokenAccess("isAuthenticated()");
+				.allowFormAuthenticationForClients()
+				.checkTokenAccess("isAuthenticated()");
 	}
 
 	@Override
 	public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
 		endpoints
-			.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST)
-			.tokenStore(tokenStore())
-			.tokenEnhancer(tokenEnhancer())
-			.userDetailsService(pigxUserDetailsService)
-			.authenticationManager(authenticationManager)
-			.reuseRefreshTokens(false)
-			.exceptionTranslator(new PigxWebResponseExceptionTranslator());
+				.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST)
+				.tokenStore(tokenStore())
+				.tokenEnhancer(tokenEnhancer())
+				.userDetailsService(pigxUserDetailsService)
+				.authenticationManager(authenticationManager)
+				.reuseRefreshTokens(false)
+				.exceptionTranslator(new PigxWebResponseExceptionTranslator());
 	}
 
 
@@ -89,13 +93,24 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
 	public TokenStore tokenStore() {
 		RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
 		tokenStore.setPrefix(SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX);
+		tokenStore.setAuthenticationKeyGenerator(new DefaultAuthenticationKeyGenerator() {
+			@Override
+			public String extractKey(OAuth2Authentication authentication) {
+				return super.extractKey(authentication) + ":" + TenantContextHolder.getTenantId();
+			}
+		});
 		return tokenStore;
 	}
 
 	@Bean
 	public TokenEnhancer tokenEnhancer() {
 		return (accessToken, authentication) -> {
-			final Map<String, Object> additionalInfo = new HashMap<>(1);
+			final Map<String, Object> additionalInfo = new HashMap<>(8);
+			PigxUser pigxUser = (PigxUser) authentication.getUserAuthentication().getPrincipal();
+			additionalInfo.put("user_id", pigxUser.getId());
+			additionalInfo.put("username", pigxUser.getUsername());
+			additionalInfo.put("dept_id", pigxUser.getDeptId());
+			additionalInfo.put("tenant_id", pigxUser.getTenantId());
 			additionalInfo.put("license", SecurityConstants.PIGX_LICENSE);
 			((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
 			return accessToken;

+ 31 - 70
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java

@@ -22,30 +22,29 @@ package com.pig4cloud.pigx.auth.endpoint;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.pig4cloud.pigx.common.core.constant.CommonConstants;
 import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
 import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
 import com.pig4cloud.pigx.common.core.util.R;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
-import com.pig4cloud.pigx.common.security.service.PigxUser;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
+import com.pig4cloud.pigx.common.security.annotation.Inner;
 import lombok.AllArgsConstructor;
 import org.springframework.cache.CacheManager;
 import org.springframework.data.redis.core.ConvertingCursor;
 import org.springframework.data.redis.core.Cursor;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ScanOptions;
+import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
 import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
 import org.springframework.http.HttpHeaders;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
 import org.springframework.security.oauth2.common.OAuth2AccessToken;
 import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -58,7 +57,8 @@ import java.util.Map;
 @AllArgsConstructor
 @RequestMapping("/token")
 public class PigxTokenEndpoint {
-	private static final String PIGX_OAUTH_ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "access:";
+	private static final String PIGX_OAUTH_ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "auth_to_access:";
+	private static final String PIGX__ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "access:";
 	private final TokenStore tokenStore;
 	private final RedisTemplate redisTemplate;
 	private final CacheManager cacheManager;
@@ -79,20 +79,26 @@ public class PigxTokenEndpoint {
 	 * @param authHeader Authorization
 	 */
 	@DeleteMapping("/logout")
-	public R<Boolean> logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
+	public R logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
 		if (StrUtil.isBlank(authHeader)) {
-			return new R<>(false, "退出失败,token 为空");
+			return R.builder()
+					.code(CommonConstants.FAIL)
+					.data(Boolean.FALSE)
+					.msg("退出失败,token 为空").build();
 		}
 
 		String tokenValue = authHeader.replace("Bearer", "").trim();
 		OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
 		if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
-			return new R<>(false, "退出失败,token 无效");
+			return R.builder()
+					.code(CommonConstants.FAIL)
+					.data(Boolean.FALSE)
+					.msg("退出失败,token 无效").build();
 		}
 
 		OAuth2Authentication auth2Authentication = tokenStore.readAuthentication(accessToken);
 		cacheManager.getCache("user_details")
-			.evict(auth2Authentication.getName());
+				.evict(auth2Authentication.getName());
 		tokenStore.removeAccessToken(accessToken);
 		return new R<>(Boolean.TRUE);
 	}
@@ -101,15 +107,14 @@ public class PigxTokenEndpoint {
 	 * 令牌管理调用
 	 *
 	 * @param token token
-	 * @param from  内部调用标志
 	 * @return
 	 */
+	@Inner
 	@DeleteMapping("/{token}")
-	public R<Boolean> delToken(@PathVariable("token") String token, @RequestHeader(required = false) String from) {
-		if (StrUtil.isBlank(from)) {
-			return null;
-		}
-		return new R<>(redisTemplate.delete(PIGX_OAUTH_ACCESS + token));
+	public R<Boolean> delToken(@PathVariable("token") String token) {
+		OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token);
+		tokenStore.removeAccessToken(oAuth2AccessToken);
+		return new R<>();
 	}
 
 
@@ -117,68 +122,24 @@ public class PigxTokenEndpoint {
 	 * 查询token
 	 *
 	 * @param params 分页参数
-	 * @param from   标志
 	 * @return
 	 */
+	@Inner
 	@PostMapping("/page")
-	public R<Page> tokenList(@RequestBody Map<String, Object> params, @RequestHeader(required = false) String from) {
-		if (StrUtil.isBlank(from)) {
-			return null;
-		}
-
-		List<Map<String, String>> list = new ArrayList<>();
+	public R<Page> tokenList(@RequestBody Map<String, Object> params) {
 		//根据分页参数获取对应数据
-		List<String> pages = findKeysForPage(PIGX_OAUTH_ACCESS + "*", MapUtil.getInt(params, PaginationConstants.CURRENT), MapUtil.getInt(params, PaginationConstants.SIZE));
-
-		for (String page : pages) {
-			String accessToken = StrUtil.subAfter(page, PIGX_OAUTH_ACCESS, true);
-			OAuth2AccessToken token = tokenStore.readAccessToken(accessToken);
-			Map<String, String> map = new HashMap<>(8);
-
-
-			map.put("token_type", token.getTokenType());
-			map.put("token_value", token.getValue());
-			map.put("expires_in", token.getExpiresIn() + "");
-
-
-			OAuth2Authentication oAuth2Auth = tokenStore.readAuthentication(token);
-			Authentication authentication = oAuth2Auth.getUserAuthentication();
-
-			map.put("client_id", oAuth2Auth.getOAuth2Request().getClientId());
-			map.put("grant_type", oAuth2Auth.getOAuth2Request().getGrantType());
-
-			if (authentication instanceof UsernamePasswordAuthenticationToken) {
-				UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) authentication;
-				if (extractToken(map, authenticationToken.getPrincipal())) {
-					continue;
-				}
-			} else if (authentication instanceof PreAuthenticatedAuthenticationToken) {
-				//刷新token方式
-				PreAuthenticatedAuthenticationToken authenticationToken = (PreAuthenticatedAuthenticationToken) authentication;
-				if (extractToken(map, authenticationToken.getPrincipal())) {
-					continue;
-				}
-			}
-			list.add(map);
-		}
+		String key = String.format("%s*:%s", PIGX_OAUTH_ACCESS, TenantContextHolder.getTenantId());
+		List<String> pages = findKeysForPage(key, MapUtil.getInt(params, PaginationConstants.CURRENT)
+				, MapUtil.getInt(params, PaginationConstants.SIZE));
 
+		redisTemplate.setKeySerializer(new StringRedisSerializer());
+		redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
 		Page result = new Page(MapUtil.getInt(params, PaginationConstants.CURRENT), MapUtil.getInt(params, PaginationConstants.SIZE));
-		result.setRecords(list);
-		result.setTotal(Long.valueOf(redisTemplate.keys(PIGX_OAUTH_ACCESS + "*").size()));
+		result.setRecords(redisTemplate.opsForValue().multiGet(pages));
+		result.setTotal(Long.valueOf(redisTemplate.keys(key).size()));
 		return new R<>(result);
 	}
 
-	private boolean extractToken(Map<String, String> map, Object principal) {
-		if (principal instanceof PigxUser) {
-			PigxUser user = (PigxUser) principal;
-			if (!user.getTenantId().equals(TenantContextHolder.getTenantId())) {
-				return true;
-			}
-			map.put("user_id", user.getId() + "");
-			map.put("user_name", user.getUsername() + "");
-		}
-		return false;
-	}
 
 	private List<String> findKeysForPage(String patternKey, int pageNum, int pageSize) {
 		ScanOptions options = ScanOptions.scanOptions().match(patternKey).build();

+ 0 - 5
pigx-common/pigx-common-cache/src/main/resources/META-INF/spring.factories

@@ -1,5 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-    com.pig4cloud.pigx.common.cache.RedisTemplateConfig,\
-    com.pig4cloud.pigx.common.cache.RedisCacheManagerConfig,\
-    com.pig4cloud.pigx.common.cache.RedisCacheAutoConfiguration
-

+ 1 - 7
pigx-common/pigx-common-core/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-core</artifactId>
@@ -50,12 +50,6 @@
 			<groupId>javax.servlet</groupId>
 			<artifactId>javax.servlet-api</artifactId>
 		</dependency>
-		<!--mybatis plus extension,包含了mybatis plus core-->
-		<dependency>
-			<groupId>com.baomidou</groupId>
-			<artifactId>mybatis-plus-extension</artifactId>
-			<version>${mybatis-plus.version}</version>
-		</dependency>
 		<!--feign 依赖-->
 		<dependency>
 			<groupId>io.github.openfeign</groupId>

+ 7 - 2
pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstants.java

@@ -80,9 +80,14 @@ public interface CommonConstants {
 	/**
 	 * 成功标记
 	 */
-	Integer SUCCESS=0;
+	Integer SUCCESS = 0;
 	/**
 	 * 失败标记
 	 */
-	Integer FAIL=1;
+	Integer FAIL = 1;
+
+	/**
+	 * 默认存储bucket
+	 */
+	String BUCKET_NAME = "lengleng";
 }

+ 8 - 4
pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java

@@ -24,6 +24,10 @@ package com.pig4cloud.pigx.common.core.constant;
  * @date 2017-12-18
  */
 public interface SecurityConstants {
+	/**
+	 * 刷新
+	 */
+	String REFRESH_TOKEN = "refresh_token";
 	/**
 	 * 验证码有效期
 	 */
@@ -82,7 +86,7 @@ public interface SecurityConstants {
 	 * 微信获取OPENID
 	 */
 	String WX_AUTHORIZATION_CODE_URL = "https://api.weixin.qq.com/sns/oauth2/access_token" +
-		"?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
+			"?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
 
 	/**
 	 * {bcrypt} 加密的特征码
@@ -92,14 +96,14 @@ public interface SecurityConstants {
 	 * sys_oauth_client_details 表的字段,不包括client_id、client_secret
 	 */
 	String CLIENT_FIELDS = "client_id, CONCAT('{noop}',client_secret) as client_secret, resource_ids, scope, "
-		+ "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
-		+ "refresh_token_validity, additional_information, autoapprove";
+			+ "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
+			+ "refresh_token_validity, additional_information, autoapprove";
 
 	/**
 	 * JdbcClientDetailsService 查询语句
 	 */
 	String BASE_FIND_STATEMENT = "select " + CLIENT_FIELDS
-		+ " from sys_oauth_client_details";
+			+ " from sys_oauth_client_details";
 
 	/**
 	 * 默认的查询语句

+ 17 - 5
pigx-common/pigx-common-cache/pom.xml

@@ -24,21 +24,33 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
-	<artifactId>pigx-common-cache</artifactId>
+	<artifactId>pigx-common-data</artifactId>
 	<packaging>jar</packaging>
 
-	<description>pigx 缓存工具类</description>
+	<description>pigx 数据操作相关</description>
 
 
 	<dependencies>
-		<!--工具类核心包 要从线程中获取租户ID-->
+		<!--工具类核心包-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
+		</dependency>
+		<!--mybatis plus extension,包含了mybatis plus core-->
+		<dependency>
+			<groupId>com.baomidou</groupId>
+			<artifactId>mybatis-plus-extension</artifactId>
+			<version>${mybatis-plus.version}</version>
+		</dependency>
+		<!--安全依赖获取上下文信息-->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-security</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<!--缓存依赖-->
 		<dependency>

+ 1 - 1
pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/DefaultRedisCacheWriter.java

@@ -15,7 +15,7 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.cache;
+package com.pig4cloud.pigx.common.data.cache;
 
 import org.springframework.dao.PessimisticLockingFailureException;
 import org.springframework.data.redis.cache.RedisCacheWriter;

+ 7 - 6
pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisAutoCacheManager.java

@@ -15,10 +15,10 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.cache;
+package com.pig4cloud.pigx.common.data.cache;
 
 import cn.hutool.core.util.StrUtil;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.cache.Cache;
 import org.springframework.data.redis.cache.RedisCache;
@@ -53,20 +53,21 @@ public class RedisAutoCacheManager extends RedisCacheManager {
 		if (StrUtil.isBlank(name) || !name.contains(SPLIT_FLAG)) {
 			return super.createRedisCache(name, cacheConfig);
 		}
+
 		String[] cacheArray = name.split(SPLIT_FLAG);
 		if (cacheArray.length < CACHE_LENGTH) {
 			return super.createRedisCache(name, cacheConfig);
 		}
-		String cacheName = cacheArray[0] + ":" + TenantContextHolder.getTenantId();
+
 		if (cacheConfig != null) {
-			long cacheAge = Long.getLong(cacheArray[1], -1);
+			long cacheAge = Long.parseLong(cacheArray[1]);
 			cacheConfig = cacheConfig.entryTtl(Duration.ofSeconds(cacheAge));
 		}
-		return super.createRedisCache(cacheName, cacheConfig);
+		return super.createRedisCache(name, cacheConfig);
 	}
 
 	@Override
 	public Cache getCache(String name) {
-		return super.getCache(name + ":" + TenantContextHolder.getTenantId());
+		return super.getCache(name + SPLIT_FLAG + TenantContextHolder.getTenantId());
 	}
 }

+ 3 - 5
pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisCacheAutoConfiguration.java

@@ -15,7 +15,7 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.cache;
+package com.pig4cloud.pigx.common.data.cache;
 
 import org.springframework.beans.factory.ObjectProvider;
 import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -75,11 +75,9 @@ public class RedisCacheAutoConfiguration {
 			cacheNames.forEach(it -> cacheConfigMap.put(it, cacheConfiguration));
 			initialCaches.putAll(cacheConfigMap);
 		}
-		boolean allowInFlightCacheCreation = true;
-		boolean enableTransactions = false;
 		RedisAutoCacheManager cacheManager = new RedisAutoCacheManager(redisCacheWriter, cacheConfiguration,
-			initialCaches, allowInFlightCacheCreation);
-		cacheManager.setTransactionAware(enableTransactions);
+			initialCaches, true);
+		cacheManager.setTransactionAware(false);
 		return this.customizerInvoker.customize(cacheManager);
 	}
 

+ 1 - 1
pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisCacheManagerConfig.java

@@ -15,7 +15,7 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.cache;
+package com.pig4cloud.pigx.common.data.cache;
 
 import org.springframework.beans.factory.ObjectProvider;
 import org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer;

+ 1 - 1
pigx-common/pigx-common-cache/src/main/java/com/pig4cloud/pigx/common/cache/RedisTemplateConfig.java

@@ -15,7 +15,7 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.cache;
+package com.pig4cloud.pigx.common.data.cache;
 
 import lombok.AllArgsConstructor;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;

+ 3 - 2
pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScope.java

@@ -15,11 +15,12 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.core.datascope;
+package com.pig4cloud.pigx.common.data.datascope;
 
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -39,7 +40,7 @@ public class DataScope extends HashMap {
 	/**
 	 * 具体的数据范围
 	 */
-	private List<Integer> deptIds;
+	private List<Integer> deptIds = new ArrayList<>();
 
 	/**
 	 * 是否只查询本部门

+ 65 - 16
pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/datascope/DataScopeInterceptor.java

@@ -15,12 +15,20 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.core.datascope;
+package com.pig4cloud.pigx.common.data.datascope;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.StrUtil;
+import cn.hutool.db.Db;
+import cn.hutool.db.Entity;
 import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
 import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler;
+import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
+import com.pig4cloud.pigx.common.core.exception.CheckedException;
+import com.pig4cloud.pigx.common.data.enums.DataScopeTypeEnum;
+import com.pig4cloud.pigx.common.security.service.PigxUser;
+import com.pig4cloud.pigx.common.security.util.SecurityUtils;
+import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.executor.statement.StatementHandler;
 import org.apache.ibatis.mapping.BoundSql;
@@ -29,26 +37,29 @@ import org.apache.ibatis.mapping.SqlCommandType;
 import org.apache.ibatis.plugin.*;
 import org.apache.ibatis.reflection.MetaObject;
 import org.apache.ibatis.reflection.SystemMetaObject;
+import org.springframework.security.core.GrantedAuthority;
 
+import javax.sql.DataSource;
 import java.sql.Connection;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
  * @author lengleng
- * @date 2018/8/30
+ * @date 2018/12/26
  * <p>
  * mybatis 数据权限拦截器
  */
 @Slf4j
+@AllArgsConstructor
 @Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
 public class DataScopeInterceptor extends AbstractSqlParserHandler implements Interceptor {
+	private final DataSource dataSource;
 
 	@Override
 	public Object intercept(Invocation invocation) throws Throwable {
-		StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
+		StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget());
 		MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
 		this.sqlParser(metaObject);
 		// 先判断是不是SELECT操作
@@ -63,19 +74,57 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
 
 		//查找参数中包含DataScope类型的参数
 		DataScope dataScope = findDataScopeObject(parameterObject);
-
 		if (dataScope == null) {
 			return invocation.proceed();
-		} else {
-			String scopeName = dataScope.getScopeName();
-			List<Integer> deptIds = dataScope.getDeptIds();
-			if (StrUtil.isNotBlank(scopeName) && CollectionUtil.isNotEmpty(deptIds)) {
-				String join = CollectionUtil.join(deptIds, ",");
-				originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")";
-				metaObject.setValue("delegate.boundSql.sql", originalSql);
+		}
+
+		String scopeName = dataScope.getScopeName();
+		List<Integer> deptIds = dataScope.getDeptIds();
+		// 优先获取赋值数据
+		if (CollUtil.isEmpty(deptIds)) {
+			PigxUser user = SecurityUtils.getUser();
+			if (user == null) {
+				throw new CheckedException("auto datascope, set up security details true");
+			}
+
+			List<String> roleIdList = user.getAuthorities()
+					.stream().map(GrantedAuthority::getAuthority)
+					.filter(authority -> authority.startsWith(SecurityConstants.ROLE))
+					.map(authority -> authority.split("_")[1])
+					.collect(Collectors.toList());
+
+			Entity query = Db.use(dataSource)
+					.query("SELECT * FROM sys_role where role_id IN (" + CollUtil.join(roleIdList, ",") + ")")
+					.stream().min(Comparator.comparingInt(o -> o.getInt("ds_type"))).get();
+
+			Integer dsType = query.getInt("ds_type");
+			// 查询全部
+			if (DataScopeTypeEnum.ALL.getType() == dsType) {
+				return invocation.proceed();
+			}
+			// 自定义
+			if (DataScopeTypeEnum.CUSTOM.getType() == dsType) {
+				String dsScope = query.getStr("ds_scope");
+				deptIds.addAll(Arrays.stream(dsScope.split(","))
+						.map(Integer::parseInt).collect(Collectors.toList()));
+			}
+			// 查询本级及其下级
+			if (DataScopeTypeEnum.OWN_CHILD_LEVEL.getType() == dsType) {
+				List<Integer> deptIdList = Db.use(dataSource)
+						.findBy("sys_dept_relation", "ancestor", user.getDeptId())
+						.stream().map(entity -> entity.getInt("descendant"))
+						.collect(Collectors.toList());
+				deptIds.addAll(deptIdList);
+			}
+			// 只查询本级
+			if (DataScopeTypeEnum.OWN_LEVEL.getType() == dsType) {
+				deptIds.add(user.getDeptId());
 			}
-			return invocation.proceed();
 		}
+		String join = CollectionUtil.join(deptIds, ",");
+		originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")";
+		metaObject.setValue("delegate.boundSql.sql", originalSql);
+		return invocation.proceed();
 	}
 
 	/**

+ 60 - 0
pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/enums/DataScopeTypeEnum.java

@@ -0,0 +1,60 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.data.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author lengleng
+ * @date 2018/12/26
+ * <p>
+ * 数据权限类型
+ */
+@Getter
+@AllArgsConstructor
+public enum DataScopeTypeEnum {
+	/**
+	 * 查询全部数据
+	 */
+	ALL(0, "全部"),
+
+	/**
+	 * 自定义
+	 */
+	CUSTOM(1, "自定义"),
+
+	/**
+	 * 本级及子级
+	 */
+	OWN_CHILD_LEVEL(2, "本级及子级"),
+
+	/**
+	 * 本级
+	 */
+	OWN_LEVEL(3, "本级");
+
+	/**
+	 * 类型
+	 */
+	private final int type;
+	/**
+	 * 描述
+	 */
+	private final String description;
+}

+ 24 - 29
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/config/MybatisPlusConfigurer.java

@@ -15,73 +15,68 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.act.config;
+package com.pig4cloud.pigx.common.data.mybatis;
 
 import com.baomidou.mybatisplus.core.injector.ISqlInjector;
 import com.baomidou.mybatisplus.core.parser.ISqlParser;
 import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
 import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
-import lombok.extern.slf4j.Slf4j;
-import net.sf.jsqlparser.expression.Expression;
-import net.sf.jsqlparser.expression.LongValue;
+import com.pig4cloud.pigx.common.data.datascope.DataScopeInterceptor;
+import com.pig4cloud.pigx.common.data.tenant.PigxTenantHandler;
 import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import javax.sql.DataSource;
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * @author lengleng
- * @date 2018/9/27
- * mybatis-plus 配置
+ * @date 2017/10/29
  */
-@Slf4j
 @Configuration
-@MapperScan("com.pig4cloud.pigx.act.mapper")
-public class MybatisPlusConfigurer {
+@MapperScan("com.pig4cloud.pigx.*.mapper")
+public class MybatisPlusConfig {
+
 	/**
 	 * 分页插件
 	 *
 	 * @return PaginationInterceptor
 	 */
 	@Bean
+	@ConditionalOnMissingBean
 	public PaginationInterceptor paginationInterceptor() {
 		PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
 		List<ISqlParser> sqlParserList = new ArrayList<>();
 		TenantSqlParser tenantSqlParser = new TenantSqlParser();
-		tenantSqlParser.setTenantHandler(new TenantHandler() {
-			@Override
-			public Expression getTenantId() {
-				Integer tenantId = TenantContextHolder.getTenantId();
-				log.debug("当前租户为 >> {}", tenantId);
-				return new LongValue(tenantId);
-			}
-
-			@Override
-			public String getTenantIdColumn() {
-				return "tenant_id";
-			}
-
-			@Override
-			public boolean doTableFilter(String tableName) {
-				return false;
-			}
-		});
+		tenantSqlParser.setTenantHandler(new PigxTenantHandler());
 		sqlParserList.add(tenantSqlParser);
 		paginationInterceptor.setSqlParserList(sqlParserList);
 		return paginationInterceptor;
 	}
 
+	/**
+	 * 数据权限插件
+	 *
+	 * @param dataSource 数据源
+	 * @return DataScopeInterceptor
+	 */
+	@Bean
+	@ConditionalOnMissingBean
+	public DataScopeInterceptor dataScopeInterceptor(DataSource dataSource) {
+		return new DataScopeInterceptor(dataSource);
+	}
+
 	/**
 	 * 逻辑删除插件
 	 *
 	 * @return LogicSqlInjector
 	 */
 	@Bean
+	@ConditionalOnMissingBean
 	public ISqlInjector sqlInjector() {
 		return new LogicSqlInjector();
 	}

+ 1 - 1
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignTenantConfiguration.java

@@ -15,7 +15,7 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.security.feign;
+package com.pig4cloud.pigx.common.data.tenant;
 
 import feign.RequestInterceptor;
 import org.springframework.context.annotation.Bean;

+ 1 - 2
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/PigxFeignTenantInterceptor.java

@@ -15,10 +15,9 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.security.feign;
+package com.pig4cloud.pigx.common.data.tenant;
 
 import com.pig4cloud.pigx.common.core.constant.CommonConstants;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
 import feign.RequestInterceptor;
 import feign.RequestTemplate;
 import lombok.extern.slf4j.Slf4j;

+ 69 - 0
pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/tenant/PigxTenantHandler.java

@@ -0,0 +1,69 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.data.tenant;
+
+import cn.hutool.core.util.ArrayUtil;
+import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.LongValue;
+
+/**
+ * @author lengleng
+ * @date 2018-12-26
+ * <p>
+ * 租户维护处理器
+ */
+@Slf4j
+public class PigxTenantHandler implements TenantHandler {
+	private static final String[] TENANT_TABLES = new String[]{"sys_user", "sys_role", "sys_dept",
+			"sys_log", "sys_social_details", "sys_dict", "sys_log", "oa_leave_bill"};
+
+	/**
+	 * 获取租户值
+	 *
+	 * @return 租户值
+	 */
+	@Override
+	public Expression getTenantId() {
+		Integer tenantId = TenantContextHolder.getTenantId();
+		log.debug("当前租户为 >> {}", tenantId);
+		return new LongValue(tenantId);
+	}
+
+	/**
+	 * 获取租户字段名
+	 *
+	 * @return 租户字段名
+	 */
+	@Override
+	public String getTenantIdColumn() {
+		return "tenant_id";
+	}
+
+	/**
+	 * 根据表名判断是否进行过滤
+	 *
+	 * @param tableName 表名
+	 * @return 是否进行过滤
+	 */
+	@Override
+	public boolean doTableFilter(String tableName) {
+		return !ArrayUtil.contains(TENANT_TABLES, tableName);
+	}
+}

+ 1 - 1
pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/TenantContextHolder.java

@@ -15,7 +15,7 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.core.util;
+package com.pig4cloud.pigx.common.data.tenant;
 
 import com.alibaba.ttl.TransmittableThreadLocal;
 import lombok.experimental.UtilityClass;

+ 1 - 2
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/filter/TenantContextHolderFilter.java

@@ -15,11 +15,10 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.common.security.filter;
+package com.pig4cloud.pigx.common.data.tenant;
 
 import cn.hutool.core.util.StrUtil;
 import com.pig4cloud.pigx.common.core.constant.CommonConstants;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.core.Ordered;
 import org.springframework.core.annotation.Order;

+ 7 - 0
pigx-common/pigx-common-data/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,7 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+    com.pig4cloud.pigx.common.data.cache.RedisTemplateConfig,\
+    com.pig4cloud.pigx.common.data.cache.RedisCacheManagerConfig,\
+    com.pig4cloud.pigx.common.data.cache.RedisCacheAutoConfiguration,\
+    com.pig4cloud.pigx.common.data.tenant.TenantContextHolderFilter,\
+    com.pig4cloud.pigx.common.data.tenant.PigxFeignTenantConfiguration,\
+    com.pig4cloud.pigx.common.data.mybatis.MybatisPlusConfig

+ 2 - 2
pigx-common/pigx-common-gateway/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-gateway</artifactId>
@@ -36,7 +36,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>

+ 4 - 0
pigx-common/pigx-common-gateway/src/main/java/com/pig4cloud/pigx/common/gateway/support/RedisRouteDefinitionWriter.java

@@ -26,6 +26,7 @@ import org.springframework.cloud.gateway.route.RouteDefinition;
 import org.springframework.cloud.gateway.route.RouteDefinitionRepository;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
 import org.springframework.stereotype.Component;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
@@ -51,6 +52,7 @@ public class RedisRouteDefinitionWriter implements RouteDefinitionRepository {
 			RouteDefinitionVo vo = new RouteDefinitionVo();
 			BeanUtils.copyProperties(r, vo);
 			log.info("保存路由信息{}", vo);
+			redisTemplate.setKeySerializer(new StringRedisSerializer());
 			redisTemplate.opsForHash().put(CommonConstants.ROUTE_KEY, r.getId(), vo);
 			return Mono.empty();
 		});
@@ -60,6 +62,7 @@ public class RedisRouteDefinitionWriter implements RouteDefinitionRepository {
 	public Mono<Void> delete(Mono<String> routeId) {
 		routeId.subscribe(id -> {
 			log.info("删除路由信息{}", id);
+			redisTemplate.setKeySerializer(new StringRedisSerializer());
 			redisTemplate.opsForHash().delete(CommonConstants.ROUTE_KEY, id);
 		});
 		return Mono.empty();
@@ -73,6 +76,7 @@ public class RedisRouteDefinitionWriter implements RouteDefinitionRepository {
 	 */
 	@Override
 	public Flux<RouteDefinition> getRouteDefinitions() {
+		redisTemplate.setKeySerializer(new StringRedisSerializer());
 		redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(RouteDefinitionVo.class));
 		List<RouteDefinitionVo> values = redisTemplate.opsForHash().values(CommonConstants.ROUTE_KEY);
 		List<RouteDefinition> definitionList = new ArrayList<>();

+ 1 - 1
pigx-common/pigx-common-job/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-job</artifactId>

+ 3 - 3
pigx-common/pigx-common-log/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-log</artifactId>
@@ -38,13 +38,13 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--UPMS接口模块-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-upms-api</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--安全依赖获取上下文信息-->
 		<dependency>

+ 24 - 0
pigx-common/pigx-common-minio/pom.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.pig4cloud</groupId>
+		<artifactId>pigx-common</artifactId>
+		<version>2.1.0</version>
+	</parent>
+
+	<artifactId>pigx-common-minio</artifactId>
+	<packaging>jar</packaging>
+
+	<description>pigx 文件系统依赖</description>
+
+	<dependencies>
+		<dependency>
+			<groupId>io.minio</groupId>
+			<artifactId>minio</artifactId>
+			<version>${minio.version}</version>
+		</dependency>
+	</dependencies>
+</project>

+ 21 - 26
pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/config/MybatisPlusConfigurer.java

@@ -15,39 +15,34 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.codegen.config;
+package com.pig4cloud.common.minio;
 
-import com.baomidou.mybatisplus.core.injector.ISqlInjector;
-import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.mybatis.spring.annotation.MapperScan;
+import com.pig4cloud.common.minio.service.MinioTemplate;
+import lombok.AllArgsConstructor;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
 
 /**
+ * minio 自动配置类
+ *
  * @author lengleng
- * @date 2017/10/29
  */
-@Configuration
-@MapperScan("com.pig4cloud.pigx.codegen.mapper")
-public class MybatisPlusConfigurer {
-	/**
-	 * 分页插件
-	 *
-	 * @return PaginationInterceptor
-	 */
-	@Bean
-	public PaginationInterceptor paginationInterceptor() {
-		return new PaginationInterceptor();
-	}
+@AllArgsConstructor
+@EnableConfigurationProperties({MinioProperties.class})
+public class MinioAutoConfiguration {
+	private final MinioProperties properties;
 
-	/**
-	 * 逻辑删除插件
-	 *
-	 * @return LogicSqlInjector
-	 */
 	@Bean
-	public ISqlInjector sqlInjector() {
-		return new LogicSqlInjector();
+	@ConditionalOnMissingBean(MinioTemplate.class)
+	@ConditionalOnProperty(name = "minio.url")
+	MinioTemplate template() {
+		return new MinioTemplate(
+				properties.getUrl(),
+				properties.getAccessKey(),
+				properties.getSecretKey()
+		);
 	}
+
 }

+ 18 - 23
pigx-visual/pigx-daemon/src/main/java/com/pig4cloud/pigx/daemon/config/MybatisPlusConfigurer.java

@@ -15,39 +15,34 @@
  * Author: lengleng (wangiegie@gmail.com)
  */
 
-package com.pig4cloud.pigx.daemon.config;
+package com.pig4cloud.common.minio;
 
-import com.baomidou.mybatisplus.core.injector.ISqlInjector;
-import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 
 /**
+ * minio 配置信息
+ *
  * @author lengleng
- * @date 2017/10/29
  */
+@Data
 @Configuration
-@MapperScan("com.pig4cloud.pigx.daemon.mapper")
-public class MybatisPlusConfigurer {
+@ConfigurationProperties(prefix = "minio")
+public class MinioProperties {
 	/**
-	 * 分页插件
-	 *
-	 * @return PaginationInterceptor
+	 * minio 服务地址 http://ip:port
 	 */
-	@Bean
-	public PaginationInterceptor paginationInterceptor() {
-		return new PaginationInterceptor();
-	}
+	private String url;
 
 	/**
-	 * 逻辑删除插件
-	 *
-	 * @return LogicSqlInjector
+	 * 用户名
 	 */
-	@Bean
-	public ISqlInjector sqlInjector() {
-		return new LogicSqlInjector();
-	}
+	private String accessKey;
+
+	/**
+	 * 密码
+	 */
+	private String secretKey;
+
 }

+ 122 - 0
pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/http/MinioEndpoint.java

@@ -0,0 +1,122 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.common.minio.http;
+
+import com.pig4cloud.common.minio.service.MinioTemplate;
+import com.pig4cloud.common.minio.vo.MinioItem;
+import com.pig4cloud.common.minio.vo.MinioObject;
+import io.minio.messages.Bucket;
+import lombok.AllArgsConstructor;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * minio 对外提供服务端点
+ *
+ * @author lengleng
+ * <p>
+ * minio.endpoint.enable
+ */
+@ConditionalOnProperty(name = "minio.endpoint.enable", havingValue = "true")
+@RestController
+@AllArgsConstructor
+@RequestMapping("${minio.endpoint.name:/minio}")
+public class MinioEndpoint {
+	private final MinioTemplate template;
+
+	/**
+	 * Bucket Endpoints
+	 */
+	@PostMapping("/bucket/{bucketName}")
+	public Bucket createBucker(@PathVariable String bucketName) throws Exception {
+
+		template.createBucket(bucketName);
+		return template.getBucket(bucketName).get();
+
+	}
+
+	@GetMapping("/bucket")
+	public List<Bucket> getBuckets() throws Exception {
+		return template.getAllBuckets();
+	}
+
+	@GetMapping("/bucket/{bucketName}")
+	public Bucket getBucket(@PathVariable String bucketName) throws Exception {
+		return template.getBucket(bucketName).orElseThrow(() -> new IllegalArgumentException("Bucket Name not found!"));
+	}
+
+	@DeleteMapping("/bucket/{bucketName}")
+	@ResponseStatus(HttpStatus.ACCEPTED)
+	public void deleteBucket(@PathVariable String bucketName) throws Exception {
+
+		template.removeBucket(bucketName);
+	}
+
+	/**
+	 * Object Endpoints
+	 */
+
+	@PostMapping("/object/{bucketName}")
+	public MinioObject createObject(@RequestBody MultipartFile object, @PathVariable String bucketName) throws Exception {
+		String name = object.getOriginalFilename();
+		template.putObject(bucketName, name, object.getInputStream(), object.getSize(), object.getContentType());
+		return new MinioObject(template.getObjectInfo(bucketName, name));
+
+	}
+
+	@PostMapping("/object/{bucketName}/{objectName}")
+	public MinioObject createObject(@RequestBody MultipartFile object, @PathVariable String bucketName, @PathVariable String objectName) throws Exception {
+		template.putObject(bucketName, objectName, object.getInputStream(), object.getSize(), object.getContentType());
+		return new MinioObject(template.getObjectInfo(bucketName, objectName));
+
+	}
+
+
+	@GetMapping("/object/{bucketName}/{objectName}")
+	public List<MinioItem> filterObject(@PathVariable String bucketName, @PathVariable String objectName) throws Exception {
+
+		return template.getAllObjectsByPrefix(bucketName, objectName, true);
+
+	}
+
+	@GetMapping("/object/{bucketName}/{objectName}/{expires}")
+	public Map<String, Object> getObject(@PathVariable String bucketName, @PathVariable String objectName, @PathVariable Integer expires) throws Exception {
+		Map<String, Object> responseBody = new HashMap<>(8);
+		// Put Object info
+		responseBody.put("bucket", bucketName);
+		responseBody.put("object", objectName);
+		responseBody.put("url", template.getObjectURL(bucketName, objectName, expires));
+		responseBody.put("expires", expires);
+		return responseBody;
+	}
+
+	@DeleteMapping("/object/{bucketName}/{objectName}/")
+	@ResponseStatus(HttpStatus.ACCEPTED)
+	public void deleteObject(@PathVariable String bucketName, @PathVariable String objectName) throws Exception {
+
+		template.removeObject(bucketName, objectName);
+	}
+
+
+}

+ 189 - 0
pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/service/MinioTemplate.java

@@ -0,0 +1,189 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.common.minio.service;
+
+import com.pig4cloud.common.minio.vo.MinioItem;
+import io.minio.MinioClient;
+import io.minio.ObjectStat;
+import io.minio.Result;
+import io.minio.messages.Bucket;
+import io.minio.messages.Item;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * minio 交互类
+ *
+ * @author lengleng
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+public class MinioTemplate {
+
+	private String endpoint;
+	private String accessKey;
+	private String secretKey;
+
+
+	/**
+	 * 创建bucket
+	 *
+	 * @param bucketName bucket名称
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#makeBucket
+	 */
+	public void createBucket(String bucketName) throws Exception {
+		MinioClient client = getMinioClient();
+		if (!client.bucketExists(bucketName)) {
+			client.makeBucket(bucketName);
+		}
+	}
+
+	/**
+	 * 获取全部bucket
+	 * <p>
+	 * https://docs.minio.io/cn/java-client-api-reference.html#listBuckets
+	 */
+	public List<Bucket> getAllBuckets() throws Exception {
+		return getMinioClient().listBuckets();
+	}
+
+	/**
+	 * @param bucketName bucket名称
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#listBuckets
+	 */
+	public Optional<Bucket> getBucket(String bucketName) throws Exception {
+		return getMinioClient().listBuckets().stream().filter(b -> b.name().equals(bucketName)).findFirst();
+	}
+
+	/**
+	 * @param bucketName bucket名称
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#removeBucket
+	 */
+	public void removeBucket(String bucketName) throws Exception {
+		getMinioClient().removeBucket(bucketName);
+	}
+
+	/**
+	 * 根据文件前置查询文件
+	 *
+	 * @param bucketName bucket名称
+	 * @param prefix     前缀
+	 * @param recursive  是否递归查询
+	 * @return
+	 * @throws Exception
+	 */
+	public List<MinioItem> getAllObjectsByPrefix(String bucketName, String prefix, boolean recursive) throws Exception {
+		List objectList = new ArrayList();
+		Iterable<Result<Item>> objectsIterator = getMinioClient()
+				.listObjects(bucketName, prefix, recursive);
+
+		while (objectsIterator.iterator().hasNext()) {
+			objectList.add(objectsIterator.iterator().next().get());
+		}
+		return objectList;
+	}
+
+	/**
+	 * 获取文件外链
+	 *
+	 * @param bucketName bucket名称
+	 * @param objectName 文件名称
+	 * @param expires    过期时间 <=7
+	 * @return url
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#getObject
+	 */
+	public String getObjectURL(String bucketName, String objectName, Integer expires) throws Exception {
+		return getMinioClient().presignedGetObject(bucketName, objectName, expires);
+	}
+
+	/**
+	 * 获取文件
+	 *
+	 * @param bucketName bucket名称
+	 * @param objectName 文件名称
+	 * @return 二进制流
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#getObject
+	 */
+	public InputStream getObject(String bucketName, String objectName) throws Exception {
+		return getMinioClient().getObject(bucketName, objectName);
+	}
+
+	/**
+	 * 上传文件
+	 *
+	 * @param bucketName bucket名称
+	 * @param objectName 文件名称
+	 * @param stream     文件流
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#putObject
+	 */
+	public void putObject(String bucketName, String objectName, InputStream stream) throws Exception {
+		getMinioClient().putObject(bucketName, objectName, stream, stream.available(), "application/octet-stream");
+	}
+
+	/**
+	 * 上传文件
+	 *
+	 * @param bucketName  bucket名称
+	 * @param objectName  文件名称
+	 * @param stream      文件流
+	 * @param size        大小
+	 * @param contextType 类型
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#putObject
+	 */
+	public void putObject(String bucketName, String objectName, InputStream stream, long size, String contextType) throws Exception {
+		getMinioClient().putObject(bucketName, objectName, stream, size, contextType);
+	}
+
+	/**
+	 * 获取文件信息
+	 *
+	 * @param bucketName bucket名称
+	 * @param objectName 文件名称
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#statObject
+	 */
+	public ObjectStat getObjectInfo(String bucketName, String objectName) throws Exception {
+		return getMinioClient().statObject(bucketName, objectName);
+	}
+
+	/**
+	 * 删除文件
+	 *
+	 * @param bucketName bucket名称
+	 * @param objectName 文件名称
+	 * @throws Exception https://docs.minio.io/cn/java-client-api-reference.html#removeObject
+	 */
+	public void removeObject(String bucketName, String objectName) throws Exception {
+		getMinioClient().removeObject(bucketName, objectName);
+	}
+
+
+	/**
+	 * 获取minio 原生客户端
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	public MinioClient getMinioClient() throws Exception {
+		return new MinioClient(endpoint, accessKey, secretKey);
+	}
+}

+ 53 - 0
pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/vo/MinioItem.java

@@ -0,0 +1,53 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.common.minio.vo;
+
+import io.minio.messages.Item;
+import io.minio.messages.Owner;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * minio 桶中的对象信息
+ *
+ * @author lengleng
+ */
+@Data
+@AllArgsConstructor
+public class MinioItem {
+
+	private String objectName;
+	private Date lastModified;
+	private String etag;
+	private Long size;
+	private String storageClass;
+	private Owner owner;
+	private String type;
+
+	public MinioItem(Item item) {
+		this.objectName = item.objectName();
+		this.lastModified = item.lastModified();
+		this.etag = item.etag();
+		this.size = (long) item.size();
+		this.storageClass = item.storageClass();
+		this.owner = item.owner();
+		this.type = item.isDir() ? "directory" : "file";
+	}
+}

+ 53 - 0
pigx-common/pigx-common-minio/src/main/java/com/pig4cloud/common/minio/vo/MinioObject.java

@@ -0,0 +1,53 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.common.minio.vo;
+
+import io.minio.ObjectStat;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.Date;
+
+
+/**
+ * 存储对象的元数据
+ *
+ * @author lengleng
+ */
+@Data
+@AllArgsConstructor
+public class MinioObject {
+	private String bucketName;
+	private String name;
+	private Date createdTime;
+	private Long length;
+	private String etag;
+	private String contentType;
+	private String matDesc;
+
+	public MinioObject(ObjectStat os) {
+		this.bucketName = os.bucketName();
+		this.name = os.name();
+		this.createdTime = os.createdTime();
+		this.length = os.length();
+		this.etag = os.etag();
+		this.contentType = os.contentType();
+		this.matDesc = os.matDesc();
+	}
+
+}

+ 2 - 0
pigx-common/pigx-common-minio/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+  com.pig4cloud.common.minio.MinioAutoConfiguration

+ 3 - 3
pigx-common/pigx-common-security/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-security</artifactId>
@@ -38,7 +38,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--安全模块-->
 		<dependency>
@@ -49,7 +49,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-upms-api</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 	</dependencies>
 </project>

+ 63 - 0
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxPreAuthenticationChecks.java

@@ -0,0 +1,63 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.security.component;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.security.authentication.AccountExpiredException;
+import org.springframework.security.authentication.DisabledException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.core.SpringSecurityMessageSource;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsChecker;
+
+/**
+ * @author lengleng
+ * @date 2019-01-02
+ */
+@Slf4j
+public class PigxPreAuthenticationChecks implements UserDetailsChecker {
+	private MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
+
+	@Override
+	public void check(UserDetails user) {
+		if (!user.isAccountNonLocked()) {
+			log.debug("User account is locked");
+
+			throw new LockedException(messages.getMessage(
+					"AbstractUserDetailsAuthenticationProvider.locked",
+					"User account is locked"));
+		}
+
+		if (!user.isEnabled()) {
+			log.debug("User account is disabled");
+
+			throw new DisabledException(messages.getMessage(
+					"AbstractUserDetailsAuthenticationProvider.disabled",
+					"User is disabled"));
+		}
+
+		if (!user.isAccountNonExpired()) {
+			log.debug("User account is expired");
+
+			throw new AccountExpiredException(messages.getMessage(
+					"AbstractUserDetailsAuthenticationProvider.expired",
+					"User account has expired"));
+		}
+	}
+}

+ 2 - 2
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/ResourceAuthExceptionEntryPoint.java

@@ -51,9 +51,9 @@ public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint
 		response.setCharacterEncoding(CommonConstants.UTF8);
 		response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
 		R<String> result = new R<>();
-		result.setCode(HttpStatus.HTTP_UNAUTHORIZED);
+		result.setCode(CommonConstants.FAIL);
 		if (authException != null) {
-			result.setMsg("error");
+			result.setMsg(authException.getMessage());
 			result.setData(authException.getMessage());
 		}
 		response.setStatus(HttpStatus.HTTP_UNAUTHORIZED);

+ 0 - 1
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileAuthenticationFilter.java

@@ -86,7 +86,6 @@ public class MobileAuthenticationFilter extends AbstractAuthenticationProcessing
 			authResult = this.getAuthenticationManager().authenticate(mobileAuthenticationToken);
 
 			logger.debug("Authentication success: " + authResult);
-			eventPublisher.publishAuthenticationSuccess(authResult);
 			SecurityContextHolder.getContext().setAuthentication(authResult);
 
 		} catch (Exception failed) {

+ 9 - 3
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileAuthenticationProvider.java

@@ -17,6 +17,7 @@
 
 package com.pig4cloud.pigx.common.security.mobile;
 
+import com.pig4cloud.pigx.common.security.component.PigxPreAuthenticationChecks;
 import com.pig4cloud.pigx.common.security.service.PigxUserDetailsService;
 import lombok.Getter;
 import lombok.Setter;
@@ -28,6 +29,7 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.SpringSecurityMessageSource;
 import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsChecker;
 
 /**
  * @author lengleng
@@ -38,6 +40,8 @@ import org.springframework.security.core.userdetails.UserDetails;
 @Slf4j
 public class MobileAuthenticationProvider implements AuthenticationProvider {
 	private MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
+	private UserDetailsChecker detailsChecker = new PigxPreAuthenticationChecks();
+
 	@Getter
 	@Setter
 	private PigxUserDetailsService userDetailsService;
@@ -52,11 +56,13 @@ public class MobileAuthenticationProvider implements AuthenticationProvider {
 			log.debug("Authentication failed: no credentials provided");
 
 			throw new BadCredentialsException(messages.getMessage(
-				"AbstractUserDetailsAuthenticationProvider.noopBindAccount",
-				"Noop Bind Account"));
-
+					"AbstractUserDetailsAuthenticationProvider.noopBindAccount",
+					"Noop Bind Account"));
 		}
 
+		// 检查账号状态
+		detailsChecker.check(userDetails);
+
 		MobileAuthenticationToken authenticationToken = new MobileAuthenticationToken(userDetails, userDetails.getAuthorities());
 		authenticationToken.setDetails(mobileAuthenticationToken.getDetails());
 		return authenticationToken;

+ 14 - 4
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java

@@ -27,6 +27,8 @@ import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
 import com.pig4cloud.pigx.common.core.util.R;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.userdetails.UserDetails;
@@ -48,6 +50,7 @@ import java.util.Set;
 @AllArgsConstructor
 public class PigxUserDetailsServiceImpl implements PigxUserDetailsService {
 	private final RemoteUserService remoteUserService;
+	private final CacheManager cacheManager;
 
 	/**
 	 * 用户密码登录
@@ -58,8 +61,15 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService {
 	 */
 	@Override
 	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+		Cache cache = cacheManager.getCache("user_details");
+		if (cache != null && cache.get(username) != null) {
+			return (PigxUser) cache.get(username).get();
+		}
+
 		R<UserInfo> result = remoteUserService.info(username, SecurityConstants.FROM_IN);
-		return getUserDetails(result);
+		UserDetails userDetails = getUserDetails(result);
+		cache.put(username, userDetails);
+		return userDetails;
 	}
 
 
@@ -96,12 +106,12 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService {
 
 		}
 		Collection<? extends GrantedAuthority> authorities
-			= AuthorityUtils.createAuthorityList(dbAuthsSet.toArray(new String[0]));
+				= AuthorityUtils.createAuthorityList(dbAuthsSet.toArray(new String[0]));
 		SysUser user = info.getSysUser();
-		boolean enabled = StrUtil.equals(user.getDelFlag(), CommonConstants.STATUS_NORMAL);
+		boolean enabled = StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL);
 		// 构造security用户
 
 		return new PigxUser(user.getUserId(), user.getDeptId(), user.getTenantId(), user.getUsername(), SecurityConstants.BCRYPT + user.getPassword(), enabled,
-			true, true, !CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities);
+				true, true, !CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities);
 	}
 }

+ 0 - 2
pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories

@@ -1,5 +1,3 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-  com.pig4cloud.pigx.common.security.filter.TenantContextHolderFilter,\
   com.pig4cloud.pigx.common.security.feign.PigxFeignClientConfiguration,\
-  com.pig4cloud.pigx.common.security.feign.PigxFeignTenantConfiguration,\
   com.pig4cloud.pigx.common.security.service.PigxUserDetailsServiceImpl

+ 1 - 1
pigx-common/pigx-common-swagger/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-swagger</artifactId>

+ 2 - 2
pigx-common/pigx-common-transaction/pom.xml

@@ -5,7 +5,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-common</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common-transaction</artifactId>
@@ -17,7 +17,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--lcn 模块端控制依赖-->
 		<dependency>

+ 3 - 2
pigx-common/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-common</artifactId>
@@ -33,11 +33,12 @@
 	<description>pigx 公共聚合模块</description>
 
 	<modules>
-		<module>pigx-common-cache</module>
 		<module>pigx-common-core</module>
+		<module>pigx-common-data</module>
 		<module>pigx-common-gateway</module>
 		<module>pigx-common-job</module>
 		<module>pigx-common-log</module>
+		<module>pigx-common-minio</module>
 		<module>pigx-common-security</module>
 		<module>pigx-common-swagger</module>
 		<module>pigx-common-transaction</module>

+ 1 - 1
pigx-config/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-config</artifactId>

+ 1 - 1
pigx-config/src/main/resources/config/pigx-auth-dev.yml

@@ -5,7 +5,7 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     username: root
     password: root
-    url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
   freemarker:
     allow-request-override: false
     allow-session-override: false

+ 7 - 0
pigx-config/src/main/resources/config/pigx-upms-biz-dev.yml

@@ -33,6 +33,13 @@ swagger:
         description: 'read all'
       - scope: 'write'
         description: 'access all'
+
+# 文件系统
+minio:
+  url: http://139.224.200.249:9090
+  access-key: lengleng
+  secret-key: lengleng
+
 # Logger Config
 logging:
   level:

+ 1 - 1
pigx-eureka/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-eureka</artifactId>

+ 5 - 6
pigx-gateway/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-gateway</artifactId>
@@ -46,7 +46,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-gateway</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--配置中心客户端-->
 		<dependency>
@@ -63,13 +63,12 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--缓存-->
 		<dependency>
-			<groupId>com.pig4cloud</groupId>
-			<artifactId>pigx-common-cache</artifactId>
-			<version>2.0.0</version>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-redis</artifactId>
 		</dependency>
 		<!--接口文档-->
 		<dependency>

+ 5 - 5
pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ValidateCodeGatewayFilter.java

@@ -61,13 +61,13 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
 				return chain.filter(exchange);
 			}
 
-			// 终端设置不校验, 直接向下执行(1. 从请求参数中获取 2.从header取)
-			String clientId = request.getQueryParams().getFirst("client_id");
-			if (StrUtil.isNotBlank(clientId)
-					&& filterIgnorePropertiesConfig.getClients().contains(clientId)) {
+			// 刷新token,直接向下执行
+			String grantType = request.getQueryParams().getFirst("grant_type");
+			if (StrUtil.equals(SecurityConstants.REFRESH_TOKEN, grantType)) {
 				return chain.filter(exchange);
 			}
 
+			// 终端设置不校验, 直接向下执行
 			try {
 				String[] clientInfos = WebUtils.getClientId(request);
 				if (filterIgnorePropertiesConfig.getClients().contains(clientInfos[0])) {
@@ -83,7 +83,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
 					return response.writeWith(Mono.just(response.bufferFactory()
 							.wrap(objectMapper.writeValueAsBytes(
 									R.builder().msg(e.getMessage())
-											.code(CommonConstant.FAIL).build()))));
+											.code(CommonConstants.FAIL).build()))));
 				} catch (JsonProcessingException e1) {
 					log.error("对象输出异常", e1);
 				}

+ 2 - 2
pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handler/HystrixFallbackHandler.java

@@ -17,7 +17,7 @@
 
 package com.pig4cloud.pigx.gateway.handler;
 
-import com.pig4cloud.pigx.common.core.constant.CommonConstant;
+import com.pig4cloud.pigx.common.core.constant.CommonConstants;
 import com.pig4cloud.pigx.common.core.util.R;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.HttpStatus;
@@ -51,7 +51,7 @@ public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> {
 				.contentType(MediaType.APPLICATION_JSON_UTF8)
 				.body(BodyInserters.fromObject(R.builder()
 						.msg("服务异常")
-						.code(CommonConstant.FAIL)
+						.code(CommonConstants.FAIL)
 						.build()));
 	}
 }

+ 8 - 2
pigx-upms/pigx-upms-api/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-upms</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-upms-api</artifactId>
@@ -38,7 +38,13 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
+		</dependency>
+		<!--mybatis plus extension,包含了mybatis plus core-->
+		<dependency>
+			<groupId>com.baomidou</groupId>
+			<artifactId>mybatis-plus-extension</artifactId>
+			<version>${mybatis-plus.version}</version>
 		</dependency>
 	</dependencies>
 </project>

+ 0 - 1
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserInfo.java

@@ -21,7 +21,6 @@ package com.pig4cloud.pigx.admin.api.dto;
 
 import com.pig4cloud.pigx.admin.api.entity.SysUser;
 import lombok.Data;
-import lombok.ToString;
 
 import java.io.Serializable;
 

+ 6 - 0
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRole.java

@@ -28,6 +28,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
@@ -58,6 +59,11 @@ public class SysRole extends Model<SysRole> {
 	@NotBlank(message = "角色描述 不能为空")
 	private String roleDesc;
 
+	@NotNull(message = "数据权限类型 不能为空")
+	private Integer dsType;
+
+	private String dsScope;
+
 	private LocalDateTime createTime;
 	private LocalDateTime updateTime;
 	/**

+ 2 - 4
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java

@@ -37,19 +37,17 @@ public interface RemoteTokenService {
 	 * 分页查询token 信息
 	 *
 	 * @param params 分页参数
-	 * @param from   内部调用标志
 	 * @return page
 	 */
 	@PostMapping("/token/page")
-	R<Page> getTokenPage(@RequestBody Map<String, Object> params, @RequestHeader(SecurityConstants.FROM) String from);
+	R<Page> getTokenPage(@RequestBody Map<String, Object> params,@RequestHeader(SecurityConstants.FROM) String from);
 
 	/**
 	 * 删除token
 	 *
 	 * @param token token
-	 * @param from  调用标志
 	 * @return
 	 */
 	@DeleteMapping("/token/{token}")
-	R<Boolean> removeTokenById(@PathVariable("token") String token, @RequestHeader(SecurityConstants.FROM) String from);
+	R<Boolean> removeTokenById(@PathVariable("token") String token,@RequestHeader(SecurityConstants.FROM) String from);
 }

+ 1 - 1
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java

@@ -54,7 +54,7 @@ public class RemoteTokenServiceFallbackImpl implements RemoteTokenService {
 	 * 删除token
 	 *
 	 * @param token
-	 * @param from
+	 * @param from  内部调用标志
 	 * @return
 	 */
 	@Override

+ 20 - 9
pigx-upms/pigx-upms-biz/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-upms</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-upms-biz</artifactId>
@@ -37,25 +37,36 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-upms-api</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--日志处理-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-log</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
+		</dependency>
+		<!--数据库操作-->
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>${mysql.connector.version}</version>
 		</dependency>
-		<!--缓存依赖-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
-			<artifactId>pigx-common-cache</artifactId>
-			<version>2.0.0</version>
+			<artifactId>pigx-common-data</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<!--swagger-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-swagger</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
+		</dependency>
+		<!--文件系统-->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-minio</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<!--eureka 客户端-->
 		<dependency>
@@ -71,13 +82,13 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-security</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--支持动态路由配置 -->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-gateway</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--mybatis-->
 		<dependency>

+ 0 - 103
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/MybatisPlusConfigurer.java

@@ -1,103 +0,0 @@
-/*
- *
- *      Copyright (c) 2018-2025, lengleng All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the pig4cloud.com developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: lengleng (wangiegie@gmail.com)
- *
- */
-
-package com.pig4cloud.pigx.admin.config;
-
-import cn.hutool.core.util.ArrayUtil;
-import com.baomidou.mybatisplus.core.injector.ISqlInjector;
-import com.baomidou.mybatisplus.core.parser.ISqlParser;
-import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
-import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
-import com.pig4cloud.pigx.common.core.datascope.DataScopeInterceptor;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
-import lombok.extern.slf4j.Slf4j;
-import net.sf.jsqlparser.expression.Expression;
-import net.sf.jsqlparser.expression.LongValue;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author lengleng
- * @date 2017/10/29
- */
-@Slf4j
-@Configuration
-@MapperScan("com.pig4cloud.pigx.admin.mapper")
-public class MybatisPlusConfigurer {
-	private static final String[] IGNORETABLES = new String[]{"sys_dept_relation", "sys_role_dept", "sys_role_menu", "sys_user_role", "sys_route_conf", "sys_menu"};
-
-	/**
-	 * 分页插件
-	 *
-	 * @return PaginationInterceptor
-	 */
-	@Bean
-	public PaginationInterceptor paginationInterceptor() {
-		PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
-		List<ISqlParser> sqlParserList = new ArrayList<>();
-		TenantSqlParser tenantSqlParser = new TenantSqlParser();
-		tenantSqlParser.setTenantHandler(new TenantHandler() {
-			@Override
-			public Expression getTenantId() {
-				Integer tenantId = TenantContextHolder.getTenantId();
-				log.debug("当前租户为 >> {}", tenantId);
-				return new LongValue(tenantId);
-			}
-
-			@Override
-			public String getTenantIdColumn() {
-				return "tenant_id";
-			}
-
-			@Override
-			public boolean doTableFilter(String tableName) {
-				return ArrayUtil.contains(IGNORETABLES, tableName);
-			}
-		});
-		sqlParserList.add(tenantSqlParser);
-		paginationInterceptor.setSqlParserList(sqlParserList);
-		return paginationInterceptor;
-	}
-
-	/**
-	 * 数据权限插件
-	 *
-	 * @return DataScopeInterceptor
-	 */
-	@Bean
-	public DataScopeInterceptor dataScopeInterceptor() {
-		return new DataScopeInterceptor();
-	}
-
-	/**
-	 * 逻辑删除插件
-	 *
-	 * @return LogicSqlInjector
-	 */
-	@Bean
-	public ISqlInjector sqlInjector() {
-		return new LogicSqlInjector();
-	}
-}

+ 91 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/FileController.java

@@ -0,0 +1,91 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.controller;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import com.pig4cloud.common.minio.service.MinioTemplate;
+import com.pig4cloud.pigx.common.core.constant.CommonConstants;
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018-12-30
+ * <p>
+ * 文件管理
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping("/file")
+public class FileController {
+	private final MinioTemplate minioTemplate;
+
+	/**
+	 * 上传文件
+	 * 文件名采用uuid,避免原始文件名中带"-"符号导致下载的时候解析出现异常
+	 * @param file 资源
+	 * @return R(bucketName, filename)
+	 */
+	@PostMapping("/upload")
+	public R upload(@RequestParam("file") MultipartFile file) {
+		String fileName = IdUtil.simpleUUID()+StrUtil.DOT+ FileUtil.extName(file.getOriginalFilename());
+		Map<String, String> resultMap = new HashMap<>(4);
+		resultMap.put("bucketName", CommonConstants.BUCKET_NAME);
+		resultMap.put("fileName", fileName);
+
+		try {
+			minioTemplate.putObject(CommonConstants.BUCKET_NAME, fileName, file.getInputStream());
+		} catch (Exception e) {
+			log.error("上传失败", e);
+			return R.builder().code(CommonConstants.FAIL)
+					.msg(e.getLocalizedMessage()).build();
+		}
+		return R.builder().data(resultMap).build();
+	}
+
+	/**
+	 * 获取文件
+	 *
+	 * @param fileName 文件空间/名称
+	 * @param response
+	 * @return
+	 */
+	@GetMapping("/{fileName}")
+	public void file(@PathVariable String fileName, HttpServletResponse response) {
+		String[] nameArray = StrUtil.split(fileName, StrUtil.DASHED);
+
+		try (InputStream inputStream = minioTemplate.getObject(nameArray[0], nameArray[1])) {
+			response.setContentType("application/octet-stream; charset=UTF-8");
+			IoUtil.copy(inputStream, response.getOutputStream());
+		} catch (Exception e) {
+			log.error("文件读取异常", e);
+		}
+	}
+}

+ 9 - 9
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/MenuController.java

@@ -62,12 +62,12 @@ public class MenuController {
 		// 获取符合条件的菜单
 		Set<MenuVO> all = new HashSet<>();
 		SecurityUtils.getRoles()
-			.forEach(roleId -> all.addAll(sysMenuService.findMenuByRoleId(roleId)));
+				.forEach(roleId -> all.addAll(sysMenuService.findMenuByRoleId(roleId)));
 		List<MenuTree> menuTreeList = all.stream()
-			.filter(menuVo -> CommonConstants.MENU.equals(menuVo.getType()))
-			.map(MenuTree::new)
-			.sorted(Comparator.comparingInt(MenuTree::getSort))
-			.collect(Collectors.toList());
+				.filter(menuVo -> CommonConstants.MENU.equals(menuVo.getType()))
+				.map(MenuTree::new)
+				.sorted(Comparator.comparingInt(MenuTree::getSort))
+				.collect(Collectors.toList());
 		return new R<>(TreeUtil.bulid(menuTreeList, -1));
 	}
 
@@ -90,9 +90,9 @@ public class MenuController {
 	@GetMapping("/tree/{roleId}")
 	public List getRoleTree(@PathVariable Integer roleId) {
 		return sysMenuService.findMenuByRoleId(roleId)
-			.stream()
-			.map(MenuVO::getMenuId)
-			.collect(Collectors.toList());
+				.stream()
+				.map(MenuVO::getMenuId)
+				.collect(Collectors.toList());
 	}
 
 	/**
@@ -129,7 +129,7 @@ public class MenuController {
 	@DeleteMapping("/{id}")
 	@PreAuthorize("@pms.hasPermission('sys_menu_del')")
 	public R removeById(@PathVariable Integer id) {
-		return new R<>(sysMenuService.removeMenuById(id));
+		return sysMenuService.removeMenuById(id);
 	}
 
 	/**

+ 4 - 2
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java

@@ -31,6 +31,8 @@ import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+
 /**
  * @author lengleng
  * @date 2017/11/5
@@ -63,7 +65,7 @@ public class RoleController {
 	@SysLog("添加角色")
 	@PostMapping
 	@PreAuthorize("@pms.hasPermission('sys_role_add')")
-	public R save(@RequestBody SysRole sysRole) {
+	public R save(@Valid @RequestBody SysRole sysRole) {
 		return new R<>(sysRoleService.save(sysRole));
 	}
 
@@ -76,7 +78,7 @@ public class RoleController {
 	@SysLog("修改角色")
 	@PutMapping
 	@PreAuthorize("@pms.hasPermission('sys_role_edit')")
-	public R update(@RequestBody SysRole sysRole) {
+	public R update(@Valid @RequestBody SysRole sysRole) {
 		return new R<>(sysRoleService.updateById(sysRole));
 	}
 

+ 6 - 6
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java

@@ -40,7 +40,7 @@ import javax.validation.Valid;
 
 /**
  * @author lengleng
- * @date 2017/10/28
+ * @date 2018/12/16
  */
 @RestController
 @AllArgsConstructor
@@ -57,12 +57,12 @@ public class UserController {
 	@GetMapping(value = {"/info"})
 	public R info() {
 		String username = SecurityUtils.getUser().getUsername();
-		SysUser sysUser = userService.getOne(Wrappers.<SysUser>query()
-			.lambda().eq(SysUser::getUsername, username));
-		if (sysUser == null) {
+		SysUser user = userService.getOne(Wrappers.<SysUser>query()
+				.lambda().eq(SysUser::getUsername, username));
+		if (user == null) {
 			return new R<>(Boolean.FALSE, "获取当前用户信息失败");
 		}
-		return new R<>(userService.findUserInfo(sysUser));
+		return new R<>(userService.findUserInfo(user));
 	}
 
 	/**
@@ -74,7 +74,7 @@ public class UserController {
 	@GetMapping("/info/{username}")
 	public R info(@PathVariable String username) {
 		SysUser user = userService.getOne(Wrappers.<SysUser>query()
-			.lambda().eq(SysUser::getUsername, username));
+				.lambda().eq(SysUser::getUsername, username));
 		if (user == null) {
 			return new R<>(Boolean.FALSE, String.format("用户信息为空 %s", username));
 		}

+ 5 - 5
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/SmsLoginHandler.java

@@ -55,14 +55,14 @@ public class SmsLoginHandler extends AbstractLoginHandler {
 	 */
 	@Override
 	public UserInfo info(String identify) {
-		SysUser sysUser = sysUserService
-			.getOne(Wrappers.<SysUser>query()
-				.lambda().eq(SysUser::getPhone, identify));
+		SysUser user = sysUserService
+				.getOne(Wrappers.<SysUser>query()
+						.lambda().eq(SysUser::getPhone, identify));
 
-		if (sysUser == null) {
+		if (user == null) {
 			log.info("手机号未注册:{}", identify);
 			return null;
 		}
-		return sysUserService.findUserInfo(sysUser);
+		return sysUserService.findUserInfo(user);
 	}
 }

+ 3 - 3
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/WeChatLoginHandler.java

@@ -75,14 +75,14 @@ public class WeChatLoginHandler extends AbstractLoginHandler {
 	 */
 	@Override
 	public UserInfo info(String openId) {
-		SysUser sysUser = sysUserService
+		SysUser user = sysUserService
 			.getOne(Wrappers.<SysUser>query()
 				.lambda().eq(SysUser::getWxOpenid, openId));
 
-		if (sysUser == null) {
+		if (user == null) {
 			log.info("微信未绑定:{}", openId);
 			return null;
 		}
-		return sysUserService.findUserInfo(sysUser);
+		return sysUserService.findUserInfo(user);
 	}
 }

+ 1 - 1
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java

@@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.pig4cloud.pigx.admin.api.dto.UserDTO;
 import com.pig4cloud.pigx.admin.api.entity.SysUser;
 import com.pig4cloud.pigx.admin.api.vo.UserVO;
-import com.pig4cloud.pigx.common.core.datascope.DataScope;
+import com.pig4cloud.pigx.common.data.datascope.DataScope;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;

+ 2 - 1
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysMenuService.java

@@ -23,6 +23,7 @@ package com.pig4cloud.pigx.admin.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.pig4cloud.pigx.admin.api.entity.SysMenu;
 import com.pig4cloud.pigx.admin.api.vo.MenuVO;
+import com.pig4cloud.pigx.common.core.util.R;
 
 import java.util.List;
 
@@ -49,7 +50,7 @@ public interface SysMenuService extends IService<SysMenu> {
 	 * @param id 菜单ID
 	 * @return 成功、失败
 	 */
-	Boolean removeMenuById(Integer id);
+	R removeMenuById(Integer id);
 
 	/**
 	 * 更新菜单信息

+ 16 - 12
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysMenuServiceImpl.java

@@ -19,6 +19,7 @@
 
 package com.pig4cloud.pigx.admin.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pig4cloud.pigx.admin.api.entity.SysMenu;
@@ -27,6 +28,8 @@ import com.pig4cloud.pigx.admin.api.vo.MenuVO;
 import com.pig4cloud.pigx.admin.mapper.SysMenuMapper;
 import com.pig4cloud.pigx.admin.mapper.SysRoleMenuMapper;
 import com.pig4cloud.pigx.admin.service.SysMenuService;
+import com.pig4cloud.pigx.common.core.constant.CommonConstants;
+import com.pig4cloud.pigx.common.core.util.R;
 import lombok.AllArgsConstructor;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
@@ -34,7 +37,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -58,20 +60,22 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	@CacheEvict(value = "menu_details", allEntries = true)
-	public Boolean removeMenuById(Integer id) {
+	public R removeMenuById(Integer id) {
 		// 查询父节点为当前节点的节点
-		List<Integer> menuIdList = this.list(Wrappers.<SysMenu>query()
-			.lambda().eq(SysMenu::getParentId, id))
-			.stream().map(SysMenu::getMenuId)
-			.collect(Collectors.toList());
+		List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query()
+				.lambda().eq(SysMenu::getParentId, id));
+		if (CollUtil.isNotEmpty(menuList)) {
+			return R.builder()
+					.code(CommonConstants.FAIL)
+					.msg("菜单含有下级不能删除").build();
+		}
+
+		sysRoleMenuMapper
+				.delete(Wrappers.<SysRoleMenu>query()
+						.lambda().eq(SysRoleMenu::getMenuId, id));
 
-		//删除关联ROLE_MENU 数据
-		menuIdList.add(id);
-		menuIdList.forEach(menu -> sysRoleMenuMapper
-			.delete(Wrappers.<SysRoleMenu>query()
-				.lambda().eq(SysRoleMenu::getMenuId, menu)));
 		//删除当前菜单及其子菜单
-		return this.removeByIds(menuIdList);
+		return new R(this.removeById(id));
 	}
 
 	@Override

+ 24 - 34
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java

@@ -33,15 +33,14 @@ import com.pig4cloud.pigx.admin.api.vo.UserVO;
 import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
 import com.pig4cloud.pigx.admin.service.*;
 import com.pig4cloud.pigx.common.core.constant.CommonConstants;
-import com.pig4cloud.pigx.common.core.datascope.DataScope;
 import com.pig4cloud.pigx.common.core.util.R;
+import com.pig4cloud.pigx.common.data.datascope.DataScope;
 import com.pig4cloud.pigx.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
@@ -83,12 +82,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 		sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
 		baseMapper.insert(sysUser);
 		List<SysUserRole> userRoleList = userDto.getRole()
-			.stream().map(roleId -> {
-				SysUserRole userRole = new SysUserRole();
-				userRole.setUserId(sysUser.getUserId());
-				userRole.setRoleId(roleId);
-				return userRole;
-			}).collect(Collectors.toList());
+				.stream().map(roleId -> {
+					SysUserRole userRole = new SysUserRole();
+					userRole.setUserId(sysUser.getUserId());
+					userRole.setRoleId(roleId);
+					return userRole;
+				}).collect(Collectors.toList());
 		return sysUserRoleService.saveBatch(userRoleList);
 	}
 
@@ -99,29 +98,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 	 * @return
 	 */
 	@Override
-	@Cacheable(value = "user_details", key = "#sysUser.username", unless = "#result == null")
 	public UserInfo findUserInfo(SysUser sysUser) {
-		if (sysUser == null) {
-			return null;
-		}
-
 		UserInfo userInfo = new UserInfo();
 		userInfo.setSysUser(sysUser);
 		//设置角色列表  (ID)
 		List<Integer> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId())
-			.stream()
-			.map(SysRole::getRoleId)
-			.collect(Collectors.toList());
+				.stream()
+				.map(SysRole::getRoleId)
+				.collect(Collectors.toList());
 		userInfo.setRoles(ArrayUtil.toArray(roleIds, Integer.class));
 
 		//设置权限列表(menu.permission)
 		Set<String> permissions = new HashSet<>();
 		roleIds.forEach(roleId -> {
 			List<String> permissionList = sysMenuService.findMenuByRoleId(roleId)
-				.stream()
-				.filter(menuVo -> StringUtils.isNotEmpty(menuVo.getPermission()))
-				.map(MenuVO::getPermission)
-				.collect(Collectors.toList());
+					.stream()
+					.filter(menuVo -> StringUtils.isNotEmpty(menuVo.getPermission()))
+					.map(MenuVO::getPermission)
+					.collect(Collectors.toList());
 			permissions.addAll(permissionList);
 		});
 		userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class));
@@ -137,11 +131,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 	 */
 	@Override
 	public IPage getUsersWithRolePage(Page page, UserDTO userDTO) {
-		DataScope dataScope = new DataScope();
-		dataScope.setScopeName("deptId");
-		dataScope.setIsOnly(true);
-		dataScope.setDeptIds(getChildDepts());
-		return baseMapper.getUserVosPage(page, userDTO, dataScope);
+		return baseMapper.getUserVosPage(page, userDTO, new DataScope());
 	}
 
 	/**
@@ -175,7 +165,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 		UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
 		SysUser sysUser = new SysUser();
 		if (StrUtil.isNotBlank(userDto.getPassword())
-			&& StrUtil.isNotBlank(userDto.getNewpassword1())) {
+				&& StrUtil.isNotBlank(userDto.getNewpassword1())) {
 			if (ENCODER.matches(userDto.getPassword(), userVO.getPassword())) {
 				sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
 			} else {
@@ -202,7 +192,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 		this.updateById(sysUser);
 
 		sysUserRoleService.remove(Wrappers.<SysUserRole>update().lambda()
-			.eq(SysUserRole::getUserId, userDto.getUserId()));
+				.eq(SysUserRole::getUserId, userDto.getUserId()));
 		userDto.getRole().forEach(roleId -> {
 			SysUserRole userRole = new SysUserRole();
 			userRole.setUserId(sysUser.getUserId());
@@ -221,7 +211,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 	@Override
 	public List<SysUser> listAncestorUsers(String username) {
 		SysUser sysUser = this.getOne(Wrappers.<SysUser>query().lambda()
-			.eq(SysUser::getUsername, username));
+				.eq(SysUser::getUsername, username));
 
 		SysDept sysDept = sysDeptService.getById(sysUser.getDeptId());
 		if (sysDept == null) {
@@ -230,7 +220,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
 		Integer parentId = sysDept.getParentId();
 		return this.list(Wrappers.<SysUser>query().lambda()
-			.eq(SysUser::getDeptId, parentId));
+				.eq(SysUser::getDeptId, parentId));
 	}
 
 	/**
@@ -242,11 +232,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 		Integer deptId = SecurityUtils.getUser().getDeptId();
 		//获取当前部门的子部门
 		return sysDeptRelationService
-			.list(Wrappers.<SysDeptRelation>query().lambda()
-				.eq(SysDeptRelation::getAncestor, deptId))
-			.stream()
-			.map(SysDeptRelation::getDescendant)
-			.collect(Collectors.toList());
+				.list(Wrappers.<SysDeptRelation>query().lambda()
+						.eq(SysDeptRelation::getAncestor, deptId))
+				.stream()
+				.map(SysDeptRelation::getDescendant)
+				.collect(Collectors.toList());
 	}
 
 }

+ 2 - 2
pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysMenuMapper.xml

@@ -32,7 +32,7 @@
 		<result column="component" property="component"/>
 		<result column="sort" property="sort"/>
 		<result column="type" property="type"/>
-		<result column="keepalive" property="keepalive"/>
+		<result column="keep_alive" property="keepAlive"/>
 		<result column="create_time" property="createTime"/>
 		<result column="update_time" property="updateTime"/>
 		<result column="del_flag" property="delFlag"/>
@@ -47,7 +47,7 @@
 		<result column="path" property="path"/>
 		<result column="component" property="component"/>
 		<result column="sort" property="sort"/>
-		<result column="keepalive" property="keepalive"/>
+		<result column="keep_alive" property="keepAlive"/>
 		<result column="type" property="type"/>
 		<result column="create_time" property="createTime"/>
 		<result column="update_time" property="updateTime"/>

+ 2 - 0
pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMapper.xml

@@ -27,6 +27,8 @@
 		<result column="role_name" property="roleName"/>
 		<result column="role_code" property="roleCode"/>
 		<result column="role_desc" property="roleDesc"/>
+		<result column="ds_type" property="dsType"/>
+		<result column="ds_scope" property="dsScope"/>
 		<result column="create_time" property="createTime"/>
 		<result column="update_time" property="updateTime"/>
 		<result column="del_flag" property="delFlag"/>

+ 1 - 1
pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRouteConfMapper.xml

@@ -18,7 +18,7 @@
 
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
-<mapper namespace="com.pig4cloud.pigx.generator.mapper.SysRouteConfMapper">
+<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysRouteConfMapper">
 
 	<!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="com.pig4cloud.pigx.admin.api.entity.SysRouteConf" id="sysRouteConfMap">

+ 35 - 19
pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml

@@ -21,21 +21,25 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.pig4cloud.pigx.admin.mapper.SysUserMapper">
 	<!-- 通用查询映射结果 -->
-	<resultMap id="baseResultMap" type="com.pig4cloud.pigx.admin.api.entity.SysUser">
+	<resultMap id="baseResultMap" type="com.pig4cloud.pigx.admin.api.vo.UserVO">
 		<id column="user_id" property="userId"/>
 		<result column="username" property="username"/>
 		<result column="password" property="password"/>
+		<result column="salt" property="salt"/>
 		<result column="phone" property="phone"/>
 		<result column="avatar" property="avatar"/>
-		<result column="salt" property="salt"/>
-		<result column="dept_id" property="deptId"/>
-		<result column="tenant_id" property="tenantId"/>
 		<result column="wx_openid" property="wxOpenid"/>
 		<result column="qq_openid" property="qqOpenid"/>
-		<result column="create_time" property="createTime"/>
-		<result column="update_time" property="updateTime"/>
-		<result column="del_flag" property="delFlag"/>
+		<result column="ucreate_time" property="createTime"/>
+		<result column="uupdate_time" property="updateTime"/>
 		<result column="lock_flag" property="lockFlag"/>
+		<result column="udel_flag" property="delFlag"/>
+		<result column="deptId" property="deptId"/>
+		<result column="tenantId" property="tenantId"/>
+		<result column="deptName" property="deptName"/>
+		<collection property="roleList" ofType="com.pig4cloud.pigx.admin.api.entity.SysRole"
+					select="com.pig4cloud.pigx.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id">
+		</collection>
 	</resultMap>
 
 	<!-- userVo结果集 -->
@@ -135,22 +139,34 @@
            `user`.user_id = #{id}
     </select>
 
-	<select id="getUserVosPage" resultMap="userVoResultMap">
+	<select id="getUserVosPage" resultMap="baseResultMap">
 		SELECT
-		<include refid="userRoleSql"/>
+		`user`.user_id,
+		`user`.username,
+		`user`.`password`,
+		`user`.salt,
+		`user`.phone,
+		`user`.avatar,
+		`user`.wx_openid,
+		`user`.qq_openid,
+		`user`.dept_id,
+		`user`.create_time AS ucreate_time,
+		`user`.update_time AS uupdate_time,
+		`user`.del_flag AS udel_flag,
+		`user`.lock_flag AS lock_flag,
+		`user`.dept_id AS deptId,
+		`user`.tenant_id AS tenantId
 		FROM
 		sys_user AS `user`
-		LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id
-		LEFT JOIN sys_role AS r ON r.role_id = ur.role_id
 		LEFT JOIN sys_dept AS d ON d.dept_id = `user`.dept_id
-		WHERE
-		r.del_flag = 0
-		<if test="query.username != null and query.username != ''">
-			and `user`.username LIKE CONCAT('%',#{query.username},'%')
-		</if>
-		<if test="query.deptId != null and query.deptId != ''">
-			and `user`.dept_id = #{query.deptId}
-		</if>
+		<where>
+			<if test="query.username != null and query.username != ''">
+				and `user`.username LIKE CONCAT('%',#{query.username},'%')
+			</if>
+			<if test="query.deptId != null and query.deptId != ''">
+				and `user`.dept_id = #{query.deptId}
+			</if>
+		</where>
 		ORDER BY `user`.create_time DESC
 	</select>
 </mapper>

+ 1 - 1
pigx-upms/pom.xml

@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-upms</artifactId>

+ 25 - 14
pigx-visual/pigx-activiti/pom.xml

@@ -23,7 +23,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-visual</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-activiti</artifactId>
@@ -41,22 +41,18 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
+		<!--数据依赖-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
-			<artifactId>pigx-upms-api</artifactId>
-			<version>2.0.0</version>
+			<artifactId>pigx-common-data</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
-			<artifactId>pigx-common-swagger</artifactId>
-			<version>2.0.0</version>
-		</dependency>
-		<dependency>
-			<groupId>mysql</groupId>
-			<artifactId>mysql-connector-java</artifactId>
-			<version>${mysql.connector.version}</version>
+			<artifactId>pigx-upms-api</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<!--mybatis-->
 		<dependency>
@@ -64,13 +60,28 @@
 			<artifactId>mybatis-plus-boot-starter</artifactId>
 			<version>${mybatis-plus.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-swagger</artifactId>
+			<version>2.1.0</version>
+		</dependency>
 		<!-- activiti -->
 		<dependency>
 			<groupId>org.activiti</groupId>
 			<artifactId>activiti-spring-boot-starter-basic</artifactId>
 			<version>${activiti.version}</version>
+			<exclusions>
+				<exclusion>
+					<groupId>org.mybatis</groupId>
+					<artifactId>mybatis</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>${mysql.connector.version}</version>
 		</dependency>
-
 		<dependency>
 			<groupId>org.activiti</groupId>
 			<artifactId>activiti-modeler</artifactId>
@@ -117,12 +128,12 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-swagger</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-security</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--undertow容器-->
 		<dependency>

+ 1 - 1
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ActTaskServiceImpl.java

@@ -29,7 +29,7 @@ import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
 import com.pig4cloud.pigx.act.service.ActTaskService;
 import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
 import com.pig4cloud.pigx.common.core.constant.enums.TaskStatusEnum;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
 import com.pig4cloud.pigx.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;

+ 1 - 1
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/EditorServiceImpl.java

@@ -21,7 +21,7 @@ import cn.hutool.core.util.CharsetUtil;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.pig4cloud.pigx.act.service.EditorService;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.activiti.engine.ActivitiException;

+ 12 - 12
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ModelServiceImpl.java

@@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.pig4cloud.pigx.act.service.ModelService;
 import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
 import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.activiti.bpmn.model.BpmnModel;
@@ -82,8 +82,8 @@ public class ModelServiceImpl implements ModelService {
 			model.setName(name);
 			model.setCategory(category);
 			model.setVersion(Integer.parseInt(
-				String.valueOf(repositoryService.createModelQuery()
-					.modelKey(model.getKey()).count() + 1)));
+					String.valueOf(repositoryService.createModelQuery()
+							.modelKey(model.getKey()).count() + 1)));
 
 			ObjectNode modelObjectNode = objectMapper.createObjectNode();
 			modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
@@ -110,8 +110,8 @@ public class ModelServiceImpl implements ModelService {
 	@Override
 	public IPage<Model> getModelPage(Map<String, Object> params) {
 		ModelQuery modelQuery = repositoryService.createModelQuery()
-			.modelTenantId(String.valueOf(TenantContextHolder.getTenantId()))
-			.latestVersion().orderByLastUpdateTime().desc();
+				.modelTenantId(String.valueOf(TenantContextHolder.getTenantId()))
+				.latestVersion().orderByLastUpdateTime().desc();
 		String category = (String) params.get("category");
 		if (StrUtil.isNotBlank(category)) {
 			modelQuery.modelCategory(category);
@@ -158,18 +158,18 @@ public class ModelServiceImpl implements ModelService {
 			}
 			// 部署流程
 			Deployment deployment = repositoryService
-				.createDeployment().name(model.getName())
-				.addBpmnModel(processName, bpmnModel)
-				.tenantId(String.valueOf(TenantContextHolder.getTenantId()))
-				.deploy();
+					.createDeployment().name(model.getName())
+					.addBpmnModel(processName, bpmnModel)
+					.tenantId(String.valueOf(TenantContextHolder.getTenantId()))
+					.deploy();
 
 			// 设置流程分类
 			List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery()
-				.deploymentId(deployment.getId())
-				.list();
+					.deploymentId(deployment.getId())
+					.list();
 
 			list.stream().forEach(processDefinition ->
-				repositoryService.setProcessDefinitionCategory(processDefinition.getId(), model.getCategory()));
+					repositoryService.setProcessDefinitionCategory(processDefinition.getId(), model.getCategory()));
 		} catch (Exception e) {
 			log.error("部署失败,异常", e);
 		}

+ 1 - 1
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ProcessServiceImpl.java

@@ -29,7 +29,7 @@ import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
 import com.pig4cloud.pigx.common.core.constant.enums.ProcessStatusEnum;
 import com.pig4cloud.pigx.common.core.constant.enums.ResourceTypeEnum;
 import com.pig4cloud.pigx.common.core.constant.enums.TaskStatusEnum;
-import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
+import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
 import lombok.AllArgsConstructor;
 import org.activiti.engine.RepositoryService;
 import org.activiti.engine.RuntimeService;

+ 10 - 4
pigx-visual/pigx-codegen/pom.xml

@@ -6,7 +6,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-visual</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-codegen</artifactId>
@@ -20,6 +20,12 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-config</artifactId>
 		</dependency>
+		<!--数据操作-->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-data</artifactId>
+			<version>2.1.0</version>
+		</dependency>
 		<!--mybatis-->
 		<dependency>
 			<groupId>com.baomidou</groupId>
@@ -35,19 +41,19 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--swagger-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-swagger</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--安全模块-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-security</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--代码生成模板引擎-->
 		<dependency>

+ 1 - 4
pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm

@@ -16,8 +16,7 @@
  */
 package ${package}.${moduleName}.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.pig4cloud.pigx.common.core.util.R;
 import com.pig4cloud.pigx.common.log.annotation.SysLog;
@@ -26,8 +25,6 @@ import ${package}.${moduleName}.service.${className}Service;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Map;
-
 
 /**
  * ${comments}

+ 1 - 1
pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm

@@ -34,8 +34,8 @@ import java.time.LocalDateTime;
  * @date ${datetime}
  */
 @Data
-@EqualsAndHashCode(callSuper = true)
 @TableName("${tableName}")
+@EqualsAndHashCode(callSuper = true)
 public class ${className} extends Model<${className}> {
 private static final long serialVersionUID = 1L;
 

+ 0 - 3
pigx-visual/pigx-codegen/src/main/resources/template/Mapper.java.vm

@@ -17,10 +17,7 @@
 package ${package}.${moduleName}.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import ${package}.${moduleName}.entity.${className};
-import org.apache.ibatis.annotations.Param;
 
 /**
  * ${comments}

+ 0 - 2
pigx-visual/pigx-codegen/src/main/resources/template/Service.java.vm

@@ -16,8 +16,6 @@
  */
 package ${package}.${moduleName}.service;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import ${package}.${moduleName}.entity.${className};
 

+ 2 - 3
pigx-visual/pigx-codegen/src/main/resources/template/ServiceImpl.java.vm

@@ -16,10 +16,9 @@
  */
 package ${package}.${moduleName}.service.impl;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import ${package}.${moduleName}.entity.${className};
+import ${package}.${moduleName}.mapper.${className}Mapper;
 import ${package}.${moduleName}.service.${className}Service;
 import org.springframework.stereotype.Service;
 
@@ -29,7 +28,7 @@ import org.springframework.stereotype.Service;
  * @author ${author}
  * @date ${datetime}
  */
-@Service("${classname}Service")
+@Service
 public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service {
 
 }

+ 0 - 1
pigx-visual/pigx-codegen/src/main/resources/template/crud.js.vm

@@ -25,7 +25,6 @@ export const tableOption = {
   editBtn: false,
   delBtn: false,
   addBtn: false,
-  dic: [],
   column: [
 #foreach ($column in $columns)
 	  {

+ 4 - 4
pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm

@@ -1,13 +1,13 @@
 -- 该脚本不要执行,请完善 ID 对应关系,注意层级关系 !!!!
 
 -- 菜单SQL
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
     values ( '父菜单ID', 'views/${moduleName}/${pathName}/index', '', '0', '${pathName}', 'icon-bangzhushouji', '菜单ID', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理');
 
 -- 菜单对应按钮SQL
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
     values ( '菜单ID', null, '${moduleName}_${pathName}_add', '1', null, '1', '子按钮ID1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增');
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
     values ( '菜单ID', null, '${moduleName}_${pathName}_edit', '1', null, '1', '子按钮ID2', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改');
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
     values ( '菜单ID', null, '${moduleName}_${pathName}_del', '1', null, '1', '子按钮ID3', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除');

+ 11 - 5
pigx-visual/pigx-daemon/pom.xml

@@ -23,7 +23,7 @@
 	<parent>
 		<groupId>com.pig4cloud</groupId>
 		<artifactId>pigx-visual</artifactId>
-		<version>2.0.0</version>
+		<version>2.1.0</version>
 	</parent>
 
 	<artifactId>pigx-daemon</artifactId>
@@ -41,12 +41,18 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-job</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-swagger</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
+		</dependency>
+		<!--数据库-->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-data</artifactId>
+			<version>2.1.0</version>
 		</dependency>
 		<!--mybatis-->
 		<dependency>
@@ -74,13 +80,13 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-swagger</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!-- 安全模块-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-security</artifactId>
-			<version>2.0.0</version>
+			<version>2.1.0</version>
 		</dependency>
 		<!--web 模块-->
 		<dependency>

+ 0 - 0
pigx-visual/pigx-monitor/pom.xml


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels