diff --git a/README.md b/README.md
index fa318262..3d1d61d8 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,40 @@
# zlt-microservices-platform
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
## 如果您觉得有帮助,请点右上角 "Star" 支持一下谢谢
+
+## 1. 总体架构图
+
-[TOC]
-
-## 1. 项目介绍
+
+## 2. 功能介绍
+
+
+## 3. 项目介绍
* **技术交流群**
@@ -38,9 +46,7 @@
* 账号密码:admin/admin
* APM监控账号密码:admin/admin
* Grafana账号:zlt/zlt123
- * txlcn事务管理器密码:admin
* 任务管理账号密码:admin/123456
- * Sentinel:sentinel/sentinel
* **演示环境有全方位的监控示例:日志系统 + APM系统 + GPE系统**
* Gitee地址:https://gitee.com/zlt2000/microservices-platform
* Github地址:https://github.com/zlt2000/microservices-platform
@@ -54,19 +60,7 @@
>重构于开源项目OCP&cp:https://gitee.com/owenwangwen/open-capacity-platform
-
-## 2. 项目总体架构图
-
-
-
-
-## 3. 功能介绍
-
-
-
-
## 4. 模块说明
-
```lua
central-platform -- 父项目,公共依赖
│ ├─zlt-business -- 业务模块一级工程
@@ -83,14 +77,16 @@ central-platform -- 父项目,公共依赖
│ │ ├─zlt-db-spring-boot-starter -- 封装数据库通用操作逻辑
│ │ ├─zlt-log-spring-boot-starter -- 封装log通用操作逻辑
│ │ ├─zlt-redis-spring-boot-starter -- 封装Redis通用操作逻辑
-│ │ ├─zlt-ribbon-spring-boot-starter -- 封装Ribbon和Feign的通用操作逻辑
+│ │ ├─zlt-loadbalancer-spring-boot-starter -- 封装Loadbalancer和Feign的通用操作逻辑
│ │ ├─zlt-sentinel-spring-boot-starter -- 封装Sentinel的通用操作逻辑
│ │ ├─zlt-swagger2-spring-boot-starter -- 封装Swagger通用操作逻辑
+│ │ ├─zlt-elasticsearch-spring-boot-starter -- 封装Elasticsearch通用操作逻辑
+│ │ ├─zlt-oss-spring-boot-starter -- 封装对象存储通用操作逻辑
+│ │ ├─zlt-zookeeper-spring-boot-starter -- 封装Zookeeper通用操作逻辑
│ ├─zlt-config -- 配置中心
│ ├─zlt-doc -- 项目文档
│ ├─zlt-gateway -- api网关一级工程
│ │ ├─sc-gateway -- spring-cloud-gateway[9900]
-│ │ ├─zuul-gateway -- netflix-zuul[9900]
│ ├─zlt-job -- 分布式任务调度一级工程
│ │ ├─job-admin -- 任务管理器[8081]
│ │ ├─job-core -- 任务调度核心代码
@@ -114,56 +110,53 @@ central-platform -- 父项目,公共依赖
## 5. 交流反馈
* 有问题先看看 [F&Q](https://www.kancloud.cn/zlt2000/microservices-platform/981382) 中有没有相关的回答
-
* 欢迎提交`ISSUS`,请写清楚问题的具体原因,重现步骤和环境(上下文)
-
* 项目/微服务交流请进群:
* 一群:[250883130(已满)](https://shang.qq.com/wpa/qunwpa?idkey=17544199255998bda0d938fb72b08d076c40c52c9904520b76eb5eb0585da71e)
- * 二群:[1041797659](https://shang.qq.com/wpa/qunwpa?idkey=41988facbc02f678942a7ee7ae03122f2ef0a10c948b3d07319f070bfb0d3a98)
-
-* 个人博客:https://blog.csdn.net/zlt2000
-
+ * 二群:[1041797659(已满)](https://shang.qq.com/wpa/qunwpa?idkey=41988facbc02f678942a7ee7ae03122f2ef0a10c948b3d07319f070bfb0d3a98)
+ * 三群:[512637767](https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi)
+* 个人博客:[https://zlt2000.gitee.io](https://zlt2000.gitee.io)
* 个人邮箱:zltdiablo@163.com
-
* 个人公众号:[陶陶技术笔记](http://qiniu.zlt2000.cn/blog/20190902/M56cWjw7uNsc.png?imageslim)
+* GitChat:[https://gitbook.cn/gitchat/author/5b2362320398d50d7b7ab29e](https://gitbook.cn/gitchat/author/5b2362320398d50d7b7ab29e)
## 6. 截图(点击可大图预览)
-  |
-  |
+  |
+  |
-
-  |
-  |
+
+  |
+  |
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e727893d..e2effa3b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,470 +1,512 @@
-
-
- 4.0.0
- com.zlt
- central-platform
- 3.5.0
- pom
-
-
- 1.8
- 1.8
- UTF-8
- 8
- 2.1.1.RELEASE
- 2.1.12.RELEASE
- Greenwich.SR5
- 4.4
- 1.2.62
- 2.9.2
- 1.8.7
- 1.0.6
- 2.0.1
- 0.9.1
- 1.1.21
- 1.14
- 3.1.0
- 2.3.8.RELEASE
- 1.1.0.RELEASE
- 3.9.1
- 1.6.2
- 5.1.4
- 3.3.1
- 3.8.1
- 7.2.28
- 4.1.3
- 4.1.1
- 2.2.2
- 1.7
- 2.6
- 5.0.2.RELEASE
- 1.26.7
- 1.21
- 2.11.4
- 5.2.2.RELEASE
- 1.0.2
- 1.9.4
- 1.1.6.RELEASE
- 2.6
- 4.0.1
- 3.2.5.RELEASE
- 6.8.8
- 1.2.2
- zlt-job/**/*, zlt-register/**/*, zlt-web/**/*
- openjdk:8-jre-alpine
- /tmp
- hub.zlt.com:8080/microservices-platform
- -Djava.security.egd=file:/dev/./urandom
- -Xms128m -Xmx128m
-
-
-
-
- org.apache.commons
- commons-lang3
-
-
- org.apache.commons
- commons-collections4
- ${commons-collections4.version}
-
-
- commons-beanutils
- commons-beanutils
- ${commons-beanutils.version}
-
-
- com.alibaba
- fastjson
- ${fastjson.version}
-
-
- org.projectlombok
- lombok
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
-
-
- com.zlt
- zlt-common-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-db-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-log-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-redis-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-swagger2-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-ribbon-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-auth-client-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-sentinel-spring-boot-starter
- ${project.version}
-
-
- com.zlt
- zlt-config
- ${project.version}
-
-
- com.zlt
- zlt-common-core
- ${project.version}
-
-
- com.zlt
- zlt-elasticsearch-spring-boot-starter
- ${project.version}
-
-
- io.jsonwebtoken
- jjwt
- ${jjwt.version}
-
-
-
- com.alibaba
- druid-spring-boot-starter
- ${druid-starter}
-
-
-
- com.baomidou
- mybatis-plus-boot-starter
- ${mybatis-plus-boot-starter.version}
-
-
- com.baomidou
- mybatis-plus-extension
- ${mybatis-plus-boot-starter.version}
-
-
-
- org.springframework.security.oauth
- spring-security-oauth2
- ${security-oauth2.version}
-
-
- org.springframework.security
- spring-security-jwt
- ${security-jwt.version}
-
-
-
- org.redisson
- redisson
- ${redisson.version}
-
-
-
- io.springfox
- springfox-swagger2
- ${swagger.version}
-
-
- io.springfox
- springfox-bean-validators
- ${swagger.version}
-
-
- io.springfox
- springfox-swagger-ui
- ${swagger.version}
-
-
- com.github.xiaoymin
- swagger-bootstrap-ui
- ${swagger.ui.version}
-
-
- com.zyplayer
- swagger-mg-ui
- ${swagger.mg.ui.version}
-
-
- com.github.zlt2000
- swagger-butler-core
- ${swagger.butler.version}
-
-
-
- com.github.whvcse
- easy-captcha
- ${easyCaptcha.version}
-
-
-
- cn.hutool
- hutool-all
- ${hutool.version}
-
-
- com.aliyun.oss
- aliyun-sdk-oss
- ${aliyun-sdk-oss}
-
-
-
- com.qiniu
- qiniu-java-sdk
- ${qiniu-java-sdk}
-
-
- org.apache.poi
- poi
- ${poi.version}
-
-
- org.apache.poi
- poi-ooxml
- ${poi.version}
-
-
-
- cn.afterturn
- easypoi-base
- ${easypoi.version}
-
-
- com.baomidou
- mybatis-plus
- ${mybatis-plus-boot-starter.version}
-
-
- de.codecentric
- spring-boot-admin-starter-server
- ${spring-boot-admin.version}
-
-
- org.apache.velocity
- velocity
- ${velocity.version}
-
-
- org.apache.commons
- commons-configuration2
- ${commons-configuration2.version}
-
-
- com.codingapi.txlcn
- txlcn-tm
- ${txlcn.version}
-
-
- com.codingapi.txlcn
- txlcn-tc
- ${txlcn.version}
-
-
- com.codingapi.txlcn
- txlcn-txmsg-netty
- ${txlcn.version}
-
-
- io.shardingsphere
- sharding-jdbc-spring-boot-starter
- ${sharding-sphere.version}
-
-
- com.github.tobato
- fastdfs-client
- ${fastdfs-client.version}
-
-
- com.zlt
- search-client
- ${project.version}
-
-
- eu.bitwalker
- UserAgentUtils
- ${userAgent.version}
-
-
- com.alibaba
- transmittable-thread-local
- ${transmittable.version}
-
-
- io.lettuce
- lettuce-core
- ${lettuce.version}
-
-
- com.nepxion
- banner
- ${banner.version}
-
-
- org.springframework.social
- spring-social-security
- ${spring-social-security.version}
-
-
- commons-io
- commons-io
- ${commons-io.version}
-
-
- javax.servlet
- javax.servlet-api
- ${servlet-api.version}
-
-
- org.springframework.data
- spring-data-elasticsearch
- ${spring-data-elasticsearch.version}
-
-
- org.elasticsearch.client
- elasticsearch-rest-high-level-client
- ${elasticsearch.version}
-
-
- org.elasticsearch.client
- elasticsearch-rest-client
- ${elasticsearch.version}
-
-
- org.elasticsearch
- elasticsearch
- ${elasticsearch.version}
-
-
-
- org.springframework.boot
- spring-boot-dependencies
- ${spring-boot-dependencies.version}
- pom
- import
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud-dependencies.version}
- pom
- import
-
-
- com.alibaba.cloud
- spring-cloud-alibaba-dependencies
- ${spring-cloud-alibaba-dependencies.version}
- pom
- import
-
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- ${spring-boot-dependencies.version}
-
-
- com.spotify
- docker-maven-plugin
- ${docker-maven-plugin.version}
-
-
-
-
-
-
-
- aliyun-repos
- https://maven.aliyun.com/repository/public
-
- false
-
-
-
-
-
- releases
- releases Repository
- http://192.168.28.138:8081/repository/maven-releases/
-
-
-
- snapshots
- http://192.168.28.138:8081/repository/maven-snapshots/
- true
-
-
-
-
-
- zlt-commons
-
- zlt-uaa
-
- zlt-gateway
-
- zlt-business
-
- zlt-web
-
- zlt-job
-
- zlt-monitor
-
- zlt-transaction
-
- zlt-config
-
- zlt-demo
-
-
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
-
-
-
-
-
- LeTao Zhu
- zltdiablo@163.com
- https://github.com/zlt2000
- https://blog.csdn.net/zlt2000
-
-
+
+
+ 4.0.0
+ com.zlt
+ central-platform
+ 5.4.0
+ pom
+
+
+ 1.8
+ 1.8
+ UTF-8
+ 8
+ 2021.1
+ 2.5.14
+ 2020.0.5
+ 4.4
+ 2.0.1
+ 0.9.1
+ 1.2.6
+ 1.14
+ 3.1.0
+ 2.3.8.RELEASE
+ 1.1.0.RELEASE
+ 3.16.1
+ 1.6.2
+ 5.7.20
+ 3.5.1
+ 3.8.1
+ 7.2.28
+ 4.1.3
+ 4.1.1
+ 2.5.6
+ 1.7
+ 2.8
+ 5.0.2.RELEASE
+ 1.27.2
+ 1.21
+ 2.12.1
+ 1.0.2
+ 1.9.4
+ 1.1.6.RELEASE
+ 2.7
+ 4.0.1
+ 4.2.3
+ 7.13.4
+ 2.0.5
+ 6.2.0.Final
+ 2.7.8
+ 5.1.0
+ 2.12.4
+ 1.10
+ 2.2.9.RELEASE
+ 1.12.40
+ 2.2.5.RELEASE
+ 1.2.2
+ zlt-job/**/*, zlt-register/**/*, zlt-web/**/*
+ openjdk:8-jre-alpine
+ /tmp
+ hub.zlt.com:8080/microservices-platform
+ -Djava.security.egd=file:/dev/./urandom
+ -Xms128m -Xmx128m
+
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+ org.apache.commons
+ commons-collections4
+ ${commons-collections4.version}
+
+
+ commons-beanutils
+ commons-beanutils
+ ${commons-beanutils.version}
+
+
+ org.projectlombok
+ lombok
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+
+
+
+
+
+ com.zlt
+ zlt-common-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-db-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-log-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-redis-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-swagger2-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-loadbalancer-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-auth-client-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-sentinel-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-config
+ ${project.version}
+
+
+ com.zlt
+ zlt-common-core
+ ${project.version}
+
+
+ com.zlt
+ zlt-elasticsearch-spring-boot-starter
+ ${project.version}
+
+
+ io.jsonwebtoken
+ jjwt
+ ${jjwt.version}
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid-starter}
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ ${mybatis-plus-boot-starter.version}
+
+
+ com.baomidou
+ mybatis-plus-extension
+ ${mybatis-plus-boot-starter.version}
+
+
+ com.baomidou
+ mybatis-plus
+ ${mybatis-plus-boot-starter.version}
+
+
+
+ org.springframework.security.oauth
+ spring-security-oauth2
+ ${security-oauth2.version}
+
+
+ org.springframework.security
+ spring-security-jwt
+ ${security-jwt.version}
+
+
+
+ org.redisson
+ redisson-spring-boot-starter
+ ${redisson-starter.version}
+
+
+
+ com.github.zlt2000
+ swagger-butler-core
+ ${swagger.butler.version}
+
+
+
+ com.github.whvcse
+ easy-captcha
+ ${easyCaptcha.version}
+
+
+
+ cn.hutool
+ hutool-all
+ ${hutool.version}
+
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ ${aliyun-sdk-oss}
+
+
+
+ com.qiniu
+ qiniu-java-sdk
+ ${qiniu-java-sdk}
+
+
+ org.apache.poi
+ poi
+ ${poi.version}
+
+
+ org.apache.poi
+ poi-ooxml
+ ${poi.version}
+
+
+
+ cn.afterturn
+ easypoi-base
+ ${easypoi.version}
+
+
+ de.codecentric
+ spring-boot-admin-starter-server
+ ${spring-boot-admin.version}
+
+
+ org.apache.velocity
+ velocity
+ ${velocity.version}
+
+
+ org.apache.commons
+ commons-configuration2
+ ${commons-configuration2.version}
+
+
+ com.codingapi.txlcn
+ txlcn-tm
+ ${txlcn.version}
+
+
+ com.codingapi.txlcn
+ txlcn-tc
+ ${txlcn.version}
+
+
+ com.codingapi.txlcn
+ txlcn-txmsg-netty
+ ${txlcn.version}
+
+
+ io.shardingsphere
+ sharding-jdbc-spring-boot-starter
+ ${sharding-sphere.version}
+
+
+ com.github.tobato
+ fastdfs-client
+ ${fastdfs-client.version}
+
+
+ com.zlt
+ search-client
+ ${project.version}
+
+
+ eu.bitwalker
+ UserAgentUtils
+ ${userAgent.version}
+
+
+ com.alibaba
+ transmittable-thread-local
+ ${transmittable.version}
+
+
+ com.nepxion
+ banner
+ ${banner.version}
+
+
+ org.springframework.social
+ spring-social-security
+ ${spring-social-security.version}
+
+
+ commons-io
+ commons-io
+ ${commons-io.version}
+
+
+ javax.servlet
+ javax.servlet-api
+ ${servlet-api.version}
+
+
+ org.springframework.data
+ spring-data-elasticsearch
+ ${spring-data-elasticsearch.version}
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-high-level-client
+ ${elasticsearch.version}
+
+
+ org.elasticsearch
+ elasticsearch-x-content
+ ${elasticsearch.version}
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-client
+ ${elasticsearch.version}
+
+
+ org.elasticsearch
+ elasticsearch
+ ${elasticsearch.version}
+
+
+ com.github.xiaoymin
+ knife4j-spring-boot-starter
+ ${knife4j.version}
+
+
+ com.github.xiaoymin
+ knife4j-micro-spring-boot-starter
+ ${knife4j.version}
+
+
+ org.hibernate
+ hibernate-validator
+ ${hibernate-validator.version}
+
+
+ org.apache.dubbo
+ dubbo
+ ${dubbo.version}
+
+
+ com.zlt
+ zlt-oss-spring-boot-starter
+ ${project.version}
+
+
+ com.zlt
+ zlt-zookeeper-spring-boot-starter
+ ${project.version}
+
+
+ org.apache.curator
+ curator-recipes
+ ${curator.version}
+
+
+ org.apache.curator
+ curator-framework
+ ${curator.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson-databind.version}
+
+
+ org.springframework.cloud
+ spring-cloud-starter-oauth2
+ ${spring-cloud-starter-oauth2.version}
+
+
+ com.amazonaws
+ aws-java-sdk-s3
+ ${aws-java-sdk-s3.version}
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-zuul
+ ${zuul.version}
+
+
+ commons-configuration
+ commons-configuration
+ ${commons-configuration.version}
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot-dependencies.version}
+ pom
+ import
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud-dependencies.version}
+ pom
+ import
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${spring-cloud-alibaba-dependencies.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot-dependencies.version}
+
+
+ com.spotify
+ docker-maven-plugin
+ ${docker-maven-plugin.version}
+
+
+
+
+
+
+
+ aliyun-repos
+ https://maven.aliyun.com/repository/public
+
+ false
+
+
+
+
+
+ releases
+ releases Repository
+ http://192.168.28.138:8081/repository/maven-releases/
+
+
+
+ snapshots
+ http://192.168.28.138:8081/repository/maven-snapshots/
+ true
+
+
+
+
+
+ zlt-commons
+
+ zlt-uaa
+
+ zlt-gateway
+
+ zlt-business
+
+ zlt-web
+
+ zlt-job
+
+ zlt-monitor
+
+ zlt-transaction
+
+ zlt-config
+
+ zlt-demo
+
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+
+
+
+
+
+ LeTao Zhu
+ zltdiablo@163.com
+ https://github.com/zlt2000
+ https://blog.csdn.net/zlt2000
+
+
\ No newline at end of file
diff --git a/zlt-business/code-generator/pom.xml b/zlt-business/code-generator/pom.xml
index afe82e55..276283ad 100644
--- a/zlt-business/code-generator/pom.xml
+++ b/zlt-business/code-generator/pom.xml
@@ -4,7 +4,7 @@
com.zlt
zlt-business
- 3.5.0
+ 5.4.0
code-generator
@@ -59,6 +59,10 @@
io.micrometer
micrometer-registry-prometheus
+
+ commons-configuration
+ commons-configuration
+
diff --git a/zlt-business/file-center/pom.xml b/zlt-business/file-center/pom.xml
index 60b50794..38a2e06f 100644
--- a/zlt-business/file-center/pom.xml
+++ b/zlt-business/file-center/pom.xml
@@ -4,7 +4,7 @@
com.zlt
zlt-business
- 3.5.0
+ 5.4.0
file-center
文件中心
@@ -24,12 +24,16 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
com.zlt
zlt-sentinel-spring-boot-starter
+
+ com.zlt
+ zlt-oss-spring-boot-starter
+
com.alibaba.cloud
@@ -66,20 +70,20 @@
micrometer-registry-prometheus
-
-
- com.aliyun.oss
- aliyun-sdk-oss
-
-
-
- com.qiniu
- qiniu-java-sdk
-
-
+
+
+
+ com.amazonaws
+ aws-java-sdk-s3
+
+
+
+ org.hibernate
+ hibernate-validator
diff --git a/zlt-business/file-center/src/main/java/com/central/FileCenterApp.java b/zlt-business/file-center/src/main/java/com/central/FileCenterApp.java
index 487e94e5..a0a9a6cf 100644
--- a/zlt-business/file-center/src/main/java/com/central/FileCenterApp.java
+++ b/zlt-business/file-center/src/main/java/com/central/FileCenterApp.java
@@ -1,10 +1,8 @@
package com.central;
-import com.central.common.ribbon.annotation.EnableFeignInterceptor;
-import com.central.file.properties.FileServerProperties;
+import com.central.common.lb.annotation.EnableFeignInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@@ -13,7 +11,6 @@
* @author 作者 owen E-mail: 624191343@qq.com
*/
@EnableDiscoveryClient
-@EnableConfigurationProperties(FileServerProperties.class)
@EnableFeignClients
@EnableFeignInterceptor
@SpringBootApplication
diff --git a/zlt-business/file-center/src/main/java/com/central/file/config/AliyunOSSAutoConfigure.java b/zlt-business/file-center/src/main/java/com/central/file/config/AliyunOSSAutoConfigure.java
deleted file mode 100644
index 9531e08a..00000000
--- a/zlt-business/file-center/src/main/java/com/central/file/config/AliyunOSSAutoConfigure.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.central.file.config;
-
-import com.aliyun.oss.common.auth.DefaultCredentialProvider;
-import com.central.file.model.FileInfo;
-import com.central.file.properties.FileServerProperties;
-import com.central.file.service.impl.AbstractIFileService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import com.aliyun.oss.OSSClient;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * 阿里云配置
- *
- * @author 作者 owen E-mail: 624191343@qq.com
- */
-@Configuration
-@ConditionalOnProperty(name = "zlt.file-server.type", havingValue = "aliyun")
-public class AliyunOSSAutoConfigure {
- @Autowired
- private FileServerProperties fileProperties;
-
- /**
- * 阿里云文件存储client
- * 只有配置了aliyun.oss.access-key才可以使用
- */
- @Bean
- public OSSClient ossClient() {
- OSSClient ossClient = new OSSClient(fileProperties.getOss().getEndpoint()
- , new DefaultCredentialProvider(fileProperties.getOss().getAccessKey(), fileProperties.getOss().getAccessKeySecret())
- , null);
- return ossClient;
- }
-
- @Service
- public class AliyunOssServiceImpl extends AbstractIFileService {
- @Autowired
- private OSSClient ossClient;
-
- @Override
- protected String fileType() {
- return fileProperties.getType();
- }
-
- @Override
- protected void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception {
- ossClient.putObject(fileProperties.getOss().getBucketName(), fileInfo.getName(), file.getInputStream());
- fileInfo.setUrl(fileProperties.getOss().getDomain() + "/" + fileInfo.getName());
- }
-
- @Override
- protected boolean deleteFile(FileInfo fileInfo) {
- ossClient.deleteObject(fileProperties.getOss().getBucketName(), fileInfo.getName());
- return true;
- }
- }
-}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/config/FastdfsAutoConfigure.java b/zlt-business/file-center/src/main/java/com/central/file/config/FastdfsAutoConfigure.java
deleted file mode 100644
index e845d6f5..00000000
--- a/zlt-business/file-center/src/main/java/com/central/file/config/FastdfsAutoConfigure.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.central.file.config;
-
-import cn.hutool.core.util.StrUtil;
-import com.central.file.model.FileInfo;
-import com.central.file.properties.FileServerProperties;
-import com.central.file.service.impl.AbstractIFileService;
-import com.github.tobato.fastdfs.domain.fdfs.StorePath;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * FastDFS配置
- *
- * @author zlt
- */
-@Configuration
-@ConditionalOnProperty(name = "zlt.file-server.type", havingValue = "fastdfs")
-public class FastdfsAutoConfigure {
- @Autowired
- private FileServerProperties fileProperties;
-
- @Service
- public class FastdfsServiceImpl extends AbstractIFileService {
- @Autowired
- private FastFileStorageClient storageClient;
-
- @Override
- protected String fileType() {
- return fileProperties.getType();
- }
-
- @Override
- protected void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception {
- StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), FilenameUtils.getExtension(file.getOriginalFilename()), null);
- fileInfo.setUrl("http://" + fileProperties.getFdfs().getWebUrl() + "/" + storePath.getFullPath());
- fileInfo.setPath(storePath.getFullPath());
- }
-
- @Override
- protected boolean deleteFile(FileInfo fileInfo) {
- if (fileInfo != null && StrUtil.isNotEmpty(fileInfo.getPath())) {
- StorePath storePath = StorePath.parseFromUrl(fileInfo.getPath());
- storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
- }
- return true;
- }
- }
-}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/config/QiniuOSSAutoConfigure.java b/zlt-business/file-center/src/main/java/com/central/file/config/QiniuOSSAutoConfigure.java
deleted file mode 100644
index 849f928a..00000000
--- a/zlt-business/file-center/src/main/java/com/central/file/config/QiniuOSSAutoConfigure.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.central.file.config;
-
-import com.central.file.model.FileInfo;
-import com.central.file.properties.FileServerProperties;
-import com.central.file.service.impl.AbstractIFileService;
-import com.qiniu.common.QiniuException;
-import com.qiniu.http.Response;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import com.qiniu.common.Zone;
-import com.qiniu.storage.BucketManager;
-import com.qiniu.storage.UploadManager;
-import com.qiniu.util.Auth;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * 七牛云配置
- *
- * @author 作者 owen E-mail: 624191343@qq.com
- */
-@Configuration
-@ConditionalOnProperty(name = "zlt.file-server.type", havingValue = "qiniu")
-public class QiniuOSSAutoConfigure {
- @Autowired
- private FileServerProperties fileProperties;
-
- /**
- * 华东机房
- */
- @Bean
- public com.qiniu.storage.Configuration qiniuConfig() {
- return new com.qiniu.storage.Configuration(Zone.zone2());
- }
-
- /**
- * 构建一个七牛上传工具实例
- */
- @Bean
- public UploadManager uploadManager() {
- return new UploadManager(qiniuConfig());
- }
-
- /**
- * 认证信息实例
- *
- * @return
- */
- @Bean
- public Auth auth() {
- return Auth.create(fileProperties.getOss().getAccessKey(), fileProperties.getOss().getAccessKeySecret());
- }
-
- /**
- * 构建七牛空间管理实例
- */
- @Bean
- public BucketManager bucketManager() {
- return new BucketManager(auth(), qiniuConfig());
- }
-
- @Service
- public class QiniuOssServiceImpl extends AbstractIFileService {
- @Autowired
- private UploadManager uploadManager;
- @Autowired
- private BucketManager bucketManager;
- @Autowired
- private Auth auth;
-
- @Override
- protected String fileType() {
- return fileProperties.getType();
- }
-
- @Override
- protected void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception {
- // 调用put方法上传
- uploadManager.put(file.getBytes(), fileInfo.getName(), auth.uploadToken(fileProperties.getOss().getBucketName()));
- fileInfo.setUrl(fileProperties.getOss().getEndpoint() + "/" + fileInfo.getName());
- fileInfo.setPath(fileProperties.getOss().getEndpoint() + "/" + fileInfo.getName());
- }
-
- @Override
- protected boolean deleteFile(FileInfo fileInfo) {
- try {
- Response response = bucketManager.delete(fileProperties.getOss().getBucketName(), fileInfo.getPath());
- int retry = 0;
- while (response.needRetry() && retry++ < 3) {
- response = bucketManager.delete(fileProperties.getOss().getBucketName(), fileInfo.getPath());
- }
- } catch (QiniuException e) {
- return false;
- }
- return true;
- }
- }
-}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/model/FileInfo.java b/zlt-business/file-center/src/main/java/com/central/file/model/FileInfo.java
index a6622a7b..2e7e300b 100644
--- a/zlt-business/file-center/src/main/java/com/central/file/model/FileInfo.java
+++ b/zlt-business/file-center/src/main/java/com/central/file/model/FileInfo.java
@@ -56,9 +56,4 @@ public class FileInfo extends Model {
private Date createTime;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
-
- @Override
- protected Serializable pkVal() {
- return this.id;
- }
}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/properties/FileServerProperties.java b/zlt-business/file-center/src/main/java/com/central/file/properties/FileServerProperties.java
deleted file mode 100644
index dca0c508..00000000
--- a/zlt-business/file-center/src/main/java/com/central/file/properties/FileServerProperties.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.central.file.properties;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-
-/**
- * @author zlt
- */
-@Setter
-@Getter
-@ConfigurationProperties(prefix = "zlt.file-server")
-@RefreshScope
-public class FileServerProperties {
- /**
- * 为以下3个值,指定不同的自动化配置
- * qiniu:七牛oss
- * aliyun:阿里云oss
- * fastdfs:本地部署的fastDFS
- */
- private String type;
-
- /**
- * oss配置
- */
- OssProperties oss = new OssProperties();
-
- /**
- * fastDFS配置
- */
- FdfsProperties fdfs = new FdfsProperties();
-}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/properties/OssProperties.java b/zlt-business/file-center/src/main/java/com/central/file/properties/OssProperties.java
deleted file mode 100644
index f3300b3b..00000000
--- a/zlt-business/file-center/src/main/java/com/central/file/properties/OssProperties.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.central.file.properties;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @author zlt
- */
-@Setter
-@Getter
-public class OssProperties {
- /**
- * 密钥key
- */
- private String accessKey;
- /**
- * 密钥密码
- */
- private String accessKeySecret;
- /**
- * 端点
- */
- private String endpoint;
- /**
- * bucket名称
- */
- private String bucketName;
- /**
- * 说明
- */
- private String domain;
-}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java b/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java
index 6f97a861..2e44595f 100644
--- a/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java
+++ b/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java
@@ -1,5 +1,6 @@
package com.central.file.service;
+import java.io.OutputStream;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -19,4 +20,6 @@ public interface IFileService extends IService {
PageResult findList(Map params);
void delete(String id);
+
+ void out(String id, OutputStream os);
}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java b/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java
index caf622c8..93e38e1e 100644
--- a/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java
+++ b/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.central.oss.model.ObjectInfo;
import org.apache.commons.collections4.MapUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -27,16 +28,14 @@ public abstract class AbstractIFileService extends ServiceImpl findList(Map params) {
diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/impl/FastdfsService.java b/zlt-business/file-center/src/main/java/com/central/file/service/impl/FastdfsService.java
new file mode 100644
index 00000000..fe54278e
--- /dev/null
+++ b/zlt-business/file-center/src/main/java/com/central/file/service/impl/FastdfsService.java
@@ -0,0 +1,44 @@
+package com.central.file.service.impl;
+
+import com.central.oss.model.ObjectInfo;
+import com.central.oss.properties.FileServerProperties;
+import com.central.oss.template.FdfsTemplate;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.OutputStream;
+
+/**
+ * @author zlt
+ * @date 2021/2/13
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Service
+@ConditionalOnProperty(prefix = com.central.oss.properties.FileServerProperties.PREFIX, name = "type", havingValue = FileServerProperties.TYPE_FDFS)
+public class FastdfsService extends AbstractIFileService {
+ @Resource
+ private FdfsTemplate fdfsTemplate;
+
+ @Override
+ protected String fileType() {
+ return FileServerProperties.TYPE_FDFS;
+ }
+
+ @Override
+ protected ObjectInfo uploadFile(MultipartFile file) {
+ return fdfsTemplate.upload(file);
+ }
+
+ @Override
+ protected void deleteFile(String objectPath) {
+ fdfsTemplate.delete(objectPath);
+ }
+
+ @Override
+ public void out(String id, OutputStream os) {
+ }
+}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/impl/S3Service.java b/zlt-business/file-center/src/main/java/com/central/file/service/impl/S3Service.java
new file mode 100644
index 00000000..f87679d6
--- /dev/null
+++ b/zlt-business/file-center/src/main/java/com/central/file/service/impl/S3Service.java
@@ -0,0 +1,74 @@
+package com.central.file.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.central.common.constant.CommonConstant;
+import com.central.file.model.FileInfo;
+import com.central.oss.model.ObjectInfo;
+import com.central.oss.properties.FileServerProperties;
+import com.central.oss.template.S3Template;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.OutputStream;
+
+/**
+ * @author zlt
+ * @date 2021/2/13
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Service
+@ConditionalOnProperty(prefix = com.central.oss.properties.FileServerProperties.PREFIX, name = "type", havingValue = FileServerProperties.TYPE_S3)
+public class S3Service extends AbstractIFileService {
+ @Resource
+ private S3Template s3Template;
+
+ @Override
+ protected String fileType() {
+ return FileServerProperties.TYPE_S3;
+ }
+
+ @Override
+ protected ObjectInfo uploadFile(MultipartFile file) {
+ return s3Template.upload(file);
+ }
+
+ @Override
+ protected void deleteFile(String objectPath) {
+ S3Object s3Object = parsePath(objectPath);
+ s3Template.delete(s3Object.bucketName, s3Object.objectName);
+ }
+
+ @Override
+ public void out(String id, OutputStream os) {
+ FileInfo fileInfo = baseMapper.selectById(id);
+ if (fileInfo != null) {
+ S3Object s3Object = parsePath(fileInfo.getPath());
+ s3Template.out(s3Object.bucketName, s3Object.objectName, os);
+ }
+ }
+
+ @Setter
+ @Getter
+ private class S3Object {
+ private String bucketName;
+ private String objectName;
+ }
+
+ private S3Object parsePath(String path) {
+ S3Object s3Object = new S3Object();
+ if (StrUtil.isNotEmpty(path)) {
+ int splitIndex = path.lastIndexOf(CommonConstant.PATH_SPLIT);
+ if (splitIndex != -1) {
+ s3Object.bucketName = path.substring(0, splitIndex);
+ s3Object.objectName = path.substring(splitIndex + 1);
+ }
+ }
+ return s3Object;
+ }
+}
diff --git a/zlt-business/file-center/src/main/java/com/central/file/utils/FileUtil.java b/zlt-business/file-center/src/main/java/com/central/file/utils/FileUtil.java
index 6f534561..f1da64e1 100644
--- a/zlt-business/file-center/src/main/java/com/central/file/utils/FileUtil.java
+++ b/zlt-business/file-center/src/main/java/com/central/file/utils/FileUtil.java
@@ -22,10 +22,8 @@ private FileUtil() {
throw new IllegalStateException("Utility class");
}
- public static FileInfo getFileInfo(MultipartFile file) throws Exception {
- //String md5 = fileMd5(file.getInputStream());
+ public static FileInfo getFileInfo(MultipartFile file) {
FileInfo fileInfo = new FileInfo();
- // 将文件的md5设置为文件表的id
fileInfo.setId(IdUtil.fastSimpleUUID());
fileInfo.setName(file.getOriginalFilename());
fileInfo.setContentType(file.getContentType());
diff --git a/zlt-business/file-center/src/main/resources/application.yml b/zlt-business/file-center/src/main/resources/application.yml
index e4c7e8c3..839effbe 100644
--- a/zlt-business/file-center/src/main/resources/application.yml
+++ b/zlt-business/file-center/src/main/resources/application.yml
@@ -15,16 +15,14 @@ mybatis-plus:
zlt:
file-server:
- type: fastdfs
- fdfs:
- web-url: ${zlt.fdfs.web-url}
- #oss配置
- #oss:
- # access-key: tpi8mObnfzZi4ggBX8Bw7zydjoTQ0WeML3RkPKsX
- # accessKeySecret: HZBXmSyUTy-haYp0KbBTtsil-GoKjVS2kDKT8Yow
- # endpoint: http://pkqtmn0p1.bkt.clouddn.com
- # bucketName: public-oss
- # domain:
+ type: s3
+ #fdfs:
+ # web-url: ${zlt.fdfs.web-url}
+ s3:
+ access-key: ${zlt.s3.access-key}
+ accessKeySecret: ${zlt.s3.accessKeySecret}
+ endpoint: ${zlt.s3.endpoint}
+ bucketName: ${zlt.s3.bucketName}
swagger:
enabled: true
title: 文件中心
@@ -36,7 +34,7 @@ zlt:
enable: true
#fastDFS配置
-fdfs:
- soTimeout: 1500
- connectTimeout: 600
- trackerList: ${zlt.fdfs.trackerList}
\ No newline at end of file
+#fdfs:
+# soTimeout: 1500
+# connectTimeout: 600
+# trackerList: ${zlt.fdfs.trackerList}
\ No newline at end of file
diff --git a/zlt-business/pom.xml b/zlt-business/pom.xml
index 25a8ab00..a5ec9e4f 100644
--- a/zlt-business/pom.xml
+++ b/zlt-business/pom.xml
@@ -4,7 +4,7 @@
com.zlt
central-platform
- 3.5.0
+ 5.4.0
zlt-business
业务中心
diff --git a/zlt-business/search-center/pom.xml b/zlt-business/search-center/pom.xml
index 242c4d2f..6a62964c 100644
--- a/zlt-business/search-center/pom.xml
+++ b/zlt-business/search-center/pom.xml
@@ -4,7 +4,7 @@
com.zlt
zlt-business
- 3.5.0
+ 5.4.0
search-center
搜索中心
diff --git a/zlt-business/search-center/search-client/pom.xml b/zlt-business/search-center/search-client/pom.xml
index 67779c85..30188b40 100644
--- a/zlt-business/search-center/search-client/pom.xml
+++ b/zlt-business/search-center/search-client/pom.xml
@@ -4,7 +4,7 @@
com.zlt
search-center
- 3.5.0
+ 5.4.0
search-client
搜索中心客户端
@@ -13,7 +13,7 @@
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
com.zlt
diff --git a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/SearchService.java b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/SearchService.java
index 1f8d3d30..b094f5c2 100644
--- a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/SearchService.java
+++ b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/SearchService.java
@@ -1,10 +1,10 @@
package com.central.search.client.feign;
-import com.alibaba.fastjson.JSONObject;
import com.central.common.constant.ServiceNameConstants;
import com.central.common.model.PageResult;
import com.central.search.client.feign.fallback.SearchServiceFallbackFactory;
import com.central.search.model.SearchDto;
+import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -19,5 +19,5 @@ public interface SearchService {
* @param searchDto 搜索Dto
*/
@PostMapping(value = "/search/{indexName}")
- PageResult strQuery(@PathVariable("indexName") String indexName, @RequestBody SearchDto searchDto);
+ PageResult strQuery(@PathVariable("indexName") String indexName, @RequestBody SearchDto searchDto);
}
diff --git a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/AggregationServiceFallbackFactory.java b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/AggregationServiceFallbackFactory.java
index 86c2534e..bc3b9ff7 100644
--- a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/AggregationServiceFallbackFactory.java
+++ b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/AggregationServiceFallbackFactory.java
@@ -2,7 +2,7 @@
import cn.hutool.core.map.MapUtil;
import com.central.search.client.feign.AggregationService;
-import feign.hystrix.FallbackFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
diff --git a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/SearchServiceFallbackFactory.java b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/SearchServiceFallbackFactory.java
index 7623ef26..ad2cb5b3 100644
--- a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/SearchServiceFallbackFactory.java
+++ b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/feign/fallback/SearchServiceFallbackFactory.java
@@ -1,9 +1,9 @@
package com.central.search.client.feign.fallback;
-import com.alibaba.fastjson.JSONObject;
import com.central.common.model.PageResult;
import com.central.search.client.feign.SearchService;
-import feign.hystrix.FallbackFactory;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.springframework.cloud.openfeign.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
/**
@@ -17,7 +17,7 @@ public class SearchServiceFallbackFactory implements FallbackFactory {
log.error("通过索引{}搜索异常:{}", indexName, throwable);
- return PageResult.builder().build();
+ return PageResult.builder().build();
};
}
}
diff --git a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/IQueryService.java b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/IQueryService.java
index dab65cde..1a282cac 100644
--- a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/IQueryService.java
+++ b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/IQueryService.java
@@ -1,9 +1,9 @@
package com.central.search.client.service;
-import com.alibaba.fastjson.JSONObject;
import com.central.common.model.PageResult;
import com.central.search.model.LogicDelDto;
import com.central.search.model.SearchDto;
+import com.fasterxml.jackson.databind.JsonNode;
import java.util.Map;
@@ -19,7 +19,7 @@ public interface IQueryService {
* @param indexName 索引名
* @param searchDto 搜索Dto
*/
- PageResult strQuery(String indexName, SearchDto searchDto);
+ PageResult strQuery(String indexName, SearchDto searchDto);
/**
* 查询文档列表
@@ -27,7 +27,7 @@ public interface IQueryService {
* @param searchDto 搜索Dto
* @param logicDelDto 逻辑删除Dto
*/
- PageResult strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto);
+ PageResult strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto);
/**
* 访问统计聚合查询
diff --git a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/impl/QueryServiceImpl.java b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/impl/QueryServiceImpl.java
index d4798919..221faafe 100644
--- a/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/impl/QueryServiceImpl.java
+++ b/zlt-business/search-center/search-client/src/main/java/com/central/search/client/service/impl/QueryServiceImpl.java
@@ -1,13 +1,13 @@
package com.central.search.client.service.impl;
import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
import com.central.common.model.PageResult;
import com.central.search.client.feign.AggregationService;
import com.central.search.client.feign.SearchService;
import com.central.search.client.service.IQueryService;
import com.central.search.model.LogicDelDto;
import com.central.search.model.SearchDto;
+import com.fasterxml.jackson.databind.JsonNode;
import javax.annotation.Resource;
import java.util.Map;
@@ -26,12 +26,12 @@ public class QueryServiceImpl implements IQueryService {
private AggregationService aggregationService;
@Override
- public PageResult strQuery(String indexName, SearchDto searchDto) {
+ public PageResult strQuery(String indexName, SearchDto searchDto) {
return strQuery(indexName, searchDto, null);
}
@Override
- public PageResult strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto) {
+ public PageResult strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto) {
setLogicDelQueryStr(searchDto, logicDelDto);
return searchService.strQuery(indexName, searchDto);
}
diff --git a/zlt-business/search-center/search-client/src/main/java/com/central/search/model/SearchDto.java b/zlt-business/search-center/search-client/src/main/java/com/central/search/model/SearchDto.java
index 71f24ebe..e1a06530 100644
--- a/zlt-business/search-center/search-client/src/main/java/com/central/search/model/SearchDto.java
+++ b/zlt-business/search-center/search-client/src/main/java/com/central/search/model/SearchDto.java
@@ -2,8 +2,6 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
import java.io.Serializable;
@@ -31,6 +29,10 @@ public class SearchDto implements Serializable {
* 排序字段
*/
private String sortCol;
+ /**
+ * 排序顺序
+ */
+ private String sortOrder = "DESC";
/**
* 是否显示高亮
*/
diff --git a/zlt-business/search-center/search-server/pom.xml b/zlt-business/search-center/search-server/pom.xml
index f258d2ee..8a2330d7 100644
--- a/zlt-business/search-center/search-server/pom.xml
+++ b/zlt-business/search-center/search-server/pom.xml
@@ -4,7 +4,7 @@
com.zlt
search-center
- 3.5.0
+ 5.4.0
search-server
搜索中心服务端
@@ -60,6 +60,11 @@
io.micrometer
micrometer-registry-prometheus
+
+
+ org.hibernate
+ hibernate-validator
+
diff --git a/zlt-business/search-center/search-server/src/main/java/com/central/admin/service/impl/IndexServiceImpl.java b/zlt-business/search-center/search-server/src/main/java/com/central/admin/service/impl/IndexServiceImpl.java
index 9c15eabe..f4ad351f 100644
--- a/zlt-business/search-center/search-server/src/main/java/com/central/admin/service/impl/IndexServiceImpl.java
+++ b/zlt-business/search-center/search-server/src/main/java/com/central/admin/service/impl/IndexServiceImpl.java
@@ -1,51 +1,51 @@
package com.central.admin.service.impl;
import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.central.admin.model.IndexDto;
import com.central.admin.service.IIndexService;
import com.central.common.model.PageResult;
+import com.central.common.utils.JsonUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.util.EntityUtils;
-import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
-import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.CreateIndexResponse;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.elasticsearch.client.indices.GetIndexResponse;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
-import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
-import org.elasticsearch.cluster.metadata.AliasMetaData;
-import org.elasticsearch.cluster.metadata.MappingMetaData;
-import org.elasticsearch.common.collect.ImmutableOpenMap;
+import org.elasticsearch.cluster.metadata.AliasMetadata;
+import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* 索引
*
* @author zlt
* @date 2019/4/23
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
@Service
public class IndexServiceImpl implements IIndexService {
- @Autowired
- private ElasticsearchRestTemplate elasticsearchRestTemplate;
-
private ObjectMapper mapper = new ObjectMapper();
+ private final RestHighLevelClient client;
+
+ public IndexServiceImpl(RestHighLevelClient client) {
+ this.client = client;
+ }
+
@Override
public boolean create(IndexDto indexDto) throws IOException {
CreateIndexRequest request = new CreateIndexRequest(indexDto.getIndexName());
@@ -53,11 +53,11 @@ public boolean create(IndexDto indexDto) throws IOException {
.put("index.number_of_shards", indexDto.getNumberOfShards())
.put("index.number_of_replicas", indexDto.getNumberOfReplicas())
);
- if (StrUtil.isNotEmpty(indexDto.getType()) && StrUtil.isNotEmpty(indexDto.getMappingsSource())) {
+ if (StrUtil.isNotEmpty(indexDto.getMappingsSource())) {
//mappings
- request.mapping(indexDto.getType(), indexDto.getMappingsSource(), XContentType.JSON);
+ request.mapping(indexDto.getMappingsSource(), XContentType.JSON);
}
- CreateIndexResponse response = elasticsearchRestTemplate.getClient()
+ CreateIndexResponse response = client
.indices()
.create(request, RequestOptions.DEFAULT);
return response.isAcknowledged();
@@ -66,13 +66,16 @@ public boolean create(IndexDto indexDto) throws IOException {
@Override
public boolean delete(String indexName) throws IOException {
DeleteIndexRequest request = new DeleteIndexRequest(indexName);
- AcknowledgedResponse response = elasticsearchRestTemplate.getClient().indices().delete(request, RequestOptions.DEFAULT);
+ AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT);
return response.isAcknowledged();
}
@Override
public PageResult
com.zlt
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
com.zlt
@@ -52,11 +52,6 @@
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
-
- org.springframework
- spring-context-support
-
-
org.springframework.boot
spring-boot-starter-actuator
@@ -71,10 +66,14 @@
io.micrometer
micrometer-registry-prometheus
-
- org.springframework.social
- spring-social-security
+ junit
+ junit
+ test
+
+
+ org.hibernate
+ hibernate-validator
diff --git a/zlt-business/user-center/src/main/java/com/central/UserCenterApp.java b/zlt-business/user-center/src/main/java/com/central/UserCenterApp.java
index 4ba97bcd..5da788be 100644
--- a/zlt-business/user-center/src/main/java/com/central/UserCenterApp.java
+++ b/zlt-business/user-center/src/main/java/com/central/UserCenterApp.java
@@ -1,6 +1,6 @@
package com.central;
-import com.central.common.ribbon.annotation.EnableFeignInterceptor;
+import com.central.common.lb.annotation.EnableFeignInterceptor;
import com.central.search.annotation.EnableSearchClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/zlt-business/user-center/src/main/java/com/central/user/controller/SysMenuController.java b/zlt-business/user-center/src/main/java/com/central/user/controller/SysMenuController.java
index 531844f5..064f6019 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/controller/SysMenuController.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/controller/SysMenuController.java
@@ -5,11 +5,11 @@
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.ObjectUtil;
import com.central.common.annotation.LoginUser;
import com.central.common.constant.CommonConstant;
import com.central.common.model.*;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
@@ -40,7 +40,7 @@ public class SysMenuController {
public static List treeBuilder(List sysMenus) {
List menus = new ArrayList<>();
for (SysMenu sysMenu : sysMenus) {
- if (ObjectUtils.equals(-1L, sysMenu.getParentId())) {
+ if (ObjectUtil.equal(-1L, sysMenu.getParentId())) {
menus.add(sysMenu);
}
for (SysMenu menu : sysMenus) {
@@ -167,7 +167,7 @@ public List findMyMenu(@LoginUser SysUser user) {
if (CollectionUtil.isEmpty(roles)) {
return Collections.emptyList();
}
- List menus = menuService.findByRoleCodes(roles.parallelStream().map(SysRole::getCode).collect(Collectors.toSet()), CommonConstant.MENU);
+ List menus = menuService.findByRoleCodes(roles.stream().map(SysRole::getCode).collect(Collectors.toSet()), CommonConstant.MENU);
return treeBuilder(menus);
}
}
diff --git a/zlt-business/user-center/src/main/java/com/central/user/controller/SysRoleController.java b/zlt-business/user-center/src/main/java/com/central/user/controller/SysRoleController.java
index 9cccefc4..80de7d23 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/controller/SysRoleController.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/controller/SysRoleController.java
@@ -61,7 +61,7 @@ public Result> findAll() {
* @return
*/
@PostMapping("/roles/saveOrUpdate")
- public Result saveOrUpdate(@RequestBody SysRole sysRole) {
+ public Result saveOrUpdate(@RequestBody SysRole sysRole) throws Exception {
return sysRoleService.saveOrUpdateRole(sysRole);
}
diff --git a/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java b/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java
index 0db93f8b..01d84597 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/controller/SysUserController.java
@@ -7,7 +7,6 @@
import java.util.Set;
import cn.hutool.core.bean.BeanUtil;
-import com.alibaba.fastjson.JSONObject;
import com.central.common.annotation.LoginUser;
import com.central.common.constant.CommonConstant;
import com.central.common.model.*;
@@ -18,6 +17,7 @@
import com.central.search.model.LogicDelDto;
import com.central.search.model.SearchDto;
import com.central.user.model.SysUserExcel;
+import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
@@ -236,7 +236,7 @@ public Result delete(@PathVariable Long id) {
@CacheEvict(value = "user", key = "#sysUser.username")
@PostMapping("/users/saveOrUpdate")
@AuditLog(operation = "'新增或更新用户:' + #sysUser.username")
- public Result saveOrUpdate(@RequestBody SysUser sysUser) {
+ public Result saveOrUpdate(@RequestBody SysUser sysUser) throws Exception {
return appUserService.saveOrUpdateUser(sysUser);
}
@@ -280,7 +280,7 @@ public Result importExcl(@RequestParam("file") MultipartFile excl) throws Except
@ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String")
})
@GetMapping("/users/search")
- public PageResult search(SearchDto searchDto) {
+ public PageResult search(SearchDto searchDto) {
searchDto.setIsHighlighter(true);
searchDto.setSortCol("createTime");
return queryService.strQuery("sys_user", searchDto, SEARCH_LOGIC_DEL_DTO);
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java b/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java
index 716a48a5..2d29f858 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java
@@ -9,10 +9,13 @@
import com.central.common.service.ISuperService;
/**
-* @author zlt
+ * @author zlt
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
public interface ISysRoleService extends ISuperService {
- void saveRole(SysRole sysRole);
+ void saveRole(SysRole sysRole) throws Exception;
void deleteRole(Long id);
@@ -28,7 +31,7 @@ public interface ISysRoleService extends ISuperService {
* @param sysRole
* @return Result
*/
- Result saveOrUpdateRole(SysRole sysRole);
+ Result saveOrUpdateRole(SysRole sysRole) throws Exception;
/**
* 查询所有角色
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java b/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java
index 26adcb5d..aaf899fd 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java
@@ -13,7 +13,10 @@
import com.central.common.model.SysUser;
/**
-* @author zlt
+ * @author zlt
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
public interface ISysUserService extends ISuperService {
/**
@@ -98,7 +101,7 @@ public interface ISysUserService extends ISuperService {
*/
List findAllUsers(Map params);
- Result saveOrUpdateUser(SysUser sysUser);
+ Result saveOrUpdateUser(SysUser sysUser) throws Exception;
/**
* 删除用户
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java
index 4d28373d..8550e08d 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java
@@ -29,7 +29,7 @@
@Slf4j
@Service
public class SysRoleServiceImpl extends SuperServiceImpl implements ISysRoleService {
- private final static String LOCK_KEY_ROLECODE = CommonConstant.LOCK_KEY_PREFIX+"rolecode:";
+ private final static String LOCK_KEY_ROLECODE = "rolecode:";
@Resource
private SysUserRoleMapper userRoleMapper;
@@ -42,7 +42,7 @@ public class SysRoleServiceImpl extends SuperServiceImpl
@Transactional(rollbackFor = Exception.class)
@Override
- public void saveRole(SysRole sysRole) {
+ public void saveRole(SysRole sysRole) throws Exception {
String roleCode = sysRole.getCode();
super.saveIdempotency(sysRole, lock
, LOCK_KEY_ROLECODE+roleCode, new QueryWrapper().eq("code", roleCode), "角色code已存在");
@@ -67,7 +67,7 @@ public PageResult findRoles(Map params) {
@Override
@Transactional
- public Result saveOrUpdateRole(SysRole sysRole) {
+ public Result saveOrUpdateRole(SysRole sysRole) throws Exception {
if (sysRole.getId() == null) {
this.saveRole(sysRole);
} else {
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java
index ce667390..eedada4c 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java
@@ -37,7 +37,7 @@
@Slf4j
@Service
public class SysUserServiceImpl extends SuperServiceImpl implements ISysUserService {
- private final static String LOCK_KEY_USERNAME = CommonConstant.LOCK_KEY_PREFIX+"username:";
+ private final static String LOCK_KEY_USERNAME = "username:";
@Autowired
private PasswordEncoder passwordEncoder;
@@ -80,10 +80,10 @@ public LoginAppUser getLoginAppUser(SysUser sysUser) {
loginAppUser.setRoles(sysRoles);
if (!CollectionUtils.isEmpty(sysRoles)) {
- Set roleIds = sysRoles.parallelStream().map(SuperEntity::getId).collect(Collectors.toSet());
+ Set roleIds = sysRoles.stream().map(SuperEntity::getId).collect(Collectors.toSet());
List menus = roleMenuMapper.findMenusByRoleIds(roleIds, CommonConstant.PERMISSION);
if (!CollectionUtils.isEmpty(menus)) {
- Set permissions = menus.parallelStream().map(p -> p.getPath())
+ Set permissions = menus.stream().map(p -> p.getPath())
.collect(Collectors.toSet());
// 设置权限集合
loginAppUser.setPermissions(permissions);
@@ -219,7 +219,7 @@ public Result updateEnabled(Map params) {
@Transactional(rollbackFor = Exception.class)
@Override
- public Result saveOrUpdateUser(SysUser sysUser) {
+ public Result saveOrUpdateUser(SysUser sysUser) throws Exception {
if (sysUser.getId() == null) {
if (StringUtils.isBlank(sysUser.getType())) {
sysUser.setType(UserType.BACKEND.name());
diff --git a/zlt-business/user-center/src/main/resources/application.yml b/zlt-business/user-center/src/main/resources/application.yml
index a9c65586..f9a8c71b 100644
--- a/zlt-business/user-center/src/main/resources/application.yml
+++ b/zlt-business/user-center/src/main/resources/application.yml
@@ -34,7 +34,10 @@ zlt:
- sys_role_user
- sys_role_menu
ignoreSqls:
+ # 用户关联角色时,显示所有角色
- com.central.user.mapper.SysRoleMapper.findAll
+ # 用户列表显示用户所关联的所有角色
+ - com.central.user.mapper.SysUserRoleMapper.findRolesByUserIds
#审计日志
# audit-log:
# enabled: true
diff --git a/zlt-commons/pom.xml b/zlt-commons/pom.xml
index 2fbe456a..617efea0 100644
--- a/zlt-commons/pom.xml
+++ b/zlt-commons/pom.xml
@@ -4,7 +4,7 @@
com.zlt
central-platform
- 3.5.0
+ 5.4.0
zlt-commons
通用组件
@@ -16,10 +16,12 @@
zlt-db-spring-boot-starter
zlt-swagger2-spring-boot-starter
zlt-log-spring-boot-starter
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
zlt-auth-client-spring-boot-starter
zlt-sentinel-spring-boot-starter
zlt-common-core
zlt-elasticsearch-spring-boot-starter
+ zlt-oss-spring-boot-starter
+ zlt-zookeeper-spring-boot-starter
\ No newline at end of file
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml b/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml
index 710df120..f6a3d8a4 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
com.zlt
zlt-commons
- 3.5.0
+ 5.4.0
4.0.0
jar
@@ -42,5 +42,10 @@
javax.servlet-api
provided
+
+ org.apache.tomcat.embed
+ tomcat-embed-websocket
+ true
+
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/AuthClientAutoConfiguration.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/AuthClientAutoConfiguration.java
new file mode 100644
index 00000000..17ede133
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/AuthClientAutoConfiguration.java
@@ -0,0 +1,21 @@
+package com.central.oauth2.common;
+
+import com.central.oauth2.common.properties.SecurityProperties;
+import com.central.oauth2.common.properties.TokenStoreProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+
+/**
+ * 鉴权自动配置
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/7/24
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@EnableConfigurationProperties({SecurityProperties.class, TokenStoreProperties.class})
+@ComponentScan
+public class AuthClientAutoConfiguration {
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/DefaultResourceServerConf.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/DefaultResourceServerConf.java
index e3c4ccf7..71e6d114 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/DefaultResourceServerConf.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/DefaultResourceServerConf.java
@@ -9,6 +9,7 @@
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.authentication.TokenExtractor;
import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler;
import org.springframework.security.oauth2.provider.expression.OAuth2WebSecurityExpressionHandler;
import org.springframework.security.oauth2.provider.token.TokenStore;
@@ -36,13 +37,17 @@ public class DefaultResourceServerConf extends ResourceServerConfigurerAdapter {
@Autowired
private SecurityProperties securityProperties;
+ @Resource
+ private TokenExtractor tokenExtractor;
+
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
resources.tokenStore(tokenStore)
.stateless(true)
.authenticationEntryPoint(authenticationEntryPoint)
.expressionHandler(expressionHandler)
- .accessDeniedHandler(oAuth2AccessDeniedHandler);
+ .accessDeniedHandler(oAuth2AccessDeniedHandler)
+ .tokenExtractor(tokenExtractor);
}
@Override
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/SecurityPropertiesConfig.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/SecurityPropertiesConfig.java
deleted file mode 100644
index e85ed2a2..00000000
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/SecurityPropertiesConfig.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.central.oauth2.common.config;
-
-import com.central.oauth2.common.properties.SecurityProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-
-/**
- * @author zlt
- * @date 2019/10/7
- *
- * Blog: https://blog.csdn.net/zlt2000
- * Github: https://github.com/zlt2000
- */
-@EnableConfigurationProperties(SecurityProperties.class)
-public class SecurityPropertiesConfig {
-}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/WcAuthConfigurator.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/WcAuthConfigurator.java
new file mode 100644
index 00000000..26caf368
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/WcAuthConfigurator.java
@@ -0,0 +1,34 @@
+package com.central.oauth2.common.config;
+
+import com.central.oauth2.common.util.AuthUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.websocket.server.ServerEndpointConfig;
+
+/**
+ * webSocket鉴权配置
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2022/5/8
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Slf4j
+public class WcAuthConfigurator extends ServerEndpointConfig.Configurator {
+ @Override
+ public boolean checkOrigin(String originHeaderValue) {
+ ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+ try {
+ //检查token有效性
+ AuthUtils.checkAccessToken(servletRequestAttributes.getRequest());
+ } catch (Exception e) {
+ log.error("WebSocket-auth-error", e);
+ return false;
+ }
+ return super.checkOrigin(originHeaderValue);
+ }
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/constants/IdTokenClaimNames.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/constants/IdTokenClaimNames.java
new file mode 100644
index 00000000..23865987
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/constants/IdTokenClaimNames.java
@@ -0,0 +1,89 @@
+package com.central.oauth2.common.constants;
+
+/**
+ * id_token属性名常量
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/4/23
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+public class IdTokenClaimNames {
+ /**
+ * {@code iss} - the Issuer identifier
+ */
+ public final static String ISS = "iss";
+
+ /**
+ * {@code sub} - the Subject identifier
+ */
+ public final static String SUB = "sub";
+
+ /**
+ * {@code aud} - the Audience(s) that the ID Token is intended for
+ */
+ public final static String AUD = "aud";
+
+ /**
+ * {@code exp} - the Expiration time on or after which the ID Token MUST NOT be accepted
+ */
+ public final static String EXP = "exp";
+
+ /**
+ * {@code iat} - the time at which the ID Token was issued
+ */
+ public final static String IAT = "iat";
+
+ /**
+ * {@code auth_time} - the time when the End-User authentication occurred
+ */
+ public final static String AUTH_TIME = "auth_time";
+
+ /**
+ * {@code nonce} - a {@code String} value used to associate a Client session with an ID Token,
+ * and to mitigate replay attacks.
+ */
+ public final static String NONCE = "nonce";
+
+ /**
+ * {@code acr} - the Authentication Context Class Reference
+ */
+ public final static String ACR = "acr";
+
+ /**
+ * {@code amr} - the Authentication Methods References
+ */
+ public final static String AMR = "amr";
+
+ /**
+ * {@code azp} - the Authorized party to which the ID Token was issued
+ */
+ public final static String AZP = "azp";
+
+ /**
+ * {@code at_hash} - the Access Token hash value
+ */
+ public final static String AT_HASH = "at_hash";
+
+ /**
+ * {@code c_hash} - the Authorization Code hash value
+ */
+ public final static String C_HASH = "c_hash";
+
+ /**
+ * {@code name} - 用户姓名
+ */
+ public final static String NAME = "name";
+
+ /**
+ * {@code login_name} - 登录名
+ */
+ public final static String L_NAME = "login_name";
+
+ /**
+ * {@code picture} - 头像照片
+ */
+ public final static String PIC = "picture";
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java
index 7bf24315..fbc86581 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java
@@ -1,5 +1,6 @@
package com.central.oauth2.common.converter;
+import com.central.common.model.LoginAppUser;
import com.central.common.model.SysUser;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -68,7 +69,7 @@ public Authentication extractAuthentication(Map map) {
principal = user;
} else {
Integer id = (Integer)map.get("id");
- SysUser user = new SysUser();
+ LoginAppUser user = new LoginAppUser();
user.setUsername((String)principal);
user.setId(Long.valueOf(id));
principal = user;
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java
index bdc0048c..c89860b9 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java
@@ -28,4 +28,23 @@ public class AuthProperties {
* url权限配置
*/
private UrlPermissionProperties urlPermission = new UrlPermissionProperties();
+
+ /**
+ * 是否开启统一登出
+ * 1. 登出时把同一个用户名下的所有token都注销
+ * 2. 登出信息通知所有单点登录系统
+ */
+ private Boolean unifiedLogout = false;
+
+ /**
+ * 是否同应用同账号登录互踢
+ */
+ private Boolean isSingleLogin = false;
+
+ /**
+ * 是否同应用同账号登录时共用token
+ * true: 多个用户使用同一账号登录时共用一个token
+ * false: 就算使用同一账号登录时都会新建一个token
+ */
+ private Boolean isShareToken = true;
}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java
index 16a5b653..e0c3c15f 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java
@@ -23,6 +23,7 @@ public class PermitProperties {
"/*/v2/api-docs",
"/swagger/api-docs",
"/swagger-ui.html",
+ "/doc.html",
"/swagger-resources/**",
"/webjars/**",
"/druid/**"
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/TokenStoreProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/TokenStoreProperties.java
new file mode 100644
index 00000000..0f2687fb
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/TokenStoreProperties.java
@@ -0,0 +1,27 @@
+package com.central.oauth2.common.properties;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+
+/**
+ * Token配置
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/5/19
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Setter
+@Getter
+@ConfigurationProperties(prefix = "zlt.oauth2.token.store")
+@RefreshScope
+public class TokenStoreProperties {
+ /**
+ * token存储类型(redis/db/authJwt/resJwt)
+ */
+ private String type = "redis";
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/CustomBearerTokenExtractor.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/CustomBearerTokenExtractor.java
new file mode 100644
index 00000000..cc21489d
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/CustomBearerTokenExtractor.java
@@ -0,0 +1,44 @@
+package com.central.oauth2.common.service.impl;
+
+import com.central.oauth2.common.properties.SecurityProperties;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.oauth2.provider.authentication.BearerTokenExtractor;
+import org.springframework.stereotype.Component;
+import org.springframework.util.AntPathMatcher;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 自定义 TokenExtractor
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2022/6/4
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@ConditionalOnClass(HttpServletRequest.class)
+@Component
+public class CustomBearerTokenExtractor extends BearerTokenExtractor {
+ @Resource
+ private SecurityProperties securityProperties;
+
+ private final AntPathMatcher antPathMatcher = new AntPathMatcher();
+
+ /**
+ * 解决只要请求携带access_token,排除鉴权的url依然会被拦截
+ */
+ @Override
+ public Authentication extract(HttpServletRequest request) {
+ //判断当前请求为排除鉴权的url时,直接返回null
+ for (String url : securityProperties.getIgnore().getUrls()) {
+ if (antPathMatcher.match(url, request.getRequestURI())) {
+ return null;
+ }
+ }
+ return super.extract(request);
+ }
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
index 954cf054..c08a178b 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
@@ -25,6 +25,9 @@
*
* @author zlt
* @date 2018/10/28
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
@Slf4j
public abstract class DefaultPermissionServiceImpl {
@@ -32,7 +35,7 @@ public abstract class DefaultPermissionServiceImpl {
@Autowired
private SecurityProperties securityProperties;
- private AntPathMatcher antPathMatcher = new AntPathMatcher();
+ private final AntPathMatcher antPathMatcher = new AntPathMatcher();
/**
* 查询当前用户拥有的资源权限
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java
index d084e549..1d0b1ec9 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java
@@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
@@ -14,6 +15,7 @@
* @author zlt
* @date 2018/7/24 16:23
*/
+@Configuration
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "db")
public class AuthDbTokenStore {
@Autowired
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java
index 9b99fb79..2d261222 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java
@@ -5,6 +5,8 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.bootstrap.encrypt.KeyProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
@@ -23,16 +25,14 @@
*
* @author zlt
* @date 2018/7/24 16:21
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
+@Configuration
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "authJwt")
public class AuthJwtTokenStore {
-
- @Bean("keyProp")
- public KeyProperties keyProperties() {
- return new KeyProperties();
- }
-
- @Resource(name = "keyProp")
+ @Resource
private KeyProperties keyProperties;
@Bean
@@ -41,6 +41,7 @@ public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
}
@Bean
+ @Order(2)
public JwtAccessTokenConverter jwtAccessTokenConverter() {
final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
KeyPair keyPair = new KeyStoreKeyFactory
@@ -51,25 +52,4 @@ public JwtAccessTokenConverter jwtAccessTokenConverter() {
tokenConverter.setUserTokenConverter(new CustomUserAuthenticationConverter());
return converter;
}
-
- /**
- * jwt 生成token 定制化处理
- * 添加一些额外的用户信息到token里面
- *
- * @return TokenEnhancer
- */
- @Bean
- public TokenEnhancer tokenEnhancer() {
- return (accessToken, authentication) -> {
- final Map additionalInfo = new HashMap<>(1);
- Object principal = authentication.getPrincipal();
- //增加id参数
- if (principal instanceof SysUser) {
- SysUser user = (SysUser)principal;
- additionalInfo.put("id", user.getId());
- }
- ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
- return accessToken;
- };
- }
}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java
index a8651589..239dc420 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java
@@ -4,7 +4,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.security.oauth2.provider.token.TokenStore;
/**
@@ -13,17 +15,15 @@
*
* @author zlt
* @date 2018/7/25 9:36
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
+@Configuration
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "redis", matchIfMissing = true)
public class AuthRedisTokenStore {
- @Autowired
- private RedisConnectionFactory connectionFactory;
-
- @Autowired
- private SecurityProperties securityProperties;
-
@Bean
- public TokenStore tokenStore() {
- return new CustomRedisTokenStore(connectionFactory, securityProperties);
+ public TokenStore tokenStore(RedisConnectionFactory connectionFactory, SecurityProperties securityProperties, RedisSerializer