commit
18a1b09dc9
1214 changed files with 155550 additions and 0 deletions
@ -0,0 +1,7 @@ |
||||
# Created by .ignore support plugin (hsz.mobi) |
||||
out/ |
||||
target/ |
||||
.idea/ |
||||
*.log |
||||
*.gz |
||||
*.iml |
@ -0,0 +1,201 @@ |
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
http://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, |
||||
and distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by |
||||
the copyright owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all |
||||
other entities that control, are controlled by, or are under common |
||||
control with that entity. For the purposes of this definition, |
||||
"control" means (i) the power, direct or indirect, to cause the |
||||
direction or management of such entity, whether by contract or |
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity |
||||
exercising permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, |
||||
including but not limited to software source code, documentation |
||||
source, and configuration files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical |
||||
transformation or translation of a Source form, including but |
||||
not limited to compiled object code, generated documentation, |
||||
and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or |
||||
Object form, made available under the License, as indicated by a |
||||
copyright notice that is included in or attached to the work |
||||
(an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object |
||||
form, that is based on (or derived from) the Work and for which the |
||||
editorial revisions, annotations, elaborations, or other modifications |
||||
represent, as a whole, an original work of authorship. For the purposes |
||||
of this License, Derivative Works shall not include works that remain |
||||
separable from, or merely link (or bind by name) to the interfaces of, |
||||
the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including |
||||
the original version of the Work and any modifications or additions |
||||
to that Work or Derivative Works thereof, that is intentionally |
||||
submitted to Licensor for inclusion in the Work by the copyright owner |
||||
or by an individual or Legal Entity authorized to submit on behalf of |
||||
the copyright owner. For the purposes of this definition, "submitted" |
||||
means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, |
||||
and issue tracking systems that are managed by, or on behalf of, the |
||||
Licensor for the purpose of discussing and improving the Work, but |
||||
excluding communication that is conspicuously marked or otherwise |
||||
designated in writing by the copyright owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||
on behalf of whom a Contribution has been received by Licensor and |
||||
subsequently incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the |
||||
Work and such Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
(except as stated in this section) patent license to make, have made, |
||||
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||
where such license applies only to those patent claims licensable |
||||
by such Contributor that are necessarily infringed by their |
||||
Contribution(s) alone or by combination of their Contribution(s) |
||||
with the Work to which such Contribution(s) was submitted. If You |
||||
institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||
or a Contribution incorporated within the Work constitutes direct |
||||
or contributory patent infringement, then any patent licenses |
||||
granted to You under this License for that Work shall terminate |
||||
as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the |
||||
Work or Derivative Works thereof in any medium, with or without |
||||
modifications, and in Source or Object form, provided that You |
||||
meet the following conditions: |
||||
|
||||
(a) You must give any other recipients of the Work or |
||||
Derivative Works a copy of this License; and |
||||
|
||||
(b) You must cause any modified files to carry prominent notices |
||||
stating that You changed the files; and |
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works |
||||
that You distribute, all copyright, patent, trademark, and |
||||
attribution notices from the Source form of the Work, |
||||
excluding those notices that do not pertain to any part of |
||||
the Derivative Works; and |
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its |
||||
distribution, then any Derivative Works that You distribute must |
||||
include a readable copy of the attribution notices contained |
||||
within such NOTICE file, excluding those notices that do not |
||||
pertain to any part of the Derivative Works, in at least one |
||||
of the following places: within a NOTICE text file distributed |
||||
as part of the Derivative Works; within the Source form or |
||||
documentation, if provided along with the Derivative Works; or, |
||||
within a display generated by the Derivative Works, if and |
||||
wherever such third-party notices normally appear. The contents |
||||
of the NOTICE file are for informational purposes only and |
||||
do not modify the License. You may add Your own attribution |
||||
notices within Derivative Works that You distribute, alongside |
||||
or as an addendum to the NOTICE text from the Work, provided |
||||
that such additional attribution notices cannot be construed |
||||
as modifying the License. |
||||
|
||||
You may add Your own copyright statement to Your modifications and |
||||
may provide additional or different license terms and conditions |
||||
for use, reproduction, or distribution of Your modifications, or |
||||
for any such Derivative Works as a whole, provided Your use, |
||||
reproduction, and distribution of the Work otherwise complies with |
||||
the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||
any Contribution intentionally submitted for inclusion in the Work |
||||
by You to the Licensor shall be under the terms and conditions of |
||||
this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify |
||||
the terms of any separate license agreement you may have executed |
||||
with Licensor regarding such Contributions. |
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade |
||||
names, trademarks, service marks, or product names of the Licensor, |
||||
except as required for reasonable and customary use in describing the |
||||
origin of the Work and reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or |
||||
agreed to in writing, Licensor provides the Work (and each |
||||
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||
implied, including, without limitation, any warranties or conditions |
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||
appropriateness of using or redistributing the Work and assume any |
||||
risks associated with Your exercise of permissions under this License. |
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, |
||||
whether in tort (including negligence), contract, or otherwise, |
||||
unless required by applicable law (such as deliberate and grossly |
||||
negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, |
||||
incidental, or consequential damages of any character arising as a |
||||
result of this License or out of the use or inability to use the |
||||
Work (including but not limited to damages for loss of goodwill, |
||||
work stoppage, computer failure or malfunction, or any and all |
||||
other commercial damages or losses), even if such Contributor |
||||
has been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing |
||||
the Work or Derivative Works thereof, You may choose to offer, |
||||
and charge a fee for, acceptance of support, warranty, indemnity, |
||||
or other liability obligations and/or rights consistent with this |
||||
License. However, in accepting such obligations, You may act only |
||||
on Your own behalf and on Your sole responsibility, not on behalf |
||||
of any other Contributor, and only if You agree to indemnify, |
||||
defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason |
||||
of your accepting any such warranty or additional liability. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
APPENDIX: How to apply the Apache License to your work. |
||||
|
||||
To apply the Apache License to your work, attach the following |
||||
boilerplate notice, with the fields enclosed by brackets "[]" |
||||
replaced with your own identifying information. (Don't include |
||||
the brackets!) The text should be enclosed in the appropriate |
||||
comment syntax for the file format. We also recommend that a |
||||
file or class name and description of purpose be included on the |
||||
same "printed page" as the copyright notice for easier |
||||
identification within third-party archives. |
||||
|
||||
Copyright (c) 2020-2030 liuh(ov_001@163.com) https://www.quafer.cn |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
@ -0,0 +1,196 @@ |
||||
<p align="center"><img src="./documents/readme/images/logo2.png" height="150" width="200" alt="logo"/></p> |
||||
<h2 align="center">简洁优雅 · 稳定高效 | 宁静致远 · 精益求精 </h2> |
||||
<p align="center">quafer Engine 基于 Spring Boot 2.X, 是 quafer Cloud 微服务架构内核核心组件库,可用于任何 Spring Boot 工程</p> |
||||
|
||||
--- |
||||
|
||||
<p align="center"> |
||||
<a href="https://github.com/spring-projects/spring-authorization-server" target="_blank"><img src="https://img.shields.io/badge/Spring%20Authorization%20Server-0.4.0-blue" alt="Spring Authorization Server 0.4.0"></a> |
||||
<a href="https://spring.io/projects/spring-boot" target="_blank"><img src="https://shields.io/badge/Spring%20Boot-2.7.8-blue" alt="Spring Boot 2.7.8"></a> |
||||
<a href="https://spring.io/projects/spring-cloud" target="_blank"><img src="https://shields.io/badge/Spring%20Cloud-2021.0.5-blue" alt="Spring Cloud 2021.0.5"></a> |
||||
<a href="https://github.com/alibaba/spring-cloud-alibaba" target="_blank"><img src="https://shields.io/badge/Spring%20Cloud%20Alibaba-2021.0.4.0-blue" alt="Spring Cloud Alibaba 2021.0.4.0"></a> |
||||
<a href="https://nacos.io/zh-cn/index.html" target="_blank"><img src="https://shields.io/badge/Nacos-2.2.0-brightgreen" alt="Nacos 2.2.0"></a> |
||||
</p> |
||||
<p align="center"> |
||||
<a href="#" target="_blank"><img src="https://shields.io/badge/Version-2.7.8.0-red" alt="Version 2.7.8.0"></a> |
||||
<a href="https://www.oracle.com/java/technologies/javase-downloads.html" target="_blank"><img src="https://img.shields.io/badge/JDK-8%2C11%2C17-green" alt="Java 8,11,17"></a> |
||||
<a href="./LICENSE"><img src="https://shields.io/badge/License-Apache--2.0-blue" alt="License Apache 2.0"></a> |
||||
<a href="https://blog.csdn.net/Pointer_v" target="_blank"><img src="https://shields.io/badge/Author-%E7%A0%81%E5%8C%A0%E5%90%9B-orange" alt="码匠君"></a> |
||||
<a href="https://gitee.com/dromara/quafer-cloud"><img src="https://img.shields.io/github/stars/quafer-cloud/quafer-cloud?style=flat&logo=github" alt="Github star"></a> |
||||
<a href="https://gitee.com/dromara/quafer-cloud"><img src="https://img.shields.io/github/forks/quafer-cloud/quafer-cloud?style=flat&logo=github" alt="Github fork"></a> |
||||
<a href="https://gitee.com/dromara/quafer-cloud"><img src="https://gitee.com/dromara/quafer-cloud/badge/star.svg?theme=dark" alt="Gitee star"></a> |
||||
<a href="https://gitee.com/dromara/quafer-cloud"><img src="https://gitee.com/dromara/quafer-cloud/badge/fork.svg?theme=dark" alt="Gitee fork"></a> |
||||
</p> |
||||
<p align="center"> |
||||
<a href="https://github.com/quafer-cloud/quafer-cloud">Github 仓库</a> | |
||||
<a href="https://gitee.com/dromara/quafer-cloud">Gitee 仓库</a> | |
||||
<a href="https://gitee.com/dromara/quafer-cloud/tree/3.0.0/">v3.0.0</a> | |
||||
<a href="https://www.quafer.cn">文档</a> |
||||
</p> |
||||
|
||||
## 说明 |
||||
|
||||
自11月24日,Spring Boot 3.0 以及 Spring Cloud 2022.0.0、Spring Cloud Tencent 等全新版本发布,整个Java 社区也步入的 Java 17 和 Spring Boot 3 的新时代。紧跟 Java 技术和 Spring 社区的发展,让更多质量更好、性能更优的新特性服务于实际的开发工作,quafer Cloud 也同步进行升级及适配,开发了全新的 3.0 版本。 |
||||
|
||||
基于 Spring Authorization Server 1.0.0、Spring Boot 3.0.1、Spring Cloud 2022.0.0、Spring Cloud Tencent 1.8.2-2022.0.0、Spring Cloud Alibaba 2022.0.0.0-RC1、Nacos 2.2.1-RC 等主流技术栈开发的 quafer Cloud v3.0.1 已经正式发布,关注请移步 [v3.0.0 分支](https://gitee.com/dromara/quafer-cloud/tree/3.0.0/) |
||||
|
||||
## 特点 |
||||
|
||||
1. 严格遵照“单一职责”原则,进行各个模块的划分和代码拆解。 |
||||
2. 严格遵循 Spring Boot 编码规则和命名规则。 |
||||
3. 大多数模块均支持 @EnableXXX注解 和 starter,让 Spring Bean 的注入顺序更加可控。 |
||||
4. 模块化设计思想,通过 Bean 注入、以及丰富的自定义 @ConditionalXXX 注解,让模块的添加和删除更加灵活。 |
||||
5. 各模块既可以综合在一起使用,也可以在其它 Spring Boot 工程中独立使用。 |
||||
|
||||
## 优点 |
||||
|
||||
很多朋友不理解这样做的好处,明明很多代码都可以放在一起,为什么要拆分出这么多包、拆这么细? |
||||
|
||||
这样做主要有以下优势: |
||||
|
||||
1. 虽然模块看似很多,但是每个模块职责单一、代码清晰,更有利于聚焦和定位问题。 |
||||
2. 通过对微服务架构的“庖丁解牛”,初学者不再需要在代码的海洋里“遨游”,通过针对性地了解各个模块,以点带面快速掌握微服务架构整体结构。 |
||||
3. 模块间的依赖极大的降低,想要替换为 `Spring Authorization Server`,影响到的代码和范围将会很小。该工程也是使用 `Spring Authorization Server` 的前序工作 |
||||
4. 每个模块均是最小化依赖第三包,规避依赖包过度依赖,特别是 starter 过多依赖,导致不可预知、难以调试、不好修改等问题。 |
||||
5. 降低微服务系统代码量,独立组件可提前编译并上传至Maven仓库,降低工程代码编译耗时,改进 CICD 效率。 |
||||
|
||||
## 工程结构 |
||||
|
||||
``` |
||||
quafer-engine |
||||
├── dependencies -- 工程Maven顶级依赖,统一控制版本和依赖 |
||||
├── documents -- 需要放置的文档位置 |
||||
├ └── readme -- README 相关素材放置目录 |
||||
├── engine-access -- 外部登录接入模块 |
||||
├ ├── access-core -- 外部登录通用代码组件 |
||||
├ ├── access-sdk-all -- 外部登录集成组件 |
||||
├ ├── access-sdk-justauth -- JustAuth登录组件 |
||||
├ ├── access-sdk-wxapp -- 微信小程序登录组件 |
||||
├ ├── access-sdk-wxmpp -- 微信公众号登录组件 |
||||
├ └── access-spring-boot-starter -- 外部登录 模块统一 Starter |
||||
├── engine-assistant -- 核心通用代码包 |
||||
├ ├── assistant-core -- 核心通用代码组件 |
||||
├ └── assistant-spring-boot-starter -- Assistant 模块统一 Starter |
||||
├── engine-cache -- 缓存模块 |
||||
├ ├── cache-core -- 缓存通用代码组件 |
||||
├ ├── cache-sdk-caffeine -- Caffeine 缓存配置相关代码组件模块 |
||||
├ ├── cache-sdk-jetcache -- JetCache 组件相关代码模块 |
||||
├ ├── cache-sdk-redis -- Caffeine 缓存配置相关代码组件模块 |
||||
├ ├── cache-sdk-redisson -- Redisson 组件相关代码模块 |
||||
├ └── cache-spring-boot-starter -- Cache 模块统一 Starter |
||||
├── engine-captcha -- 验证码模块 |
||||
├ ├── captcha-core -- 验证码共性通用代码 |
||||
├ ├── captcha-sdk-behavior -- 行为验证码组件(包括拼图滑块、文字点选) |
||||
├ ├── captcha-sdk-graphic -- 传统图形验证码组件(包括算数类型、中文类型、字母类型、GIF类型) |
||||
├ ├── captcha-sdk-hutool -- Hutool验证码组件(包括圆圈干扰、扭曲干扰、线段干扰) |
||||
├ └── captcha-spring-boot-starter -- Captcha 模块统一 Starter |
||||
├── engine-data -- 数据访问模块 |
||||
├ ├── data-core -- 数据访问共性通用代码 |
||||
├ ├── data-sdk-jpa -- JPA 及Hibernate 组件相关代码模块 |
||||
├ ├── data-sdk-mybatis-plus -- MybatisPlus 组件相关代码模块 |
||||
├ ├── data-sdk-p6spy -- P6spy 组件相关代码模块 |
||||
├ └── data-spring-boot-starter -- Data 模块统一 Starter |
||||
├── engine-event -- Spring 事件模块 |
||||
├ ├── event-core -- 事件组件共性代码模块 |
||||
├ ├── event-message-spring-boot-starter -- Kafka Message 统一 Starter |
||||
├ ├── event-pay-spring-boot-starter -- 支付事件统一 Starter |
||||
├ └── event-security-spring-boot-starter --安全事件统一 Starter |
||||
├── engine-facility -- 微服务基础设施模块 |
||||
├ ├── facility-core -- 基础设施共性通用代码 |
||||
├ ├── facility-sdk-log -- 微服务日志中心组件模块 |
||||
├ ├── facility-sdk-sentinel -- Sentinel 组件模块 |
||||
├ └── facility-spring-boot-starter -- Facility 模块统一 Starter |
||||
├── engine-message -- 消息模块 |
||||
├ ├── message-core -- 消息共性通用代码 |
||||
├ ├── message-sdk-mailing -- 站内消息、私信通用代码模块 |
||||
├ ├── message-sdk-websocket -- 基于 WebSocket 的消息代码模块 |
||||
├ └── message-spring-boot-starter -- Message 模块统一 Starter |
||||
├── engine-nosql -- Nosql 数据库接入管理模块 |
||||
├ ├── nosql-core -- nosql基础共性通用代码 |
||||
├ ├── nosql-sdk-couchdb -- Couchdb Nosql 数据库接入管理组件模块 |
||||
├ └── nosql-sdk-influxdb -- Influxdb 时序数据库接入管理组件模块 |
||||
├── engine-oauth2 -- OAuth2 认证模块 |
||||
├ ├── oauth2-core -- OAuth2 共性通用代码模块 |
||||
├ ├── oauth2-sdk-authentication -- Spring Authorization Server 认证逻辑模块 |
||||
├ ├── oauth2-sdk-authentication-server -- Spring Authorization Server 认证服务器管理基础模块 |
||||
├ ├── oauth2-sdk-authorization -- Spring Authorization Server 授权逻辑处理模块 |
||||
├ ├── oauth2-sdk-compliance -- Spring Authorization Server 应用安全合规支撑组件模块 |
||||
├ └── oauth2-sdk-data-jpa -- 基于 Spring Data JPA 封装的 Spring Authorization Server 数据访问代码模块 |
||||
├── engine-oss -- 对象存储模块 |
||||
├ ├── oss-core -- 对象存储共性通用代码 |
||||
├ ├── oss-sdk-minio -- Minio 组件模块 |
||||
├ └── oss-spring-boot-starter -- Oss 模块统一 Starter |
||||
├── engine-pay -- 支付模块 |
||||
├ ├── pay-core -- 支付共性通用代码 |
||||
├ ├── pay-sdk-alipay -- 支付宝支付组件模块 |
||||
├ ├── pay-sdk-all -- 支付方式整合组件模块 |
||||
├ ├── pay-sdk-wxpay -- 微信支付组件模块 |
||||
├ └── pay-spring-boot-starter -- Pay 模块统一 Starter |
||||
├── engine-rest -- 服务Rest接口模块 |
||||
├ ├── rest-core -- 服务Rest接口共性通用代码 |
||||
├ ├── rest-sdk-protect -- 前后端数据加密、接口幂等、防刷、Xss和SQL注入Rest API 防护组件模块 |
||||
├ └── rest-spring-boot-starter -- Rest 模块统一 Starter(包括通用CRUD代码) |
||||
├── engine-sms -- 短信接入模块 |
||||
├ ├── sms-core -- 短信共性通用代码模块 |
||||
├ ├── sms-sdk-aliyun -- 阿里云短信发送组件模块 |
||||
├ ├── sms-sdk-all -- 短信整合组件模块 |
||||
├ ├── sms-sdk-chinamobile -- 移动短信发送组件模块 |
||||
├ ├── sms-sdk-huawei -- 华为短信发送组件模块 |
||||
├ ├── sms-sdk-jd -- 京东短信发送组件模块 |
||||
├ ├── sms-sdk-netease -- 网易短信发送组件模块 |
||||
├ ├── sms-sdk-qiniu -- 七牛短信发送组件模块 |
||||
├ ├── sms-sdk-tencent -- 腾讯短信发送组件模块 |
||||
├ ├── sms-sdk-upyun -- 又拍短信发送组件模块 |
||||
├ ├── sms-sdk-yunpian -- 云片短信发送组件模块 |
||||
├ └── sms-spring-boot-starter -- SMS 模块统一 Starter |
||||
├── engine-web -- Web处理模块 |
||||
├ ├── web-core -- Web 应用共性通用代码模块组件 |
||||
├ ├── web-sdk-rest -- Web 应用基础支撑模块组件 |
||||
├ ├── web-sdk-scan -- 接口权限扫描组件模块 |
||||
└── └── web-spring-boot-starter -- Web 模块统一 Starter |
||||
``` |
||||
|
||||
## 阅读顺序 |
||||
|
||||
### 一、关联性阅读 |
||||
|
||||
部分组件存在关联和组合性,建议按照以下顺序阅读和了解代码: |
||||
|
||||
1. engine-assistant |
||||
2. engine-cache |
||||
3. engine-data |
||||
4. engine-web |
||||
5. engine-protect |
||||
6. engine-rest |
||||
7. engine-oauth2 |
||||
8. engine-facility |
||||
9. engine-event |
||||
10. engine-message |
||||
|
||||
### 二、独立性阅读 |
||||
|
||||
部分组件都是相对独立的,组件间的关联性非常弱。可分开独立阅读和了解代码: |
||||
|
||||
* engine-captcha |
||||
* engine-oss |
||||
* engine-pay |
||||
* engine-temporal |
||||
* engine-websocket |
||||
|
||||
## 参与贡献 |
||||
|
||||
1. Fork 本仓库 |
||||
2. 新建 Feat_xxx 分支 |
||||
3. 提交代码 |
||||
4. 新建 Pull Request |
||||
|
||||
## 交流反馈 |
||||
|
||||
- 欢迎提交[ISSUS](https://gitee.com/dromara/quafer-cloud/issues) ,请写清楚问题的具体原因,重现步骤和环境 |
||||
|
||||
## 关联项目 |
||||
|
||||
- quafer 主工程地址:[https://gitee.com/dromara/quafer-cloud](https://gitee.com/dromara/quafer-cloud) |
||||
- quafer 单体版示例工程地址:[https://gitee.com/quafer/quafer-cloud-athena](https://gitee.com/quafer/quafer-cloud-athena) |
||||
- quafer 前端工程地址:[https://gitee.com/quafer/quafer-cloud-ui](https://gitee.com/quafer/quafer-cloud-ui) |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,61 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>engine-access</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<description>基于 Spring Authorization Server 的外部访问接入通用组件模块模块</description> |
||||
|
||||
<artifactId>access-core</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>assistant-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>me.zhyd.oauth</groupId> |
||||
<artifactId>JustAuth</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.github.binarywang</groupId> |
||||
<artifactId>weixin-java-miniapp</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,42 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.constants; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.constants.BaseConstants; |
||||
|
||||
/** |
||||
* @description 对外接口常量 |
||||
* @author ov_00 |
||||
* @date 2023/2/19 13:52 |
||||
*/ |
||||
public interface AccessConstants extends BaseConstants { |
||||
|
||||
String PROPERTY_PREFIX_ACCESS = PROPERTY_PREFIX_HERODOTUS + ".access"; |
||||
String PROPERTY_ACCESS_JUSTAUTH = PROPERTY_PREFIX_ACCESS + ".justauth"; |
||||
String ITEM_JUSTAUTH_ENABLED = PROPERTY_ACCESS_JUSTAUTH + PROPERTY_ENABLED; |
||||
String PROPERTY_ACCESS_WXAPP = PROPERTY_PREFIX_ACCESS + ".wxapp"; |
||||
String ITEM_WXAPP_ENABLED = PROPERTY_ACCESS_WXAPP + PROPERTY_ENABLED; |
||||
String PROPERTY_ACCESS_WXMPP = PROPERTY_PREFIX_ACCESS + ".wxmpp"; |
||||
String ITEM_WXMPP_ENABLED = PROPERTY_ACCESS_WXMPP + PROPERTY_ENABLED; |
||||
String CACHE_NAME_TOKEN_JUSTAUTH = CACHE_TOKEN_BASE_PREFIX + "justauth:"; |
||||
} |
@ -0,0 +1,40 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.constants; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.constants.ErrorCode; |
||||
|
||||
/** |
||||
* <p>Description: Access 模块错误代码 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/9/2 17:50 |
||||
*/ |
||||
public interface AccessErrorCode extends ErrorCode { |
||||
|
||||
int ILLEGAL_ACCESS_SOURCE = ACCESS_MODULE_406_BEGIN + 1; |
||||
int ACCESS_CONFIG_ERROR = ILLEGAL_ACCESS_SOURCE + 1; |
||||
} |
@ -0,0 +1,57 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.definition; |
||||
|
||||
import com.liuhung.engine.assistant.core.domain.AccessPrincipal; |
||||
|
||||
/** |
||||
* <p>Description: 外部应用接入处理器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/25 16:20 |
||||
*/ |
||||
public interface AccessHandler { |
||||
|
||||
/** |
||||
* 外部应用接入预处理 |
||||
* 比如 微信小程序需要传入Code 和 AppId |
||||
* 比如 手机登录需要传入手机号码等 |
||||
* |
||||
* @param core 对于只需要一个参数就可以进行预处理操作的核心值。 |
||||
* @param params 核心值以外的其它参数 |
||||
* @return {@link AccessResponse} |
||||
*/ |
||||
AccessResponse preProcess(String core, String... params); |
||||
|
||||
/** |
||||
* 获取接入系统中的用户信息,并转换为系统可以识别的 {@link AccessUserDetails} 类型 |
||||
* |
||||
* @param source 类别 |
||||
* @param accessPrincipal 外部系统接入所需信息 |
||||
* @return 外部系统用户信息 {@link AccessUserDetails} |
||||
*/ |
||||
AccessUserDetails loadUserDetails(String source, AccessPrincipal accessPrincipal); |
||||
} |
@ -0,0 +1,74 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.definition; |
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
||||
|
||||
/** |
||||
* <p>Description: 外部接入预操作统一返回实体 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/25 16:35 |
||||
*/ |
||||
public class AccessResponse { |
||||
|
||||
/** |
||||
* JustAuth 认证URL |
||||
*/ |
||||
private String authorizeUrl; |
||||
/** |
||||
* 手机短信验证码是否发送成功 |
||||
*/ |
||||
private Boolean success; |
||||
/** |
||||
* 微信小程序返回Session信息 |
||||
*/ |
||||
private WxMaJscode2SessionResult session; |
||||
|
||||
public String getAuthorizeUrl() { |
||||
return authorizeUrl; |
||||
} |
||||
|
||||
public void setAuthorizeUrl(String authorizeUrl) { |
||||
this.authorizeUrl = authorizeUrl; |
||||
} |
||||
|
||||
public Boolean getSuccess() { |
||||
return success; |
||||
} |
||||
|
||||
public void setSuccess(Boolean success) { |
||||
this.success = success; |
||||
} |
||||
|
||||
public WxMaJscode2SessionResult getSession() { |
||||
return session; |
||||
} |
||||
|
||||
public void setSession(WxMaJscode2SessionResult session) { |
||||
this.session = session; |
||||
} |
||||
} |
@ -0,0 +1,335 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.definition; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import me.zhyd.oauth.enums.AuthUserGender; |
||||
|
||||
/** |
||||
* <p>Description: 外部程序接入返回用户信息 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/25 16:46 |
||||
*/ |
||||
public class AccessUserDetails { |
||||
|
||||
/** |
||||
* JustAuth中的关键词 |
||||
* 以下内容了解后,将会使你更容易地上手JustAuth。 |
||||
* <p> |
||||
* source JustAuth支持的第三方平台,比如:GITHUB、GITEE等 |
||||
* uuid 一般为第三方平台的用户ID。以下几个平台需特别注意: |
||||
* 钉钉、抖音:uuid 为用户的 unionid |
||||
* 微信公众平台登录、京东、酷家乐、美团:uuid 为用户的 openId |
||||
* 微信开放平台登录、QQ:uuid 为用户的 openId,平台支持获取unionid, unionid 在 AuthToken 中(如果支持),在登录完成后,可以通过 response.getData().getToken().getUnionId() 获取 |
||||
* Google:uuid 为用户的 sub,sub为Google的所有账户体系中用户唯一的身份标识符,详见:OpenID Connect (opens new window) |
||||
* 注:建议通过uuid + source的方式唯一确定一个用户,这样可以解决用户身份归属的问题。因为 单个用户ID 在某一平台中是唯一的,但不能保证在所有平台中都是唯一的。 |
||||
*/ |
||||
@Schema(title = "用户第三方系统的唯一id", description = "在调用方集成该组件时,可以用uuid + source唯一确定一个用") |
||||
private String uuid; |
||||
|
||||
@Schema(title = "用户名") |
||||
private String userName; |
||||
|
||||
@Schema(title = "用户昵称") |
||||
private String nickName; |
||||
|
||||
@Schema(title = "用户头像") |
||||
private String avatar; |
||||
|
||||
@Schema(title = "用户网址") |
||||
private String blog; |
||||
|
||||
@Schema(title = "所在公司") |
||||
private String company; |
||||
|
||||
@Schema(title = "位置") |
||||
private String location; |
||||
|
||||
@Schema(title = "用户邮箱") |
||||
private String email; |
||||
|
||||
@Schema(title = "用户邮箱") |
||||
private String remark; |
||||
/** |
||||
* 性别 |
||||
*/ |
||||
@Schema(title = "性别") |
||||
private AuthUserGender gender; |
||||
|
||||
@Schema(title = "第三方用户来源") |
||||
private String source; |
||||
|
||||
@Schema(title = "用户的授权令牌") |
||||
private String accessToken; |
||||
|
||||
@Schema(title = "第三方用户的授权令牌的有效期", description = "部分平台可能没有") |
||||
private Integer expireIn; |
||||
|
||||
@Schema(title = "刷新令牌", description = "部分平台可能没有") |
||||
private String refreshToken; |
||||
|
||||
@Schema(title = "第三方用户的刷新令牌的有效期", description = "部分平台可能没有") |
||||
private Integer refreshTokenExpireIn; |
||||
|
||||
@Schema(title = "第三方用户授予的权限", description = "部分平台可能没有") |
||||
private String scope; |
||||
|
||||
@Schema(title = "个别平台的授权信息", description = "部分平台可能没有") |
||||
private String tokenType; |
||||
|
||||
@Schema(title = "第三方用户的 ID", description = "部分平台可能没有") |
||||
private String uid; |
||||
|
||||
@Schema(title = "第三方用户的 open id", description = "部分平台可能没有") |
||||
private String openId; |
||||
|
||||
@Schema(title = "个别平台的授权信息", description = "部分平台可能没有") |
||||
private String accessCode; |
||||
|
||||
@Schema(title = "第三方用户的 union id", description = "部分平台可能没有") |
||||
private String unionId; |
||||
|
||||
@Schema(title = "小程序Appid", description = "部分平台可能没有") |
||||
private String appId; |
||||
|
||||
@Schema(title = "手机号码", description = "部分平台可能没有") |
||||
private String phoneNumber; |
||||
|
||||
public String getUuid() { |
||||
return uuid; |
||||
} |
||||
|
||||
public void setUuid(String uuid) { |
||||
this.uuid = uuid; |
||||
} |
||||
|
||||
public String getUserName() { |
||||
return userName; |
||||
} |
||||
|
||||
public void setUserName(String userName) { |
||||
this.userName = userName; |
||||
} |
||||
|
||||
public String getNickName() { |
||||
return nickName; |
||||
} |
||||
|
||||
public void setNickName(String nickName) { |
||||
this.nickName = nickName; |
||||
} |
||||
|
||||
public String getAvatar() { |
||||
return avatar; |
||||
} |
||||
|
||||
public void setAvatar(String avatar) { |
||||
this.avatar = avatar; |
||||
} |
||||
|
||||
public String getBlog() { |
||||
return blog; |
||||
} |
||||
|
||||
public void setBlog(String blog) { |
||||
this.blog = blog; |
||||
} |
||||
|
||||
public String getCompany() { |
||||
return company; |
||||
} |
||||
|
||||
public void setCompany(String company) { |
||||
this.company = company; |
||||
} |
||||
|
||||
public String getLocation() { |
||||
return location; |
||||
} |
||||
|
||||
public void setLocation(String location) { |
||||
this.location = location; |
||||
} |
||||
|
||||
public String getEmail() { |
||||
return email; |
||||
} |
||||
|
||||
public void setEmail(String email) { |
||||
this.email = email; |
||||
} |
||||
|
||||
public String getRemark() { |
||||
return remark; |
||||
} |
||||
|
||||
public void setRemark(String remark) { |
||||
this.remark = remark; |
||||
} |
||||
|
||||
public AuthUserGender getGender() { |
||||
return gender; |
||||
} |
||||
|
||||
public void setGender(AuthUserGender gender) { |
||||
this.gender = gender; |
||||
} |
||||
|
||||
public String getSource() { |
||||
return source; |
||||
} |
||||
|
||||
public void setSource(String source) { |
||||
this.source = source; |
||||
} |
||||
|
||||
public String getAccessToken() { |
||||
return accessToken; |
||||
} |
||||
|
||||
public void setAccessToken(String accessToken) { |
||||
this.accessToken = accessToken; |
||||
} |
||||
|
||||
public Integer getExpireIn() { |
||||
return expireIn; |
||||
} |
||||
|
||||
public void setExpireIn(Integer expireIn) { |
||||
this.expireIn = expireIn; |
||||
} |
||||
|
||||
public String getRefreshToken() { |
||||
return refreshToken; |
||||
} |
||||
|
||||
public void setRefreshToken(String refreshToken) { |
||||
this.refreshToken = refreshToken; |
||||
} |
||||
|
||||
public Integer getRefreshTokenExpireIn() { |
||||
return refreshTokenExpireIn; |
||||
} |
||||
|
||||
public void setRefreshTokenExpireIn(Integer refreshTokenExpireIn) { |
||||
this.refreshTokenExpireIn = refreshTokenExpireIn; |
||||
} |
||||
|
||||
public String getScope() { |
||||
return scope; |
||||
} |
||||
|
||||
public void setScope(String scope) { |
||||
this.scope = scope; |
||||
} |
||||
|
||||
public String getTokenType() { |
||||
return tokenType; |
||||
} |
||||
|
||||
public void setTokenType(String tokenType) { |
||||
this.tokenType = tokenType; |
||||
} |
||||
|
||||
public String getUid() { |
||||
return uid; |
||||
} |
||||
|
||||
public void setUid(String uid) { |
||||
this.uid = uid; |
||||
} |
||||
|
||||
public String getOpenId() { |
||||
return openId; |
||||
} |
||||
|
||||
public void setOpenId(String openId) { |
||||
this.openId = openId; |
||||
} |
||||
|
||||
public String getAccessCode() { |
||||
return accessCode; |
||||
} |
||||
|
||||
public void setAccessCode(String accessCode) { |
||||
this.accessCode = accessCode; |
||||
} |
||||
|
||||
public String getUnionId() { |
||||
return unionId; |
||||
} |
||||
|
||||
public void setUnionId(String unionId) { |
||||
this.unionId = unionId; |
||||
} |
||||
|
||||
public String getAppId() { |
||||
return appId; |
||||
} |
||||
|
||||
public void setAppId(String appId) { |
||||
this.appId = appId; |
||||
} |
||||
|
||||
public String getPhoneNumber() { |
||||
return phoneNumber; |
||||
} |
||||
|
||||
public void setPhoneNumber(String phoneNumber) { |
||||
this.phoneNumber = phoneNumber; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("uuid", uuid) |
||||
.add("userName", userName) |
||||
.add("nickName", nickName) |
||||
.add("avatar", avatar) |
||||
.add("blog", blog) |
||||
.add("company", company) |
||||
.add("location", location) |
||||
.add("email", email) |
||||
.add("remark", remark) |
||||
.add("gender", gender) |
||||
.add("source", source) |
||||
.add("accessToken", accessToken) |
||||
.add("expireIn", expireIn) |
||||
.add("refreshToken", refreshToken) |
||||
.add("refreshTokenExpireIn", refreshTokenExpireIn) |
||||
.add("scope", scope) |
||||
.add("tokenType", tokenType) |
||||
.add("uid", uid) |
||||
.add("openId", openId) |
||||
.add("accessCode", accessCode) |
||||
.add("unionId", unionId) |
||||
.add("appId", appId) |
||||
.add("phoneNumber", phoneNumber) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.exception; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessErrorCode; |
||||
import com.liuhung.engine.assistant.core.domain.Feedback; |
||||
import com.liuhung.engine.assistant.core.exception.PlatformException; |
||||
import org.apache.http.HttpStatus; |
||||
|
||||
/** |
||||
* <p>Description: Access 配置错误 </p> |
||||
* @author : liuh |
||||
* @date : 2022/9/2 18:02 |
||||
*/ |
||||
public class AccessConfigErrorException extends PlatformException { |
||||
|
||||
public AccessConfigErrorException() { |
||||
super(); |
||||
} |
||||
|
||||
public AccessConfigErrorException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public AccessConfigErrorException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public AccessConfigErrorException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
protected AccessConfigErrorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
|
||||
@Override |
||||
public Feedback getFeedback() { |
||||
return new Feedback(AccessErrorCode.ACCESS_CONFIG_ERROR, "Access 模块配置错误", HttpStatus.SC_PRECONDITION_FAILED); |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.exception; |
||||
|
||||
import com.liuhung.engine.assistant.core.exception.PlatformException; |
||||
|
||||
/** |
||||
* <p>Description: 接入处理器未找到错误 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 12:03 |
||||
*/ |
||||
public class AccessHandlerNotFoundException extends PlatformException { |
||||
|
||||
public AccessHandlerNotFoundException() { |
||||
super(); |
||||
} |
||||
|
||||
public AccessHandlerNotFoundException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public AccessHandlerNotFoundException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public AccessHandlerNotFoundException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public AccessHandlerNotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.exception; |
||||
|
||||
import com.liuhung.engine.assistant.core.exception.PlatformException; |
||||
|
||||
/** |
||||
* <p>Description: 接入身份认证错误 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 10:54 |
||||
*/ |
||||
public class AccessIdentityVerificationFailedException extends PlatformException { |
||||
|
||||
public AccessIdentityVerificationFailedException() { |
||||
super(); |
||||
} |
||||
|
||||
public AccessIdentityVerificationFailedException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public AccessIdentityVerificationFailedException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public AccessIdentityVerificationFailedException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public AccessIdentityVerificationFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
} |
@ -0,0 +1,56 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.exception; |
||||
|
||||
import com.liuhung.engine.assistant.core.exception.PlatformException; |
||||
|
||||
/** |
||||
* <p>Description: 接入预操作失败错误 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 11:10 |
||||
*/ |
||||
public class AccessPreProcessFailedException extends PlatformException { |
||||
|
||||
public AccessPreProcessFailedException() { |
||||
} |
||||
|
||||
public AccessPreProcessFailedException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public AccessPreProcessFailedException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public AccessPreProcessFailedException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public AccessPreProcessFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.exception; |
||||
|
||||
import com.liuhung.engine.assistant.core.exception.PlatformException; |
||||
|
||||
/** |
||||
* <p>Description: 非法的访问参数错误 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 12:02 |
||||
*/ |
||||
public class IllegalAccessArgumentException extends PlatformException { |
||||
|
||||
public IllegalAccessArgumentException() { |
||||
super(); |
||||
} |
||||
|
||||
public IllegalAccessArgumentException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public IllegalAccessArgumentException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public IllegalAccessArgumentException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public IllegalAccessArgumentException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.core.exception; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessErrorCode; |
||||
import com.liuhung.engine.assistant.core.domain.Feedback; |
||||
import com.liuhung.engine.assistant.core.exception.PlatformException; |
||||
import org.apache.http.HttpStatus; |
||||
|
||||
/** |
||||
* <p>Description: 非法的外部访问参数类型错误 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 12:02 |
||||
*/ |
||||
public class IllegalAccessSourceException extends PlatformException { |
||||
|
||||
public IllegalAccessSourceException() { |
||||
super(); |
||||
} |
||||
|
||||
public IllegalAccessSourceException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public IllegalAccessSourceException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public IllegalAccessSourceException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
public IllegalAccessSourceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
|
||||
@Override |
||||
public Feedback getFeedback() { |
||||
return new Feedback(AccessErrorCode.ILLEGAL_ACCESS_SOURCE, "社交登录Source参数错误", HttpStatus.SC_PRECONDITION_FAILED); |
||||
} |
||||
} |
@ -0,0 +1,63 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>engine-access</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<artifactId>access-sdk-all</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<description>基于 Spring Authorization Server 的外部接入统一处理逻辑业务组件模块</description> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-sdk-justauth</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-sdk-wxapp</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-sdk-wxmpp</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>sms-sdk-all</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,131 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.configuration; |
||||
|
||||
import com.liuhung.engine.access.business.controller.JustAuthAccessController; |
||||
import com.liuhung.engine.access.business.controller.PhoneNumberAccessController; |
||||
import com.liuhung.engine.access.business.controller.WxappAccessController; |
||||
import com.liuhung.engine.access.business.processor.AccessHandlerStrategyFactory; |
||||
import com.liuhung.engine.access.business.processor.PhoneNumberAccessHandler; |
||||
import com.liuhung.engine.access.justauth.annotation.ConditionalOnJustAuthEnabled; |
||||
import com.liuhung.engine.access.justauth.configuration.JustAuthConfiguration; |
||||
import com.liuhung.engine.access.wxapp.annotation.ConditionalOnWxappEnabled; |
||||
import com.liuhung.engine.access.wxapp.configuration.WxappConfiguration; |
||||
import com.liuhung.engine.access.wxmpp.configuration.WxmppConfiguration; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import com.liuhung.engine.sms.all.annotation.ConditionalOnSmsEnabled; |
||||
import com.liuhung.engine.sms.all.configuration.SmsConfiguration; |
||||
import com.liuhung.engine.sms.all.processor.SmsSendStrategyFactory; |
||||
import com.liuhung.engine.sms.all.stamp.VerificationCodeStampManager; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.context.annotation.Import; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
/** |
||||
* <p>Description: Access 业务模块配置 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 14:59 |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@Import({ |
||||
JustAuthConfiguration.class, |
||||
WxappConfiguration.class, |
||||
WxmppConfiguration.class |
||||
}) |
||||
public class AccessAllConfiguration { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AccessAllConfiguration.class); |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
log.debug("[Quafer] |- SDK [Access All] Auto Configure."); |
||||
} |
||||
|
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnSmsEnabled |
||||
@Import({SmsConfiguration.class}) |
||||
static class PhoneNumberSignInConfiguration { |
||||
|
||||
@Bean(AccountType.PHONE_NUMBER_HANDLER) |
||||
@ConditionalOnBean({VerificationCodeStampManager.class, SmsSendStrategyFactory.class}) |
||||
public PhoneNumberAccessHandler phoneNumberAccessHandler(VerificationCodeStampManager verificationCodeStampManager, SmsSendStrategyFactory smsSendStrategyFactory) { |
||||
PhoneNumberAccessHandler phoneNumberAuthenticationHandler = new PhoneNumberAccessHandler(verificationCodeStampManager, smsSendStrategyFactory); |
||||
log.trace("[Quafer] |- Bean [Phone Number SignIn Handler] Auto Configure."); |
||||
return phoneNumberAuthenticationHandler; |
||||
} |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean(AccessHandlerStrategyFactory.class) |
||||
public AccessHandlerStrategyFactory accessHandlerStrategyFactory() { |
||||
AccessHandlerStrategyFactory accessHandlerStrategyFactory = new AccessHandlerStrategyFactory(); |
||||
log.trace("[Quafer] |- Bean [Access Handler Strategy Factory] Auto Configure."); |
||||
return accessHandlerStrategyFactory; |
||||
} |
||||
|
||||
@Configuration(proxyBeanMethods = false) |
||||
static class ControllerConfiguration { |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
log.debug("[Quafer] |- SDK [Access All Controller] Auto Configure."); |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnSmsEnabled |
||||
@ConditionalOnMissingBean |
||||
public PhoneNumberAccessController phoneNumberAccessController() { |
||||
PhoneNumberAccessController phoneNumberAuthenticationController = new PhoneNumberAccessController(); |
||||
log.trace("[Quafer] |- Bean [Phone Number Access Controller] Auto Configure."); |
||||
return phoneNumberAuthenticationController; |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnJustAuthEnabled |
||||
@ConditionalOnMissingBean |
||||
public JustAuthAccessController justAuthSignInController() { |
||||
JustAuthAccessController justAuthAuthenticationController = new JustAuthAccessController(); |
||||
log.trace("[Quafer] |- Bean [Just Auth Access Controller] Auto Configure."); |
||||
return justAuthAuthenticationController; |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnWxappEnabled |
||||
@ConditionalOnMissingBean |
||||
public WxappAccessController wxappAccessController() { |
||||
WxappAccessController wxappAccessController = new WxappAccessController(); |
||||
log.trace("[Quafer] |- Bean [Wxapp Access Controller] Auto Configure."); |
||||
return wxappAccessController; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,88 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.controller; |
||||
|
||||
import com.liuhung.engine.access.business.event.AutomaticSignInEvent; |
||||
import com.liuhung.engine.access.justauth.processor.JustAuthProcessor; |
||||
import com.liuhung.engine.assistant.core.domain.Result; |
||||
import cn.hutool.core.bean.BeanUtil; |
||||
import com.google.common.collect.ImmutableMap; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.Parameters; |
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import me.zhyd.oauth.model.AuthCallback; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 社交登录第三方系统返回的Redirect Url </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/28 11:35 |
||||
*/ |
||||
@RestController |
||||
@Tag(name = "社交登录Redirect Url") |
||||
public class JustAuthAccessController { |
||||
|
||||
@Autowired |
||||
private ApplicationContext applicationContext; |
||||
@Autowired |
||||
private JustAuthProcessor justAuthProcessor; |
||||
|
||||
@Operation(summary = "社交登录redirect url地址", description = "社交登录标准模式的redirect url地址,获取第三方登录返回的code") |
||||
@Parameters({ |
||||
@Parameter(name = "source", required = true, description = "社交登录的类型,具体指定是哪一个第三方系统", in = ParameterIn.PATH), |
||||
}) |
||||
@RequestMapping("/open/identity/social/{source}") |
||||
public void callback(@PathVariable("source") String source, AuthCallback callback) { |
||||
if (StringUtils.isNotBlank(source) && BeanUtil.isNotEmpty(callback)) { |
||||
Map<String, Object> params = ImmutableMap.of("source", source, "callback", callback); |
||||
applicationContext.publishEvent(new AutomaticSignInEvent(params)); |
||||
} |
||||
} |
||||
|
||||
@Operation(summary = "获取社交登录列表", description = "根据后台已配置社交登录信息,返回可用的社交登录控制列表") |
||||
@GetMapping("/open/identity/sources") |
||||
public Result<Map<String, String>> list() { |
||||
Map<String, String> list = justAuthProcessor.getAuthorizeUrls(); |
||||
if (MapUtils.isNotEmpty(list)) { |
||||
return Result.success("获取社交登录列表成功", list); |
||||
} else { |
||||
return Result.success("社交登录没有配置", new HashMap<>()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,71 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.controller; |
||||
|
||||
import com.liuhung.engine.access.business.processor.AccessHandlerStrategyFactory; |
||||
import com.liuhung.engine.access.core.definition.AccessResponse; |
||||
import com.liuhung.engine.assistant.core.domain.Result; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.Parameters; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p>Description: 手机验证码登录 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/28 11:39 |
||||
*/ |
||||
@RestController |
||||
@Tag(name = "手机验证码登录接口") |
||||
public class PhoneNumberAccessController { |
||||
|
||||
@Autowired |
||||
private AccessHandlerStrategyFactory accessHandlerStrategyFactory; |
||||
|
||||
@Operation(summary = "手机验证码发送地址", description = "接收手机号码,发送验证码,并缓存至Redis") |
||||
@Parameters({ |
||||
@Parameter(name = "mobile", required = true, description = "手机号码"), |
||||
}) |
||||
@PostMapping("/open/identity/verification-code") |
||||
public Result<String> sendCode(@RequestParam("mobile") String mobile) { |
||||
AccessResponse response = accessHandlerStrategyFactory.preProcess(AccountType.SMS, mobile); |
||||
if (ObjectUtils.isNotEmpty(response)) { |
||||
if (response.getSuccess()) { |
||||
return Result.success("短信发送成功!"); |
||||
} else { |
||||
return Result.failure("短信发送失败!"); |
||||
} |
||||
} |
||||
return Result.failure("手机号码接收失败!"); |
||||
} |
||||
} |
@ -0,0 +1,71 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.controller; |
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
||||
import com.liuhung.engine.access.business.dto.WxappProfile; |
||||
import com.liuhung.engine.access.business.processor.AccessHandlerStrategyFactory; |
||||
import com.liuhung.engine.access.core.definition.AccessResponse; |
||||
import com.liuhung.engine.assistant.core.domain.Result; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.Parameters; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序平台认证 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/28 11:40 |
||||
*/ |
||||
@RestController |
||||
@Tag(name = "微信小程序平台认证接口") |
||||
public class WxappAccessController { |
||||
|
||||
@Autowired |
||||
private AccessHandlerStrategyFactory accessHandlerStrategyFactory; |
||||
|
||||
@Operation(summary = "微信小程序登录", description = "利用wx.login获取code,进行小程序登录") |
||||
@Parameters({ |
||||
@Parameter(name = "socialDetails", required = true, description = "社交登录自定义参数实体"), |
||||
}) |
||||
@PostMapping("/open/identity/wxapp") |
||||
public Result<WxMaJscode2SessionResult> login(@Validated @RequestBody WxappProfile wxappProfile) { |
||||
AccessResponse response = accessHandlerStrategyFactory.preProcess(AccountType.WXAPP, wxappProfile.getCode(), wxappProfile.getAppId()); |
||||
if (ObjectUtils.isNotEmpty(response)) { |
||||
return Result.success("微信小程序登录成功", response.getSession()); |
||||
} else { |
||||
return Result.failure("微信小程序登录失败"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.dto; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.domain.AbstractDto; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序登录请求实体 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 14:44 |
||||
*/ |
||||
@Schema(name = "微信小程序登录请求实体", title = "根据code和appid返回微信小程序session信息") |
||||
public class WxappProfile extends AbstractDto { |
||||
|
||||
@Schema(name = "code", title = "前端调用小程序自己的方法返回的code") |
||||
@NotBlank(message = "微信小程序code参数不能为空") |
||||
private String code; |
||||
|
||||
@Schema(name = "appId", title = "需要前端返回给后端appId,以支持多个小程序") |
||||
@NotBlank(message = "微信小程序appId参数不能为空") |
||||
private String appId; |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getAppId() { |
||||
return appId; |
||||
} |
||||
|
||||
public void setAppId(String appId) { |
||||
this.appId = appId; |
||||
} |
||||
} |
@ -0,0 +1,52 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.event; |
||||
|
||||
import org.springframework.context.ApplicationEvent; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 自动登录事件 </p> |
||||
* <p> |
||||
* JustAuth 接收到 Callback以后,统一走系统 /oauth/token 接口获取 Token |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 14:35 |
||||
*/ |
||||
public class AutomaticSignInEvent extends ApplicationEvent { |
||||
|
||||
private final Map<String, Object> callbackParams; |
||||
|
||||
public AutomaticSignInEvent(Map<String, Object> callbackParams) { |
||||
super(callbackParams); |
||||
this.callbackParams = callbackParams; |
||||
} |
||||
|
||||
public Map<String, Object> getCallbackParams() { |
||||
return callbackParams; |
||||
} |
||||
} |
@ -0,0 +1,101 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.processor; |
||||
|
||||
import com.liuhung.engine.access.core.definition.AccessHandler; |
||||
import com.liuhung.engine.access.core.definition.AccessResponse; |
||||
import com.liuhung.engine.access.core.definition.AccessUserDetails; |
||||
import com.liuhung.engine.access.core.exception.AccessHandlerNotFoundException; |
||||
import com.liuhung.engine.access.core.exception.IllegalAccessArgumentException; |
||||
import com.liuhung.engine.assistant.core.domain.AccessPrincipal; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
import java.util.Map; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* <p>Description: Access Handler 工厂 </p> |
||||
* <p> |
||||
* 通过该工厂模式,对接入的常规操作进行封装。避免导入引用各个组件,导致耦合性增大 |
||||
* <p> |
||||
* 本处使用基于Spring Boot 的工厂模式 |
||||
* {@see :https://www.pianshen.com/article/466978086/}
|
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/4 17:40 |
||||
*/ |
||||
public class AccessHandlerStrategyFactory { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AccessHandlerStrategyFactory.class); |
||||
|
||||
@Autowired |
||||
private final Map<String, AccessHandler> handlers = new ConcurrentHashMap<>(); |
||||
|
||||
public AccessResponse preProcess(String source, String core, String... params) { |
||||
AccessHandler socialAuthenticationHandler = this.getAccessHandler(source); |
||||
return socialAuthenticationHandler.preProcess(core, params); |
||||
} |
||||
|
||||
public AccessResponse preProcess(AccountType accountType, String core, String... params) { |
||||
AccessHandler socialAuthenticationHandler = this.getAccessHandler(accountType); |
||||
return socialAuthenticationHandler.preProcess(core, params); |
||||
} |
||||
|
||||
public AccessUserDetails findAccessUserDetails(String source, AccessPrincipal accessPrincipal) { |
||||
AccessHandler socialAuthenticationHandler = this.getAccessHandler(source); |
||||
AccessUserDetails accessUserDetails = socialAuthenticationHandler.loadUserDetails(source, accessPrincipal); |
||||
|
||||
log.debug("[Quafer] |- AccessHandlerFactory findAccessUserDetails."); |
||||
return accessUserDetails; |
||||
} |
||||
|
||||
public AccessHandler getAccessHandler(String source) { |
||||
if (ObjectUtils.isEmpty(source)) { |
||||
throw new IllegalAccessArgumentException("Cannot found SocialProvider"); |
||||
} |
||||
|
||||
AccountType accountType = AccountType.getAccountType(source); |
||||
if (ObjectUtils.isEmpty(accountType)) { |
||||
throw new IllegalAccessArgumentException("Cannot parse the source parameter."); |
||||
} |
||||
|
||||
return getAccessHandler(accountType); |
||||
} |
||||
|
||||
public AccessHandler getAccessHandler(AccountType accountType) { |
||||
String handlerName = accountType.getHandler(); |
||||
AccessHandler socialAuthenticationHandler = handlers.get(handlerName); |
||||
if (ObjectUtils.isNotEmpty(socialAuthenticationHandler)) { |
||||
return socialAuthenticationHandler; |
||||
} else { |
||||
throw new AccessHandlerNotFoundException("Can not found Social Handler for " + handlerName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,89 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.business.processor; |
||||
|
||||
import com.liuhung.engine.access.core.definition.AccessHandler; |
||||
import com.liuhung.engine.access.core.definition.AccessResponse; |
||||
import com.liuhung.engine.access.core.definition.AccessUserDetails; |
||||
import com.liuhung.engine.access.core.exception.AccessIdentityVerificationFailedException; |
||||
import com.liuhung.engine.assistant.core.definition.constants.BaseConstants; |
||||
import com.liuhung.engine.assistant.core.domain.AccessPrincipal; |
||||
import com.liuhung.engine.sms.all.processor.SmsSendStrategyFactory; |
||||
import com.liuhung.engine.sms.all.stamp.VerificationCodeStampManager; |
||||
import com.liuhung.engine.sms.core.domain.Template; |
||||
import com.google.common.collect.ImmutableMap; |
||||
|
||||
/** |
||||
* <p>Description: 手机短信接入处理器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 11:46 |
||||
*/ |
||||
public class PhoneNumberAccessHandler implements AccessHandler { |
||||
|
||||
private final VerificationCodeStampManager verificationCodeStampManager; |
||||
private final SmsSendStrategyFactory smsSendStrategyFactory; |
||||
|
||||
public PhoneNumberAccessHandler(VerificationCodeStampManager verificationCodeStampManager, SmsSendStrategyFactory smsSendStrategyFactory) { |
||||
this.verificationCodeStampManager = verificationCodeStampManager; |
||||
this.smsSendStrategyFactory = smsSendStrategyFactory; |
||||
} |
||||
|
||||
@Override |
||||
public AccessResponse preProcess(String core, String... params) { |
||||
String code = verificationCodeStampManager.create(core); |
||||
boolean result; |
||||
if (verificationCodeStampManager.getSandbox()) { |
||||
result = true; |
||||
} else { |
||||
Template template = new Template(); |
||||
template.setType(verificationCodeStampManager.getVerificationCodeTemplateId()); |
||||
template.setParams(ImmutableMap.of(BaseConstants.CODE, code)); |
||||
result = smsSendStrategyFactory.send(template, core); |
||||
} |
||||
|
||||
AccessResponse accessResponse = new AccessResponse(); |
||||
accessResponse.setSuccess(result); |
||||
return accessResponse; |
||||
} |
||||
|
||||
@Override |
||||
public AccessUserDetails loadUserDetails(String source, AccessPrincipal accessPrincipal) { |
||||
boolean isCodeOk = verificationCodeStampManager.check(accessPrincipal.getMobile(), accessPrincipal.getCode()); |
||||
if (isCodeOk) { |
||||
AccessUserDetails accessUserDetails = new AccessUserDetails(); |
||||
accessUserDetails.setUuid(accessPrincipal.getMobile()); |
||||
accessUserDetails.setPhoneNumber(accessPrincipal.getMobile()); |
||||
accessUserDetails.setUserName(accessPrincipal.getMobile()); |
||||
accessUserDetails.setSource(source); |
||||
|
||||
verificationCodeStampManager.delete(accessPrincipal.getMobile()); |
||||
return accessUserDetails; |
||||
} |
||||
|
||||
throw new AccessIdentityVerificationFailedException("Phone Verification Code Error!"); |
||||
} |
||||
} |
@ -0,0 +1,56 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>engine-access</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<artifactId>access-sdk-justauth</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<description>基于 Spring Authorization Server 的 JustAuth 外部接入组件模块</description> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>cache-sdk-jetcache</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,44 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.annotation; |
||||
|
||||
import com.liuhung.engine.access.justauth.condition.JustAuthEnabledCondition; |
||||
import org.springframework.context.annotation.Conditional; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* <p>Description: JustAuth开启条件注解 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/24 14:40 |
||||
*/ |
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
@Conditional(JustAuthEnabledCondition.class) |
||||
public @interface ConditionalOnJustAuthEnabled { |
||||
} |
@ -0,0 +1,53 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.condition; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import com.liuhung.engine.assistant.core.context.PropertyResolver; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Condition; |
||||
import org.springframework.context.annotation.ConditionContext; |
||||
import org.springframework.core.type.AnnotatedTypeMetadata; |
||||
|
||||
/** |
||||
* <p>Description: JusAuth注入条件 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/27 22:08 |
||||
*/ |
||||
public class JustAuthEnabledCondition implements Condition { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JustAuthEnabledCondition.class); |
||||
|
||||
@SuppressWarnings("NullableProblems") |
||||
@Override |
||||
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) { |
||||
boolean result = PropertyResolver.getBoolean(conditionContext, AccessConstants.ITEM_JUSTAUTH_ENABLED, false); |
||||
log.debug("[Quafer] |- Condition [JustAuth Enabled] value is [{}]", result); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,92 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.configuration; |
||||
|
||||
import com.liuhung.engine.access.justauth.annotation.ConditionalOnJustAuthEnabled; |
||||
import com.liuhung.engine.access.justauth.processor.JustAuthAccessHandler; |
||||
import com.liuhung.engine.access.justauth.processor.JustAuthProcessor; |
||||
import com.liuhung.engine.access.justauth.properties.JustAuthProperties; |
||||
import com.liuhung.engine.access.justauth.stamp.JustAuthStateStampManager; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
/** |
||||
* <p>Description: JustAuth配置 </p> |
||||
* <p> |
||||
* 仅在存在quafer.platform.social.justauth.configs配置的情况下才注入 |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/22 11:25 |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnJustAuthEnabled |
||||
@EnableConfigurationProperties(JustAuthProperties.class) |
||||
public class JustAuthConfiguration { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JustAuthConfiguration.class); |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
log.debug("[Quafer] |- SDK [Access Just Auth] Auto Configure."); |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public JustAuthStateStampManager justAuthStateStampManager(JustAuthProperties justAuthProperties) { |
||||
JustAuthStateStampManager justAuthStateStampManager = new JustAuthStateStampManager(); |
||||
justAuthStateStampManager.setJustAuthProperties(justAuthProperties); |
||||
log.trace("[Quafer] |- Bean [Just Auth State Redis Cache] Auto Configure."); |
||||
return justAuthStateStampManager; |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnBean(JustAuthStateStampManager.class) |
||||
@ConditionalOnMissingBean |
||||
public JustAuthProcessor justAuthProcessor(JustAuthStateStampManager justAuthStateStampManager, JustAuthProperties justAuthProperties) { |
||||
JustAuthProcessor justAuthProcessor = new JustAuthProcessor(); |
||||
justAuthProcessor.setJustAuthStateRedisCache(justAuthStateStampManager); |
||||
justAuthProcessor.setJustAuthProperties(justAuthProperties); |
||||
log.trace("[Quafer] |- Bean [Just Auth Request Generator] Auto Configure."); |
||||
return justAuthProcessor; |
||||
} |
||||
|
||||
@Bean(AccountType.JUST_AUTH_HANDLER) |
||||
@ConditionalOnBean(JustAuthProcessor.class) |
||||
@ConditionalOnMissingBean |
||||
public JustAuthAccessHandler justAuthAccessHandler(JustAuthProcessor justAuthProcessor) { |
||||
JustAuthAccessHandler justAuthAccessHandler = new JustAuthAccessHandler(justAuthProcessor); |
||||
log.debug("[Quafer] |- Bean [Just Auth Access Handler] Auto Configure."); |
||||
return justAuthAccessHandler; |
||||
} |
||||
} |
@ -0,0 +1,118 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.processor; |
||||
|
||||
import com.liuhung.engine.access.core.definition.AccessHandler; |
||||
import com.liuhung.engine.access.core.definition.AccessResponse; |
||||
import com.liuhung.engine.access.core.definition.AccessUserDetails; |
||||
import com.liuhung.engine.access.core.exception.AccessIdentityVerificationFailedException; |
||||
import com.liuhung.engine.assistant.core.domain.AccessPrincipal; |
||||
import me.zhyd.oauth.model.AuthCallback; |
||||
import me.zhyd.oauth.model.AuthResponse; |
||||
import me.zhyd.oauth.model.AuthToken; |
||||
import me.zhyd.oauth.model.AuthUser; |
||||
import me.zhyd.oauth.request.AuthRequest; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
|
||||
/** |
||||
* <p>Description: JustAuth 接入处理器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/25 17:45 |
||||
*/ |
||||
public class JustAuthAccessHandler implements AccessHandler { |
||||
|
||||
private final JustAuthProcessor justAuthProcessor; |
||||
|
||||
public JustAuthAccessHandler(JustAuthProcessor justAuthProcessor) { |
||||
this.justAuthProcessor = justAuthProcessor; |
||||
} |
||||
|
||||
@Override |
||||
public AccessResponse preProcess(String core, String... params) { |
||||
String url = justAuthProcessor.getAuthorizeUrl(core); |
||||
|
||||
AccessResponse accessResponse = new AccessResponse(); |
||||
accessResponse.setAuthorizeUrl(url); |
||||
return accessResponse; |
||||
} |
||||
|
||||
@Override |
||||
public AccessUserDetails loadUserDetails(String source, AccessPrincipal accessPrincipal) { |
||||
AuthRequest authRequest = justAuthProcessor.getAuthRequest(source); |
||||
|
||||
AuthCallback authCallback = AuthCallback.builder() |
||||
.code(accessPrincipal.getCode()) |
||||
.auth_code(accessPrincipal.getAuth_code()) |
||||
.state(accessPrincipal.getState()) |
||||
.authorization_code(accessPrincipal.getAuthorization_code()) |
||||
.oauth_token(accessPrincipal.getOauth_token()) |
||||
.oauth_verifier(accessPrincipal.getOauth_verifier()) |
||||
.build(); |
||||
|
||||
AuthResponse<AuthUser> response = authRequest.login(authCallback); |
||||
if (response.ok()) { |
||||
AuthUser authUser = response.getData(); |
||||
return convertAuthUserToAccessUserDetails(authUser); |
||||
} |
||||
|
||||
throw new AccessIdentityVerificationFailedException(response.getMsg()); |
||||
} |
||||
|
||||
private AccessUserDetails convertAuthUserToAccessUserDetails(AuthUser authUser) { |
||||
AccessUserDetails sysSocialUser = new AccessUserDetails(); |
||||
sysSocialUser.setUuid(authUser.getUuid()); |
||||
sysSocialUser.setUserName(authUser.getUsername()); |
||||
sysSocialUser.setNickName(authUser.getNickname()); |
||||
sysSocialUser.setAvatar(authUser.getAvatar()); |
||||
sysSocialUser.setBlog(authUser.getBlog()); |
||||
sysSocialUser.setCompany(authUser.getCompany()); |
||||
sysSocialUser.setLocation(authUser.getLocation()); |
||||
sysSocialUser.setEmail(authUser.getEmail()); |
||||
sysSocialUser.setRemark(authUser.getRemark()); |
||||
sysSocialUser.setGender(authUser.getGender()); |
||||
sysSocialUser.setSource(authUser.getSource()); |
||||
AuthToken authToken = authUser.getToken(); |
||||
if (ObjectUtils.isNotEmpty(authToken)) { |
||||
setAccessUserInfo(sysSocialUser, authToken.getAccessToken(), authToken.getExpireIn(), authToken.getRefreshToken(), authToken.getRefreshTokenExpireIn(), authToken.getScope(), authToken.getTokenType(), authToken.getUid(), authToken.getOpenId(), authToken.getAccessCode(), authToken.getUnionId()); |
||||
} |
||||
|
||||
return sysSocialUser; |
||||
} |
||||
|
||||
private void setAccessUserInfo(AccessUserDetails accessUserDetails, String accessToken, Integer expireIn, String refreshToken, Integer refreshTokenExpireIn, String scope, String tokenType, String uid, String openId, String accessCode, String unionId) { |
||||
accessUserDetails.setAccessToken(accessToken); |
||||
accessUserDetails.setExpireIn(expireIn); |
||||
accessUserDetails.setRefreshToken(refreshToken); |
||||
accessUserDetails.setRefreshTokenExpireIn(refreshTokenExpireIn); |
||||
accessUserDetails.setScope(scope); |
||||
accessUserDetails.setTokenType(tokenType); |
||||
accessUserDetails.setUid(uid); |
||||
accessUserDetails.setOpenId(openId); |
||||
accessUserDetails.setAccessCode(accessCode); |
||||
accessUserDetails.setUnionId(unionId); |
||||
} |
||||
} |
@ -0,0 +1,210 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.processor; |
||||
|
||||
import com.liuhung.engine.access.core.exception.AccessConfigErrorException; |
||||
import com.liuhung.engine.access.core.exception.IllegalAccessSourceException; |
||||
import com.liuhung.engine.access.justauth.properties.JustAuthProperties; |
||||
import com.liuhung.engine.access.justauth.stamp.JustAuthStateStampManager; |
||||
import cn.hutool.core.util.EnumUtil; |
||||
import me.zhyd.oauth.config.AuthConfig; |
||||
import me.zhyd.oauth.config.AuthDefaultSource; |
||||
import me.zhyd.oauth.request.*; |
||||
import me.zhyd.oauth.utils.AuthStateUtils; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* <p>Description: JustAuth请求的生成器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/22 11:23 |
||||
*/ |
||||
public class JustAuthProcessor { |
||||
|
||||
private JustAuthProperties justAuthProperties; |
||||
private JustAuthStateStampManager justAuthStateStampManager; |
||||
|
||||
public void setJustAuthProperties(JustAuthProperties justAuthProperties) { |
||||
this.justAuthProperties = justAuthProperties; |
||||
} |
||||
|
||||
public void setJustAuthStateRedisCache(JustAuthStateStampManager justAuthStateStampManager) { |
||||
this.justAuthStateStampManager = justAuthStateStampManager; |
||||
} |
||||
|
||||
private JustAuthStateStampManager getJustAuthStateRedisCache() { |
||||
return justAuthStateStampManager; |
||||
} |
||||
|
||||
public AuthRequest getAuthRequest(String source) { |
||||
AuthDefaultSource authDefaultSource = parseAuthDefaultSource(source); |
||||
AuthConfig authConfig = getAuthConfig(authDefaultSource); |
||||
return getAuthRequest(authDefaultSource, authConfig); |
||||
} |
||||
|
||||
public AuthRequest getAuthRequest(String source, AuthConfig authConfig) { |
||||
AuthDefaultSource authDefaultSource = parseAuthDefaultSource(source); |
||||
return getAuthRequest(authDefaultSource, authConfig); |
||||
} |
||||
|
||||
/** |
||||
* 返回带state参数的授权url,授权回调时会带上这个state |
||||
* |
||||
* @param source 第三方登录的类别 {@link AuthDefaultSource} |
||||
* @return 返回授权地址 |
||||
*/ |
||||
public String getAuthorizeUrl(String source) { |
||||
AuthRequest authRequest = this.getAuthRequest(source); |
||||
return authRequest.authorize(AuthStateUtils.createState()); |
||||
} |
||||
|
||||
public String getAuthorizeUrl(String source, AuthConfig authConfig) { |
||||
AuthRequest authRequest = this.getAuthRequest(source, authConfig); |
||||
return authRequest.authorize(AuthStateUtils.createState()); |
||||
} |
||||
|
||||
public Map<String, String> getAuthorizeUrls() { |
||||
Map<String, AuthConfig> configs = getConfigs(); |
||||
return configs.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> getAuthorizeUrl(entry.getKey(), entry.getValue()))); |
||||
} |
||||
|
||||
@NotNull |
||||
private Map<String, AuthConfig> getConfigs() { |
||||
Map<String, AuthConfig> configs = justAuthProperties.getConfigs(); |
||||
if(MapUtils.isEmpty(configs)) { |
||||
throw new AccessConfigErrorException(); |
||||
} |
||||
return configs; |
||||
} |
||||
|
||||
|
||||
@NotNull |
||||
private AuthConfig getAuthConfig(AuthDefaultSource authDefaultSource) { |
||||
Map<String, AuthConfig> configs = getConfigs(); |
||||
|
||||
AuthConfig authConfig = configs.get(authDefaultSource.name()); |
||||
// 找不到对应关系,直接返回空
|
||||
if (ObjectUtils.isEmpty(authConfig)) { |
||||
throw new AccessConfigErrorException(); |
||||
} |
||||
return authConfig; |
||||
} |
||||
|
||||
private static AuthDefaultSource parseAuthDefaultSource(String source) { |
||||
AuthDefaultSource authDefaultSource; |
||||
|
||||
try { |
||||
authDefaultSource = EnumUtil.fromString(AuthDefaultSource.class, source.toUpperCase()); |
||||
} catch (IllegalArgumentException e) { |
||||
throw new IllegalAccessSourceException(); |
||||
} |
||||
return authDefaultSource; |
||||
} |
||||
|
||||
private AuthRequest getAuthRequest(AuthDefaultSource authDefaultSource, AuthConfig authConfig) { |
||||
switch (authDefaultSource) { |
||||
case GITHUB: |
||||
return new AuthGithubRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case WEIBO: |
||||
return new AuthWeiboRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case GITEE: |
||||
return new AuthGiteeRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case DINGTALK: |
||||
return new AuthDingTalkRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case BAIDU: |
||||
return new AuthBaiduRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case CSDN: |
||||
return new AuthCsdnRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case CODING: |
||||
return new AuthCodingRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case OSCHINA: |
||||
return new AuthOschinaRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case ALIPAY: |
||||
return new AuthAlipayRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case QQ: |
||||
return new AuthQqRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case WECHAT_MP: |
||||
return new AuthWeChatMpRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case WECHAT_OPEN: |
||||
return new AuthWeChatOpenRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case WECHAT_ENTERPRISE: |
||||
return new AuthWeChatEnterpriseQrcodeRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case WECHAT_ENTERPRISE_WEB: |
||||
return new AuthWeChatEnterpriseWebRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case TAOBAO: |
||||
return new AuthTaobaoRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case GOOGLE: |
||||
return new AuthGoogleRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case FACEBOOK: |
||||
return new AuthFacebookRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case DOUYIN: |
||||
return new AuthDouyinRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case LINKEDIN: |
||||
return new AuthLinkedinRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case MICROSOFT: |
||||
return new AuthMicrosoftRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case MI: |
||||
return new AuthMiRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case TOUTIAO: |
||||
return new AuthToutiaoRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case TEAMBITION: |
||||
return new AuthTeambitionRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case RENREN: |
||||
return new AuthRenrenRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case PINTEREST: |
||||
return new AuthPinterestRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case STACK_OVERFLOW: |
||||
return new AuthStackOverflowRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case HUAWEI: |
||||
return new AuthHuaweiRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case GITLAB: |
||||
return new AuthGitlabRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case KUJIALE: |
||||
return new AuthKujialeRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case ELEME: |
||||
return new AuthElemeRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case MEITUAN: |
||||
return new AuthMeituanRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case TWITTER: |
||||
return new AuthTwitterRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case FEISHU: |
||||
return new AuthFeishuRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case JD: |
||||
return new AuthJdRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case ALIYUN: |
||||
return new AuthAliyunRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
case XMLY: |
||||
return new AuthXmlyRequest(authConfig, this.getJustAuthStateRedisCache()); |
||||
default: |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.properties; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import me.zhyd.oauth.config.AuthConfig; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
import java.time.Duration; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 用于支持JustAuth第三方登录的配置 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/16 10:24 |
||||
*/ |
||||
@ConfigurationProperties(prefix = AccessConstants.PROPERTY_ACCESS_JUSTAUTH) |
||||
public class JustAuthProperties { |
||||
|
||||
/** |
||||
* 是否开启 |
||||
*/ |
||||
private Boolean enabled; |
||||
/** |
||||
* State 缓存时长,默认5分钟 |
||||
*/ |
||||
private Duration timeout = Duration.ofMinutes(5); |
||||
/** |
||||
* 第三方系统登录配置信息 |
||||
*/ |
||||
private Map<String, AuthConfig> configs; |
||||
|
||||
public Boolean getEnabled() { |
||||
return enabled; |
||||
} |
||||
|
||||
public void setEnabled(Boolean enabled) { |
||||
this.enabled = enabled; |
||||
} |
||||
|
||||
public Duration getTimeout() { |
||||
return timeout; |
||||
} |
||||
|
||||
public void setTimeout(Duration timeout) { |
||||
this.timeout = timeout; |
||||
} |
||||
|
||||
public Map<String, AuthConfig> getConfigs() { |
||||
return configs; |
||||
} |
||||
|
||||
public void setConfigs(Map<String, AuthConfig> configs) { |
||||
this.configs = configs; |
||||
} |
||||
} |
@ -0,0 +1,78 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.justauth.stamp; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import com.liuhung.engine.access.justauth.properties.JustAuthProperties; |
||||
import com.liuhung.engine.cache.jetcache.stamp.AbstractStampManager; |
||||
import cn.hutool.core.util.IdUtil; |
||||
import me.zhyd.oauth.cache.AuthStateCache; |
||||
|
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* <p>Description: 自定义JustAuth State Cache </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/22 10:22 |
||||
*/ |
||||
public class JustAuthStateStampManager extends AbstractStampManager<String, String> implements AuthStateCache { |
||||
|
||||
public JustAuthStateStampManager() { |
||||
super(AccessConstants.CACHE_NAME_TOKEN_JUSTAUTH); |
||||
} |
||||
|
||||
private JustAuthProperties justAuthProperties; |
||||
|
||||
public void setJustAuthProperties(JustAuthProperties justAuthProperties) { |
||||
this.justAuthProperties = justAuthProperties; |
||||
} |
||||
|
||||
@Override |
||||
public void afterPropertiesSet() throws Exception { |
||||
super.setExpire(justAuthProperties.getTimeout()); |
||||
} |
||||
|
||||
@Override |
||||
public String nextStamp(String key) { |
||||
return IdUtil.fastSimpleUUID(); |
||||
} |
||||
|
||||
@Override |
||||
public void cache(String key, String value) { |
||||
this.put(key, value); |
||||
} |
||||
|
||||
@Override |
||||
public void cache(String key, String value, long expire) { |
||||
this.put(key, value, expire, TimeUnit.MILLISECONDS); |
||||
} |
||||
|
||||
@Override |
||||
public boolean containsKey(String key) { |
||||
return this.containKey(key); |
||||
} |
||||
} |
@ -0,0 +1,51 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>engine-access</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<artifactId>access-sdk-wxapp</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<description>基于 Spring Authorization Server 的 微信小程序外部接入基础核心组件模块</description> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-core</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,44 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.annotation; |
||||
|
||||
import com.liuhung.engine.access.wxapp.condition.WxappEnabledCondition; |
||||
import org.springframework.context.annotation.Conditional; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序开启条件注解 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/24 14:40 |
||||
*/ |
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
@Conditional(WxappEnabledCondition.class) |
||||
public @interface ConditionalOnWxappEnabled { |
||||
} |
@ -0,0 +1,53 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.condition; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import com.liuhung.engine.assistant.core.context.PropertyResolver; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Condition; |
||||
import org.springframework.context.annotation.ConditionContext; |
||||
import org.springframework.core.type.AnnotatedTypeMetadata; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序注入条件 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/27 22:13 |
||||
*/ |
||||
public class WxappEnabledCondition implements Condition { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxappEnabledCondition.class); |
||||
|
||||
@SuppressWarnings("NullableProblems") |
||||
@Override |
||||
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) { |
||||
boolean result = PropertyResolver.getBoolean(conditionContext, AccessConstants.ITEM_WXAPP_ENABLED); |
||||
log.debug("[Quafer] |- Condition [Wxapp Enabled] value is [{}]", result); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.configuration; |
||||
|
||||
import com.liuhung.engine.access.wxapp.annotation.ConditionalOnWxappEnabled; |
||||
import com.liuhung.engine.access.wxapp.processor.WxappAccessHandler; |
||||
import com.liuhung.engine.access.wxapp.processor.WxappLogHandler; |
||||
import com.liuhung.engine.access.wxapp.processor.WxappProcessor; |
||||
import com.liuhung.engine.access.wxapp.properties.WxappProperties; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序后配置 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/3/29 9:27 |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnWxappEnabled |
||||
@EnableConfigurationProperties(WxappProperties.class) |
||||
public class WxappConfiguration { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxappConfiguration.class); |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
log.debug("[Quafer] |- SDK [Access Wxapp] Auto Configure."); |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public WxappProcessor wxappProcessor(WxappProperties wxappProperties) { |
||||
WxappProcessor wxappProcessor = new WxappProcessor(); |
||||
wxappProcessor.setWxappProperties(wxappProperties); |
||||
wxappProcessor.setWxappLogHandler(new WxappLogHandler()); |
||||
log.trace("[Quafer] |- Bean [Wxapp Processor] Auto Configure."); |
||||
return wxappProcessor; |
||||
} |
||||
|
||||
@Bean(AccountType.WECHAT_MINI_APP_HANDLER) |
||||
@ConditionalOnBean(WxappProcessor.class) |
||||
@ConditionalOnMissingBean |
||||
public WxappAccessHandler wxappAccessHandler(WxappProcessor wxappProcessor) { |
||||
WxappAccessHandler wxappAccessHandler = new WxappAccessHandler(wxappProcessor); |
||||
log.debug("[Quafer] |- Bean [Wxapp Access Handler] Auto Configure."); |
||||
return wxappAccessHandler; |
||||
} |
||||
} |
@ -0,0 +1,52 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.enums; |
||||
|
||||
/** |
||||
* <p>Description: 跳转小程序类型 </p> |
||||
* <p> |
||||
* developer为开发版;trial为体验版;formal为正式版;默认为正式版 |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/9 16:09 |
||||
*/ |
||||
public enum MiniProgramState { |
||||
|
||||
/** |
||||
* 开发版 |
||||
*/ |
||||
developer, |
||||
|
||||
/** |
||||
* 体验版 |
||||
*/ |
||||
trial, |
||||
|
||||
/** |
||||
* 正式版 |
||||
*/ |
||||
formal; |
||||
} |
@ -0,0 +1,90 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.processor; |
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
||||
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; |
||||
import com.liuhung.engine.access.core.definition.AccessHandler; |
||||
import com.liuhung.engine.access.core.definition.AccessResponse; |
||||
import com.liuhung.engine.access.core.definition.AccessUserDetails; |
||||
import com.liuhung.engine.access.core.exception.AccessIdentityVerificationFailedException; |
||||
import com.liuhung.engine.access.core.exception.AccessPreProcessFailedException; |
||||
import com.liuhung.engine.assistant.core.definition.constants.SymbolConstants; |
||||
import com.liuhung.engine.assistant.core.domain.AccessPrincipal; |
||||
import com.liuhung.engine.assistant.core.enums.AccountType; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序接入处理器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 10:56 |
||||
*/ |
||||
public class WxappAccessHandler implements AccessHandler { |
||||
|
||||
private final WxappProcessor wxappProcessor; |
||||
|
||||
public WxappAccessHandler(WxappProcessor wxappProcessor) { |
||||
this.wxappProcessor = wxappProcessor; |
||||
} |
||||
|
||||
@Override |
||||
public AccessResponse preProcess(String core, String... params) { |
||||
WxMaJscode2SessionResult wxMaSession = wxappProcessor.login(core, params[0]); |
||||
if (ObjectUtils.isNotEmpty(wxMaSession)) { |
||||
AccessResponse accessResponse = new AccessResponse(); |
||||
accessResponse.setSession(wxMaSession); |
||||
return accessResponse; |
||||
} |
||||
|
||||
throw new AccessPreProcessFailedException("Wxapp login failed"); |
||||
} |
||||
|
||||
@Override |
||||
public AccessUserDetails loadUserDetails(String source, AccessPrincipal accessPrincipal) { |
||||
WxMaUserInfo wxMaUserInfo = wxappProcessor.getUserInfo(accessPrincipal.getAppId(), accessPrincipal.getSessionKey(), accessPrincipal.getEncryptedData(), accessPrincipal.getIv()); |
||||
if (ObjectUtils.isNotEmpty(wxMaUserInfo)) { |
||||
return convertWxMaUserInfoToAccessUserDetails(wxMaUserInfo, accessPrincipal); |
||||
} |
||||
|
||||
throw new AccessIdentityVerificationFailedException("Can not find the userinfo from Wechat!"); |
||||
} |
||||
|
||||
private AccessUserDetails convertWxMaUserInfoToAccessUserDetails(WxMaUserInfo wxMaUserInfo, AccessPrincipal accessPrincipal) { |
||||
AccessUserDetails accessUserDetails = new AccessUserDetails(); |
||||
accessUserDetails.setUuid(accessPrincipal.getOpenId()); |
||||
accessUserDetails.setUserName(wxMaUserInfo.getNickName()); |
||||
accessUserDetails.setNickName(wxMaUserInfo.getNickName()); |
||||
accessUserDetails.setAvatar(wxMaUserInfo.getAvatarUrl()); |
||||
accessUserDetails.setLocation(wxMaUserInfo.getCountry() + SymbolConstants.FORWARD_SLASH + wxMaUserInfo.getProvince() + SymbolConstants.FORWARD_SLASH + wxMaUserInfo.getCity()); |
||||
accessUserDetails.setSource(AccountType.WXAPP.name()); |
||||
accessUserDetails.setOpenId(accessPrincipal.getOpenId()); |
||||
accessUserDetails.setUnionId(accessPrincipal.getUnionId()); |
||||
accessUserDetails.setAppId(wxMaUserInfo.getWatermark().getAppid()); |
||||
accessUserDetails.setPhoneNumber(wxMaUserInfo.getWatermark().getAppid()); |
||||
return accessUserDetails; |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.processor; |
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService; |
||||
import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage; |
||||
import cn.binarywang.wx.miniapp.bean.WxMaMessage; |
||||
import cn.binarywang.wx.miniapp.message.WxMaMessageHandler; |
||||
import cn.binarywang.wx.miniapp.message.WxMaXmlOutMessage; |
||||
import me.chanjar.weixin.common.error.WxErrorException; |
||||
import me.chanjar.weixin.common.session.WxSessionManager; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序Log处理器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/7 12:44 |
||||
*/ |
||||
public class WxappLogHandler implements WxMaMessageHandler { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxappLogHandler.class); |
||||
|
||||
@Override |
||||
public WxMaXmlOutMessage handle(WxMaMessage wxMaMessage, Map<String, Object> context, WxMaService wxMaService, WxSessionManager sessionManager) throws WxErrorException { |
||||
log.info("收到消息:" + wxMaMessage.toString()); |
||||
wxMaService.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMaMessage.toJson()) |
||||
.toUser(wxMaMessage.getFromUser()).build()); |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,351 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.processor; |
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService; |
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; |
||||
import cn.binarywang.wx.miniapp.bean.*; |
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; |
||||
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter; |
||||
import com.liuhung.engine.access.wxapp.properties.WxappProperties; |
||||
import com.google.common.collect.Maps; |
||||
import me.chanjar.weixin.common.error.WxErrorException; |
||||
import me.chanjar.weixin.common.error.WxRuntimeException; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
|
||||
import java.io.File; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序核心基础代码 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/27 20:29 |
||||
*/ |
||||
public class WxappProcessor implements InitializingBean { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxappProcessor.class); |
||||
|
||||
private WxappProperties wxappProperties; |
||||
private WxappLogHandler wxappLogHandler; |
||||
|
||||
private Map<String, WxMaMessageRouter> wxMaMessagerouters = Maps.newHashMap(); |
||||
private Map<String, WxMaService> wxMaServices = Maps.newHashMap(); |
||||
|
||||
public void setWxappProperties(WxappProperties wxappProperties) { |
||||
this.wxappProperties = wxappProperties; |
||||
} |
||||
|
||||
public void setWxappLogHandler(WxappLogHandler wxappLogHandler) { |
||||
this.wxappLogHandler = wxappLogHandler; |
||||
} |
||||
|
||||
@Override |
||||
public void afterPropertiesSet() throws Exception { |
||||
List<WxappProperties.Config> configs = this.wxappProperties.getConfigs(); |
||||
if (configs == null) { |
||||
throw new WxRuntimeException("Weixin Mini App Configuraiton is not setting!"); |
||||
} |
||||
|
||||
wxMaServices = configs.stream() |
||||
.map(a -> { |
||||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
||||
// WxMaDefaultConfigImpl config = new WxMaRedisConfigImpl(new JedisPool());
|
||||
// 使用上面的配置时,需要同时引入jedis-lock的依赖,否则会报类无法找到的异常
|
||||
config.setAppid(a.getAppId()); |
||||
config.setSecret(a.getSecret()); |
||||
config.setToken(a.getToken()); |
||||
config.setAesKey(a.getAesKey()); |
||||
config.setMsgDataFormat(a.getMessageDataFormat()); |
||||
|
||||
WxMaService service = new WxMaServiceImpl(); |
||||
service.setWxMaConfig(config); |
||||
wxMaMessagerouters.put(a.getAppId(), this.newRouter(service)); |
||||
return service; |
||||
}).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); |
||||
|
||||
log.info("[Quafer] |- Bean [quafer Weixin Mini App] Auto Configure."); |
||||
} |
||||
|
||||
private WxMaMessageRouter newRouter(WxMaService wxMaService) { |
||||
final WxMaMessageRouter router = new WxMaMessageRouter(wxMaService); |
||||
router.rule().handler(wxappLogHandler).next(); |
||||
return router; |
||||
} |
||||
|
||||
public WxMaService getWxMaService(String appid) { |
||||
WxMaService wxMaService = wxMaServices.get(appid); |
||||
if (ObjectUtils.isEmpty(wxMaService)) { |
||||
throw new IllegalArgumentException(String.format("Cannot find the configuration of appid=[%s], please check!", appid)); |
||||
} |
||||
|
||||
return wxMaService; |
||||
} |
||||
|
||||
public WxMaMessageRouter getWxMaMessageRouter(String appid) { |
||||
return wxMaMessagerouters.get(appid); |
||||
} |
||||
|
||||
public WxMaService getWxMaService() { |
||||
String appId = wxappProperties.getDefaultAppId(); |
||||
if (StringUtils.isBlank(appId)) { |
||||
log.error("[Quafer] |- Must set [quafer.platform.social.wxapp.default-app-id] property, or use getWxMaService(String appid)!"); |
||||
throw new IllegalArgumentException("Must set [quafer.platform.social.wxapp.default-app-id] property"); |
||||
} |
||||
return this.getWxMaService(appId); |
||||
} |
||||
|
||||
/** |
||||
* 获取登录后的session信息. |
||||
* |
||||
* @param code 登录时获取的 code |
||||
* @param wxMaService 微信小程序服务 |
||||
* @return {@link WxMaJscode2SessionResult} |
||||
*/ |
||||
private WxMaJscode2SessionResult getSessionInfo(String code, WxMaService wxMaService) { |
||||
try { |
||||
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code); |
||||
log.debug("[Quafer] |- Weixin Mini App login successfully!"); |
||||
return sessionResult; |
||||
} catch (WxErrorException e) { |
||||
log.error("[Quafer] |- Weixin Mini App login failed! For reason: {}", e.getMessage()); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 验证用户完整性 |
||||
* |
||||
* @param sessionKey 会话密钥 |
||||
* @param rawData 微信用户基本信息 |
||||
* @param signature 数据签名 |
||||
* @param wxMaService 微信小程序服务 |
||||
* @return true 完整, false 不完整 |
||||
*/ |
||||
private boolean checkUserInfo(String sessionKey, String rawData, String signature, WxMaService wxMaService) { |
||||
if (wxMaService.getUserService().checkUserInfo(sessionKey, rawData, signature)) { |
||||
log.debug("[Quafer] |- Weixin Mini App user info is valid!"); |
||||
return true; |
||||
} else { |
||||
log.warn("[Quafer] |- Weixin Mini App user check failed!"); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 解密用户信息 |
||||
* |
||||
* @param sessionKey 会话密钥 |
||||
* @param encryptedData 消息密文 |
||||
* @param iv 加密算法的初始向量 |
||||
* @param wxMaService 微信小程序服务 |
||||
* @return {@link WxMaUserInfo} |
||||
*/ |
||||
private WxMaUserInfo getUserInfo(String sessionKey, String encryptedData, String iv, WxMaService wxMaService) { |
||||
WxMaUserInfo wxMaUserInfo = wxMaService.getUserService().getUserInfo(sessionKey, encryptedData, iv); |
||||
log.debug("[Quafer] |- Weixin Mini App get user info successfully!"); |
||||
return wxMaUserInfo; |
||||
} |
||||
|
||||
/** |
||||
* 解密手机号 |
||||
* <p> |
||||
* 确认下前后端传递的参数有没有做UrlEncode/UrlDecode,因为encryptedData里会包含特殊字符在传递参数时被转义,可能服务器端实际拿到的参数encryptedData并不是前端实际获取到的值,导致SDK调用微信相应接口时无法解密而报错,只要保证前端实际获取到的encryptedData和服务器端调用SDK时传入的encryptedData一致就不会报错的,SDK中方法并无问题;建议让前后台都打印下日志,看下服务端最终使用的参数值是否还是前端获取到的原始值呢。PS:SpringBoot某些场景下form表单参数是会自动做UrlDecode的... |
||||
* <p> |
||||
* {@see :https://github.com/Wechat-Group/WxJava/issues/359}
|
||||
* @param wxMaService 微信小程序服务 |
||||
* @return {@link WxMaPhoneNumberInfo} |
||||
*/ |
||||
private WxMaPhoneNumberInfo getPhoneNumberInfo(String code, WxMaService wxMaService) { |
||||
log.info("[Quafer] |- Weixin Mini App get code: {}", code); |
||||
|
||||
WxMaPhoneNumberInfo wxMaPhoneNumberInfo; |
||||
try { |
||||
wxMaPhoneNumberInfo = wxMaService.getUserService().getPhoneNoInfo(code); |
||||
log.debug("[Quafer] |- Weixin Mini App get phone number successfully!"); |
||||
log.debug("[Quafer] |- WxMaPhoneNumberInfo : {}", wxMaPhoneNumberInfo); |
||||
return wxMaPhoneNumberInfo; |
||||
} catch (Exception e) { |
||||
log.error("[Quafer] |- Weixin Mini App get phone number failed!"); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
private boolean checkUserInfo(String rawData, String signature) { |
||||
return StringUtils.isNotBlank(rawData) && StringUtils.isNotBlank(signature); |
||||
} |
||||
|
||||
public WxMaJscode2SessionResult login(String code, String appId) { |
||||
WxMaService wxMaService = getWxMaService(appId); |
||||
if (StringUtils.isNotBlank(code) && ObjectUtils.isNotEmpty(wxMaService)) { |
||||
return this.getSessionInfo(code, wxMaService); |
||||
} else { |
||||
log.error("[Quafer] |- Weixin Mini App login failed, please check code param!"); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public WxMaUserInfo getUserInfo(String appId, String sessionKey, String encryptedData, String iv) { |
||||
return this.getUserInfo(appId, sessionKey, encryptedData, iv, null, null); |
||||
} |
||||
|
||||
public WxMaUserInfo getUserInfo(String appId, String sessionKey, String encryptedData, String iv, String rawData, String signature) { |
||||
|
||||
WxMaService wxMaService = getWxMaService(appId); |
||||
|
||||
if (ObjectUtils.isNotEmpty(wxMaService)) { |
||||
// 用户信息校验
|
||||
if (checkUserInfo(rawData, signature)) { |
||||
if (checkUserInfo(sessionKey, rawData, signature, wxMaService)) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
return this.getUserInfo(sessionKey, encryptedData, iv, wxMaService); |
||||
} else { |
||||
log.error("[Quafer] |- Weixin Mini App get user info failed!"); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 根据直接创建的WxMaSubscribeMessage发送订阅消息 |
||||
* |
||||
* @param appId 小程序appId |
||||
* @param subscribeMessage 参见 {@link WxMaSubscribeMessage} |
||||
* @return true 发送成功,false 发送失败,或者参数subscribeId配置不对,无法获取相应的WxMaSubscribeMessage |
||||
*/ |
||||
public boolean sendSubscribeMessage(String appId, WxMaSubscribeMessage subscribeMessage) { |
||||
try { |
||||
this.getWxMaService(appId).getMsgService().sendSubscribeMsg(subscribeMessage); |
||||
log.debug("[Quafer] |- Send Subscribe Message Successfully!"); |
||||
return true; |
||||
} catch (WxErrorException e) { |
||||
log.debug("[Quafer] |- Send Subscribe Message Failed!", e); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 检查一段文本是否含有违法违规内容。 |
||||
* 应用场景举例: |
||||
* · 用户个人资料违规文字检测; |
||||
* · 媒体新闻类用户发表文章,评论内容检测; |
||||
* · 游戏类用户编辑上传的素材(如答题类小游戏用户上传的问题及答案)检测等。 频率限制:单个 appId 调用上限为 4000 次/分钟,2,000,000 次/天* |
||||
* · 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/msgSecCheck.html
|
||||
* |
||||
* @param appId 小程序appId |
||||
* @param message 需要检测的字符串 |
||||
* @return 是否违规 boolean |
||||
*/ |
||||
public boolean checkMessage(String appId, String message) { |
||||
try { |
||||
this.getWxMaService(appId).getSecCheckService().checkMessage(message); |
||||
log.debug("[Quafer] |- Check Message Successfully!"); |
||||
return true; |
||||
} catch (WxErrorException e) { |
||||
log.debug("[Quafer] |- Check Message Failed!", e); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 校验一张图片是否含有违法违规内容 |
||||
* |
||||
* @param appId 小程序appId |
||||
* @param fileUrl 需要检测图片的网地址 |
||||
* @return 是否违规 boolean |
||||
*/ |
||||
public boolean checkImage(String appId, String fileUrl) { |
||||
try { |
||||
this.getWxMaService(appId).getSecCheckService().checkImage(fileUrl); |
||||
log.debug("[Quafer] |- Check Image Successfully!"); |
||||
return true; |
||||
} catch (WxErrorException e) { |
||||
log.debug("[Quafer] |- Check Image Failed! Detail is :{}", e.getMessage()); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 校验一张图片是否含有违法违规内容. |
||||
* <p> |
||||
* 应用场景举例: |
||||
* 1)图片智能鉴黄:涉及拍照的工具类应用(如美拍,识图类应用)用户拍照上传检测;电商类商品上架图片检测;媒体类用户文章里的图片检测等; |
||||
* 2)敏感人脸识别:用户头像;媒体类用户文章里的图片检测;社交类用户上传的图片检测等。频率限制:单个 appId 调用上限为 1000 次/分钟,100,000 次/天 |
||||
* 详情请见: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sec-check/imgSecCheck.html
|
||||
* |
||||
* @param appId 小程序appId |
||||
* @param file 图片文件 |
||||
* @return 是否违规 boolean |
||||
*/ |
||||
public boolean checkImage(String appId, File file) { |
||||
try { |
||||
this.getWxMaService(appId).getSecCheckService().checkImage(file); |
||||
log.debug("[Quafer] |- Check Image Successfully!"); |
||||
return true; |
||||
} catch (WxErrorException e) { |
||||
log.debug("[Quafer] |- Check Image Failed! Detail is :{}", e.getMessage()); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 异步校验图片/音频是否含有违法违规内容。 |
||||
* 应用场景举例: |
||||
* 语音风险识别:社交类用户发表的语音内容检测; |
||||
* 图片智能鉴黄:涉及拍照的工具类应用(如美拍,识图类应用)用户拍照上传检测;电商类商品上架图片检测;媒体类用户文章里的图片检测等; |
||||
* 敏感人脸识别:用户头像;媒体类用户文章里的图片检测;社交类用户上传的图片检测等。 |
||||
* 频率限制: |
||||
* 单个 appId 调用上限为 2000 次/分钟,200,000 次/天;文件大小限制:单个文件大小不超过10M |
||||
* 详情请见: |
||||
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.mediaCheckAsync.html
|
||||
* |
||||
* @param appId 小程序appId |
||||
* @param mediaUrl 要检测的多媒体url |
||||
* @param mediaType 媒体类型 {@link cn.binarywang.wx.miniapp.constant.WxMaConstants.SecCheckMediaType} |
||||
* @return 微信检测结果 WxMaMediaAsyncCheckResult {@link WxMaMediaAsyncCheckResult} |
||||
*/ |
||||
public WxMaMediaAsyncCheckResult mediaAsyncCheck(String appId, String mediaUrl, int mediaType) { |
||||
WxMaMediaAsyncCheckResult wxMaMediaAsyncCheckResult = null; |
||||
try { |
||||
wxMaMediaAsyncCheckResult = this.getWxMaService(appId).getSecCheckService().mediaCheckAsync(mediaUrl, mediaType); |
||||
log.debug("[Quafer] |- Media Async Check Successfully!"); |
||||
} catch (WxErrorException e) { |
||||
log.debug("[Quafer] |- Media Async Check Failed! Detail is :{}", e.getMessage()); |
||||
} |
||||
|
||||
return wxMaMediaAsyncCheckResult; |
||||
} |
||||
} |
@ -0,0 +1,234 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxapp.properties; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import com.liuhung.engine.access.wxapp.enums.MiniProgramState; |
||||
import com.google.common.base.MoreObjects; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p>Description: 微信小程序配置属性 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/3/26 17:27 |
||||
*/ |
||||
@ConfigurationProperties(prefix = AccessConstants.PROPERTY_ACCESS_WXAPP) |
||||
public class WxappProperties implements Serializable { |
||||
|
||||
/** |
||||
* 是否开启 |
||||
*/ |
||||
private Boolean enabled; |
||||
/** |
||||
* 默认App Id |
||||
*/ |
||||
private String defaultAppId; |
||||
|
||||
/** |
||||
* 小程序配置列表 |
||||
*/ |
||||
private List<Config> configs; |
||||
|
||||
/** |
||||
* 小程序订阅消息配置列表 |
||||
*/ |
||||
private List<Subscribe> subscribes; |
||||
|
||||
public String getDefaultAppId() { |
||||
return defaultAppId; |
||||
} |
||||
|
||||
public void setDefaultAppId(String defaultAppId) { |
||||
this.defaultAppId = defaultAppId; |
||||
} |
||||
|
||||
public List<Config> getConfigs() { |
||||
return configs; |
||||
} |
||||
|
||||
public void setConfigs(List<Config> configs) { |
||||
this.configs = configs; |
||||
} |
||||
|
||||
public List<Subscribe> getSubscribes() { |
||||
return subscribes; |
||||
} |
||||
|
||||
public void setSubscribes(List<Subscribe> subscribes) { |
||||
this.subscribes = subscribes; |
||||
} |
||||
|
||||
public Boolean getEnabled() { |
||||
return enabled; |
||||
} |
||||
|
||||
public void setEnabled(Boolean enabled) { |
||||
this.enabled = enabled; |
||||
} |
||||
|
||||
public static class Config { |
||||
/** |
||||
* 设置微信小程序的appid |
||||
*/ |
||||
private String appId; |
||||
|
||||
/** |
||||
* 设置微信小程序的Secret |
||||
*/ |
||||
private String secret; |
||||
|
||||
/** |
||||
* 设置微信小程序消息服务器配置的token |
||||
*/ |
||||
private String token; |
||||
|
||||
/** |
||||
* 设置微信小程序消息服务器配置的EncodingAESKey |
||||
*/ |
||||
private String aesKey; |
||||
|
||||
/** |
||||
* 消息格式,XML或者JSON |
||||
*/ |
||||
private String messageDataFormat; |
||||
|
||||
public String getAppId() { |
||||
return appId; |
||||
} |
||||
|
||||
public void setAppId(String appId) { |
||||
this.appId = appId; |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return secret; |
||||
} |
||||
|
||||
public void setSecret(String secret) { |
||||
this.secret = secret; |
||||
} |
||||
|
||||
public String getToken() { |
||||
return token; |
||||
} |
||||
|
||||
public void setToken(String token) { |
||||
this.token = token; |
||||
} |
||||
|
||||
public String getAesKey() { |
||||
return aesKey; |
||||
} |
||||
|
||||
public void setAesKey(String aesKey) { |
||||
this.aesKey = aesKey; |
||||
} |
||||
|
||||
public String getMessageDataFormat() { |
||||
return messageDataFormat; |
||||
} |
||||
|
||||
public void setMessageDataFormat(String messageDataFormat) { |
||||
this.messageDataFormat = messageDataFormat; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("appid", appId) |
||||
.add("secret", secret) |
||||
.add("token", token) |
||||
.add("aesKey", aesKey) |
||||
.add("messageDataFormat", messageDataFormat) |
||||
.toString(); |
||||
} |
||||
} |
||||
|
||||
public static class Subscribe { |
||||
|
||||
/** |
||||
* 订阅消息指定的小程序跳转页面地址 |
||||
*/ |
||||
private String redirectPage; |
||||
/** |
||||
* 订阅消息模版ID |
||||
*/ |
||||
private String templateId; |
||||
|
||||
/** |
||||
* 自定义Message区分ID,用于获取不同的SubscribeMessageHandler |
||||
*/ |
||||
private String subscribeId; |
||||
|
||||
private MiniProgramState miniProgramState = MiniProgramState.formal; |
||||
|
||||
public String getRedirectPage() { |
||||
return redirectPage; |
||||
} |
||||
|
||||
public void setRedirectPage(String redirectPage) { |
||||
this.redirectPage = redirectPage; |
||||
} |
||||
|
||||
public String getTemplateId() { |
||||
return templateId; |
||||
} |
||||
|
||||
public void setTemplateId(String templateId) { |
||||
this.templateId = templateId; |
||||
} |
||||
|
||||
public MiniProgramState getMiniProgramState() { |
||||
return miniProgramState; |
||||
} |
||||
|
||||
public void setMiniProgramState(MiniProgramState miniProgramState) { |
||||
this.miniProgramState = miniProgramState; |
||||
} |
||||
|
||||
public String getSubscribeId() { |
||||
return subscribeId; |
||||
} |
||||
|
||||
public void setSubscribeId(String subscribeId) { |
||||
this.subscribeId = subscribeId; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("redirectPage", redirectPage) |
||||
.add("templateId", templateId) |
||||
.add("subscribeId", subscribeId) |
||||
.add("miniProgramState", miniProgramState) |
||||
.toString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,60 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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"> |
||||
<parent> |
||||
<artifactId>engine-access</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>access-sdk-wxmpp</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<description>基于 Spring Authorization Server 的微信公众号外部接入组件模块</description> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>cache-sdk-redis</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.github.binarywang</groupId> |
||||
<artifactId>weixin-java-mp</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,45 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxmpp.annotation; |
||||
|
||||
import com.liuhung.engine.access.wxmpp.condition.WxmppEnabledCondition; |
||||
import org.springframework.context.annotation.Conditional; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* <p>Description: 微信公众号开启条件注解 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/24 14:40 |
||||
*/ |
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
@Conditional(WxmppEnabledCondition.class) |
||||
public @interface ConditionalOnWxmppEnabled { |
||||
|
||||
} |
@ -0,0 +1,53 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxmpp.condition; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import com.liuhung.engine.assistant.core.context.PropertyResolver; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Condition; |
||||
import org.springframework.context.annotation.ConditionContext; |
||||
import org.springframework.core.type.AnnotatedTypeMetadata; |
||||
|
||||
/** |
||||
* <p>Description: 微信公众号注入条件 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/27 22:13 |
||||
*/ |
||||
public class WxmppEnabledCondition implements Condition { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxmppEnabledCondition.class); |
||||
|
||||
@SuppressWarnings("NullableProblems") |
||||
@Override |
||||
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) { |
||||
boolean result = PropertyResolver.getBoolean(conditionContext, AccessConstants.ITEM_WXMPP_ENABLED); |
||||
log.debug("[Quafer] |- Condition [Wxmpp Enabled] value is [{}]", result); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,70 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxmpp.configuration; |
||||
|
||||
import com.liuhung.engine.access.wxmpp.annotation.ConditionalOnWxmppEnabled; |
||||
import com.liuhung.engine.access.wxmpp.processor.WxmppLogHandler; |
||||
import com.liuhung.engine.access.wxmpp.processor.WxmppProcessor; |
||||
import com.liuhung.engine.access.wxmpp.properties.WxmppProperties; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.data.redis.core.StringRedisTemplate; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
/** |
||||
* <p>Description: 微信公众号配置 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/7 13:25 |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnWxmppEnabled |
||||
@EnableConfigurationProperties(WxmppProperties.class) |
||||
public class WxmppConfiguration { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxmppConfiguration.class); |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
log.debug("[Quafer] |- SDK [Access Wxmpp] Auto Configure."); |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public WxmppProcessor wxmppProcessor(WxmppProperties wxmppProperties, StringRedisTemplate stringRedisTemplate) { |
||||
WxmppProcessor wxmppProcessor = new WxmppProcessor(); |
||||
wxmppProcessor.setWxmppProperties(wxmppProperties); |
||||
wxmppProcessor.setWxmppLogHandler(new WxmppLogHandler()); |
||||
wxmppProcessor.setStringRedisTemplate(stringRedisTemplate); |
||||
log.trace("[Quafer] |- Bean [Wxmpp Processor] Auto Configure."); |
||||
return wxmppProcessor; |
||||
} |
||||
} |
@ -0,0 +1,62 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxmpp.processor; |
||||
|
||||
import com.liuhung.engine.assistant.core.json.jackson2.utils.JacksonUtils; |
||||
import me.chanjar.weixin.common.error.WxErrorException; |
||||
import me.chanjar.weixin.common.session.WxSessionManager; |
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler; |
||||
import me.chanjar.weixin.mp.api.WxMpService; |
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; |
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 微信公众号日志处理 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/7 13:26 |
||||
*/ |
||||
@Component |
||||
public class WxmppLogHandler implements WxMpMessageHandler { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxmppLogHandler.class); |
||||
|
||||
@Override |
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map, WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException { |
||||
// 代码逻辑未实现,仅仅简单打印信息
|
||||
if(null!=wxMpXmlMessage){ |
||||
String msg =JacksonUtils.toJson(wxMpXmlMessage); |
||||
log.info("\n接收到请求消息,内容:{}",msg ); |
||||
} |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,114 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxmpp.processor; |
||||
|
||||
import com.liuhung.engine.access.wxmpp.properties.WxmppProperties; |
||||
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; |
||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter; |
||||
import me.chanjar.weixin.mp.api.WxMpService; |
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; |
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; |
||||
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
import org.springframework.data.redis.core.StringRedisTemplate; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* <p>Description: 微信公众号核心服务 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/5/27 20:25 |
||||
*/ |
||||
public class WxmppProcessor implements InitializingBean { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WxmppProcessor.class); |
||||
private WxMpService wxMpService; |
||||
private WxmppProperties wxmppProperties; |
||||
private WxmppLogHandler wxmppLogHandler; |
||||
private StringRedisTemplate stringRedisTemplate; |
||||
|
||||
public void setWxmppProperties(WxmppProperties wxmppProperties) { |
||||
this.wxmppProperties = wxmppProperties; |
||||
} |
||||
|
||||
public void setWxmppLogHandler(WxmppLogHandler wxmppLogHandler) { |
||||
this.wxmppLogHandler = wxmppLogHandler; |
||||
} |
||||
|
||||
public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) { |
||||
this.stringRedisTemplate = stringRedisTemplate; |
||||
} |
||||
|
||||
@Override |
||||
public void afterPropertiesSet() { |
||||
// 代码里 getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!!
|
||||
final List<WxmppProperties.MpConfig> configs = this.wxmppProperties.getConfigs(); |
||||
if (configs == null) { |
||||
throw new RuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!"); |
||||
} |
||||
|
||||
WxMpService wxMpService = new WxMpServiceImpl(); |
||||
wxMpService.setMultiConfigStorages(configs |
||||
.stream().map(a -> { |
||||
WxMpDefaultConfigImpl configStorage; |
||||
if (this.wxmppProperties.isUseRedis()) { |
||||
final WxmppProperties.RedisConfig redisConfig = this.wxmppProperties.getRedis(); |
||||
configStorage = new WxMpRedisConfigImpl(new RedisTemplateWxRedisOps(stringRedisTemplate), a.getAppId()); |
||||
} else { |
||||
configStorage = new WxMpDefaultConfigImpl(); |
||||
} |
||||
|
||||
configStorage.setAppId(a.getAppId()); |
||||
configStorage.setSecret(a.getSecret()); |
||||
configStorage.setToken(a.getToken()); |
||||
configStorage.setAesKey(a.getAesKey()); |
||||
return configStorage; |
||||
}).collect(Collectors.toMap(WxMpDefaultConfigImpl::getAppId, a -> a, (o, n) -> o))); |
||||
|
||||
log.info("[Quafer] |- Bean [Quafer Weixin Micro Message Public Platform] Auto Configure."); |
||||
|
||||
this.wxMpService = wxMpService; |
||||
} |
||||
|
||||
public WxMpService getWxMpService() { |
||||
if (ObjectUtils.isEmpty(this.wxMpService)) { |
||||
throw new IllegalArgumentException("Cannot find the configuration for wechat official accounts, please check!"); |
||||
} |
||||
return wxMpService; |
||||
} |
||||
|
||||
public WxMpMessageRouter getWxMpMessageRouter() { |
||||
final WxMpMessageRouter newRouter = new WxMpMessageRouter(this.getWxMpService()); |
||||
// 记录所有事件的日志 (异步执行)
|
||||
newRouter.rule().handler(this.wxmppLogHandler).next(); |
||||
return newRouter; |
||||
} |
||||
} |
@ -0,0 +1,202 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.wxmpp.properties; |
||||
|
||||
import com.liuhung.engine.access.core.constants.AccessConstants; |
||||
import com.google.common.base.MoreObjects; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p>Description: 微信公众号属性配置 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/7 13:17 |
||||
*/ |
||||
@ConfigurationProperties(prefix = AccessConstants.PROPERTY_ACCESS_WXMPP) |
||||
public class WxmppProperties { |
||||
|
||||
/** |
||||
* 是否开启 |
||||
*/ |
||||
private Boolean enabled; |
||||
/** |
||||
* 是否使用redis存储access token |
||||
*/ |
||||
private boolean useRedis; |
||||
|
||||
/** |
||||
* redis 配置 |
||||
*/ |
||||
private RedisConfig redis; |
||||
|
||||
public boolean isUseRedis() { |
||||
return useRedis; |
||||
} |
||||
|
||||
public void setUseRedis(boolean useRedis) { |
||||
this.useRedis = useRedis; |
||||
} |
||||
|
||||
public RedisConfig getRedis() { |
||||
return redis; |
||||
} |
||||
|
||||
public void setRedis(RedisConfig redis) { |
||||
this.redis = redis; |
||||
} |
||||
|
||||
public Boolean getEnabled() { |
||||
return enabled; |
||||
} |
||||
|
||||
public void setEnabled(Boolean enabled) { |
||||
this.enabled = enabled; |
||||
} |
||||
|
||||
public static class RedisConfig { |
||||
/** |
||||
* redis服务器 主机地址 |
||||
*/ |
||||
private String host; |
||||
|
||||
/** |
||||
* redis服务器 端口号 |
||||
*/ |
||||
private Integer port; |
||||
|
||||
public String getHost() { |
||||
return host; |
||||
} |
||||
|
||||
public void setHost(String host) { |
||||
this.host = host; |
||||
} |
||||
|
||||
public Integer getPort() { |
||||
return port; |
||||
} |
||||
|
||||
public void setPort(Integer port) { |
||||
this.port = port; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("host", host) |
||||
.add("port", port) |
||||
.toString(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 多个公众号配置信息 |
||||
*/ |
||||
private List<MpConfig> configs; |
||||
|
||||
public List<MpConfig> getConfigs() { |
||||
return configs; |
||||
} |
||||
|
||||
public void setConfigs(List<MpConfig> configs) { |
||||
this.configs = configs; |
||||
} |
||||
|
||||
public static class MpConfig { |
||||
/** |
||||
* 设置微信公众号的appid |
||||
*/ |
||||
private String appId; |
||||
|
||||
/** |
||||
* 设置微信公众号的app secret |
||||
*/ |
||||
private String secret; |
||||
|
||||
/** |
||||
* 设置微信公众号的token |
||||
*/ |
||||
private String token; |
||||
|
||||
/** |
||||
* 设置微信公众号的EncodingAESKey |
||||
*/ |
||||
private String aesKey; |
||||
|
||||
public String getAppId() { |
||||
return appId; |
||||
} |
||||
|
||||
public void setAppId(String appId) { |
||||
this.appId = appId; |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return secret; |
||||
} |
||||
|
||||
public void setSecret(String secret) { |
||||
this.secret = secret; |
||||
} |
||||
|
||||
public String getToken() { |
||||
return token; |
||||
} |
||||
|
||||
public void setToken(String token) { |
||||
this.token = token; |
||||
} |
||||
|
||||
public String getAesKey() { |
||||
return aesKey; |
||||
} |
||||
|
||||
public void setAesKey(String aesKey) { |
||||
this.aesKey = aesKey; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("appId", appId) |
||||
.add("secret", secret) |
||||
.add("token", token) |
||||
.add("aesKey", aesKey) |
||||
.toString(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("useRedis", useRedis) |
||||
.add("redis", redis) |
||||
.add("configs", configs) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,49 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>engine-access</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<artifactId>access-spring-boot-starter</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<artifactId>access-sdk-all</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,54 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.access.autoconfigure; |
||||
|
||||
import com.liuhung.engine.access.business.configuration.AccessAllConfiguration; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.context.annotation.Import; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
/** |
||||
* <p>Description: 外部程序接入模块自动配置 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/26 16:23 |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@Import({ |
||||
AccessAllConfiguration.class |
||||
}) |
||||
public class AutoConfiguration { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AutoConfiguration.class); |
||||
|
||||
@PostConstruct |
||||
public void postConstruct() { |
||||
log.info("[Quafer] |- Starter [Access Starter] Auto Configure."); |
||||
} |
||||
} |
@ -0,0 +1 @@ |
||||
com.liuhung.engine.access.autoconfigure.AutoConfiguration |
@ -0,0 +1,53 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>quafer-engine</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<description>手机短信、小程序、公众号、JustAuth等外部登录处理逻辑集成模块</description> |
||||
|
||||
<artifactId>engine-access</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>pom</packaging> |
||||
|
||||
<modules> |
||||
<module>access-core</module> |
||||
<module>access-sdk-justauth</module> |
||||
<module>access-sdk-wxapp</module> |
||||
<module>access-sdk-wxmpp</module> |
||||
<module>access-sdk-all</module> |
||||
<module>access-spring-boot-starter</module> |
||||
</modules> |
||||
|
||||
</project> |
@ -0,0 +1 @@ |
||||
## 全局通用代码模块 |
@ -0,0 +1 @@ |
||||
> 基础通用共性代码模块包 |
@ -0,0 +1,171 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
~ |
||||
~ quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
~ you may not use this file except in compliance with the License. |
||||
~ You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
~ |
||||
~ quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
~ |
||||
~ 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
~ 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
~ 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
~ 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine |
||||
~ 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
--> |
||||
|
||||
<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> |
||||
<artifactId>engine-assistant</artifactId> |
||||
<groupId>com.liuhung.engine</groupId> |
||||
<version>2.7.8.0</version> |
||||
</parent> |
||||
|
||||
<artifactId>assistant-core</artifactId> |
||||
<version>2.7.8.0</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<description>基于 Spring Authorization Server 的 quafer Cloud 核心通用代码组件</description> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-configuration-processor</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-validation</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springdoc</groupId> |
||||
<artifactId>springdoc-openapi-common</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-collections4</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-text</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-pool2</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>commons-io</groupId> |
||||
<artifactId>commons-io</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>commons-codec</groupId> |
||||
<artifactId>commons-codec</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.dataformat</groupId> |
||||
<artifactId>jackson-dataformat-yaml</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.datatype</groupId> |
||||
<artifactId>jackson-datatype-jsr310</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.datatype</groupId> |
||||
<artifactId>jackson-datatype-jdk8</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.module</groupId> |
||||
<artifactId>jackson-module-kotlin</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.httpcomponents</groupId> |
||||
<artifactId>httpclient</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.httpcomponents</groupId> |
||||
<artifactId>httpcore</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>cn.hutool</groupId> |
||||
<artifactId>hutool-all</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.google.guava</groupId> |
||||
<artifactId>guava</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.google.code.gson</groupId> |
||||
<artifactId>gson</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.skywalking</groupId> |
||||
<artifactId>apm-toolkit-logback-1.x</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.skywalking</groupId> |
||||
<artifactId>apm-toolkit-trace</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>cn.zhxu</groupId> |
||||
<artifactId>okhttps-jackson</artifactId> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>com.squareup.okio</groupId> |
||||
<artifactId>okio</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.squareup.okio</groupId> |
||||
<artifactId>okio</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.zhxu</groupId> |
||||
<artifactId>okhttps-gson</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>me.zhyd.oauth</groupId> |
||||
<artifactId>JustAuth</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.owasp.antisamy</groupId> |
||||
<artifactId>antisamy</artifactId> |
||||
<exclusions> |
||||
<exclusion> |
||||
<artifactId>slf4j-simple</artifactId> |
||||
<groupId>org.slf4j</groupId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>transmittable-thread-local</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,44 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.annotation; |
||||
|
||||
import com.liuhung.engine.assistant.core.conditon.SwaggerEnabledCondition; |
||||
import org.springframework.context.annotation.Conditional; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* <p>Description: Swagger条件开启主机 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/8/20 11:58 |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Documented |
||||
@Conditional(SwaggerEnabledCondition.class) |
||||
public @interface ConditionalOnSwaggerEnabled { |
||||
} |
@ -0,0 +1,68 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.annotation; |
||||
|
||||
import com.liuhung.engine.assistant.core.validation.EnumeratedValueValidator; |
||||
|
||||
import javax.validation.Constraint; |
||||
import javax.validation.Payload; |
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
/** |
||||
* <p>Description: 枚举值校验注解 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/6/13 15:58 |
||||
*/ |
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Repeatable(EnumeratedValue.List.class) |
||||
@Documented |
||||
@Constraint(validatedBy = {EnumeratedValueValidator.class}) |
||||
public @interface EnumeratedValue { |
||||
|
||||
// 默认错误消息
|
||||
String message() default "必须为指定值"; |
||||
|
||||
String[] names() default {}; |
||||
|
||||
int[] ordinals() default {}; |
||||
|
||||
// 分组
|
||||
Class<?>[] groups() default {}; |
||||
|
||||
// 负载
|
||||
Class<? extends Payload>[] payload() default {}; |
||||
|
||||
// 指定多个时使用
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
@interface List { |
||||
EnumeratedValue[] value(); |
||||
} |
||||
} |
@ -0,0 +1,41 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.annotation; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* <p>Description: Feign 内部调用标记注解 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/5/31 12:10 |
||||
*/ |
||||
@Target({ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface Inner { |
||||
|
||||
} |
@ -0,0 +1,66 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.datatables; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p>Description: JQuery Datatables 组件只用的参数对象封装 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2019/11/24 15:48 |
||||
*/ |
||||
public class DataTableParameter implements Serializable { |
||||
|
||||
private String name; |
||||
private Object value; |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(Object value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("name", name) |
||||
.add("value", value) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,125 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.datatables; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p>Description: 返回给JQuery Datatables 组件使用的结果 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2019/11/24 15:48 |
||||
*/ |
||||
public class DataTableResult implements Serializable { |
||||
|
||||
private int pageNumber; |
||||
private int pageSize; |
||||
private String sEcho; |
||||
private int iDisplayStart; |
||||
private int iDisplayLength; |
||||
private String jsonString; |
||||
private long total; |
||||
|
||||
public DataTableResult(String sEcho, int iDisplayStart, int iDisplayLength, String jsonString) { |
||||
this.sEcho = sEcho; |
||||
this.iDisplayStart = iDisplayStart; |
||||
this.iDisplayLength = iDisplayLength; |
||||
this.pageNumber = this.iDisplayStart / this.iDisplayLength; |
||||
this.pageSize = this.iDisplayLength; |
||||
this.jsonString = jsonString; |
||||
} |
||||
|
||||
public int getPageNumber() { |
||||
return pageNumber; |
||||
} |
||||
|
||||
public void setPageNumber(int pageNumber) { |
||||
this.pageNumber = pageNumber; |
||||
} |
||||
|
||||
public int getPageSize() { |
||||
return pageSize; |
||||
} |
||||
|
||||
public void setPageSize(int pageSize) { |
||||
this.pageSize = pageSize; |
||||
} |
||||
|
||||
public String getsEcho() { |
||||
return sEcho; |
||||
} |
||||
|
||||
public void setsEcho(String sEcho) { |
||||
this.sEcho = sEcho; |
||||
} |
||||
|
||||
public int getiDisplayStart() { |
||||
return iDisplayStart; |
||||
} |
||||
|
||||
public void setiDisplayStart(int iDisplayStart) { |
||||
this.iDisplayStart = iDisplayStart; |
||||
} |
||||
|
||||
public int getiDisplayLength() { |
||||
return iDisplayLength; |
||||
} |
||||
|
||||
public void setiDisplayLength(int iDisplayLength) { |
||||
this.iDisplayLength = iDisplayLength; |
||||
} |
||||
|
||||
public String getJsonString() { |
||||
return jsonString; |
||||
} |
||||
|
||||
public void setJsonString(String jsonString) { |
||||
this.jsonString = jsonString; |
||||
} |
||||
|
||||
public long getTotal() { |
||||
return total; |
||||
} |
||||
|
||||
public void setTotal(long total) { |
||||
this.total = total; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("pageNumber", pageNumber) |
||||
.add("pageSize", pageSize) |
||||
.add("sEcho", sEcho) |
||||
.add("iDisplayStart", iDisplayStart) |
||||
.add("iDisplayLength", iDisplayLength) |
||||
.add("jsonString", jsonString) |
||||
.add("total", total) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.datatables; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p>Description: JQuery Datatable组件使用的工具类 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2019/11/24 15:49 |
||||
*/ |
||||
public class DataTableUtils { |
||||
|
||||
public static final String ECHO = "sEcho"; |
||||
public static final String DISPLAY_START = "iDisplayStart"; |
||||
public static final String DISPLAY_LENGTH = "iDisplayLength"; |
||||
public static final String QUERY_JSON = "queryJson"; |
||||
public static final String DATA = "data"; |
||||
|
||||
public static DataTableResult parseDataTableParameter(List<DataTableParameter> params) { |
||||
|
||||
String sEcho = null; |
||||
String jsonString = null; |
||||
int iDisplayStart = 0; |
||||
int iDisplayLength = 0; |
||||
for (DataTableParameter param : params) { |
||||
if (param.getName().equals(ECHO)) { |
||||
sEcho = param.getValue().toString(); |
||||
} |
||||
if (param.getName().equals(DISPLAY_START)) { |
||||
iDisplayStart = (int) param.getValue(); |
||||
} |
||||
if (param.getName().equals(DISPLAY_LENGTH)) { |
||||
iDisplayLength = (int) param.getValue(); |
||||
} |
||||
if (param.getName().equals(QUERY_JSON)) { |
||||
jsonString = param.getValue().toString(); |
||||
} |
||||
} |
||||
|
||||
return new DataTableResult(sEcho, iDisplayStart, iDisplayLength, jsonString); |
||||
} |
||||
} |
@ -0,0 +1,77 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.router; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.domain.Entity; |
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
||||
/** |
||||
* <p>Description: Vue Router Meta 属性定义 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/14 16:51 |
||||
*/ |
||||
public class BaseMeta implements Entity { |
||||
|
||||
private String title; |
||||
private String icon; |
||||
@JsonProperty("isNotKeepAlive") |
||||
private Boolean notKeepAlive = false; |
||||
@JsonProperty("isIgnoreAuth") |
||||
private Boolean ignoreAuth = false; |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public String getIcon() { |
||||
return icon; |
||||
} |
||||
|
||||
public void setIcon(String icon) { |
||||
this.icon = icon; |
||||
} |
||||
|
||||
public Boolean getNotKeepAlive() { |
||||
return notKeepAlive; |
||||
} |
||||
|
||||
public void setNotKeepAlive(Boolean notKeepAlive) { |
||||
this.notKeepAlive = notKeepAlive; |
||||
} |
||||
|
||||
public Boolean getIgnoreAuth() { |
||||
return ignoreAuth; |
||||
} |
||||
|
||||
public void setIgnoreAuth(Boolean ignoreAuth) { |
||||
this.ignoreAuth = ignoreAuth; |
||||
} |
||||
} |
@ -0,0 +1,48 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.router; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
||||
/** |
||||
* <p>Description: 子节点 Meta </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/14 16:54 |
||||
*/ |
||||
public class ChildMeta extends BaseMeta{ |
||||
|
||||
@JsonProperty("isDetailContent") |
||||
private Boolean detailContent; |
||||
|
||||
public Boolean getDetailContent() { |
||||
return detailContent; |
||||
} |
||||
|
||||
public void setDetailContent(Boolean detailContent) { |
||||
this.detailContent = detailContent; |
||||
} |
||||
} |
@ -0,0 +1,48 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.router; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
||||
/** |
||||
* <p>Description: 子级节点Meta定义 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/14 16:53 |
||||
*/ |
||||
public class ParentMeta extends BaseMeta{ |
||||
|
||||
@JsonProperty("isHideAllChild") |
||||
private Boolean hideAllChild = false; |
||||
|
||||
public Boolean getHideAllChild() { |
||||
return hideAllChild; |
||||
} |
||||
|
||||
public void setHideAllChild(Boolean hideAllChild) { |
||||
this.hideAllChild = hideAllChild; |
||||
} |
||||
} |
@ -0,0 +1,45 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.component.router; |
||||
|
||||
/** |
||||
* <p>Description: RootMeta </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/14 17:01 |
||||
*/ |
||||
public class RootMeta extends BaseMeta{ |
||||
|
||||
private Integer sort; |
||||
|
||||
public Integer getSort() { |
||||
return sort; |
||||
} |
||||
|
||||
public void setSort(Integer sort) { |
||||
this.sort = sort; |
||||
} |
||||
} |
@ -0,0 +1,53 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.conditon; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.constants.BaseConstants; |
||||
import com.liuhung.engine.assistant.core.context.PropertyResolver; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Condition; |
||||
import org.springframework.context.annotation.ConditionContext; |
||||
import org.springframework.core.type.AnnotatedTypeMetadata; |
||||
|
||||
/** |
||||
* <p>Description: Swagger 开启条件 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/17 14:34 |
||||
*/ |
||||
public class SwaggerEnabledCondition implements Condition { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SwaggerEnabledCondition.class); |
||||
|
||||
@SuppressWarnings("NullableProblems") |
||||
@Override |
||||
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) { |
||||
boolean result = PropertyResolver.getBoolean(conditionContext, BaseConstants.ITEM_SWAGGER_ENABLED); |
||||
log.debug("[Quafer] |- Condition [Swagger Enabled] value is [{}]", result); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.context; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.constants.BaseConstants; |
||||
import org.springframework.core.env.Environment; |
||||
|
||||
/** |
||||
* <p>Description: 通用属性读取器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/2/1 18:10 |
||||
*/ |
||||
public class PropertyFinder { |
||||
|
||||
public static String getApplicationName(Environment environment) { |
||||
return PropertyResolver.getProperty(environment, BaseConstants.ITEM_SPRING_APPLICATION_NAME); |
||||
} |
||||
|
||||
public static String getServerPort(Environment environment) { |
||||
return PropertyResolver.getProperty(environment, BaseConstants.ITEM_SERVER_PORT); |
||||
} |
||||
|
||||
public static String getSessionStoreType(Environment environment) { |
||||
return PropertyResolver.getProperty(environment, BaseConstants.ITEM_SPRING_SESSION_STORE_TYPE); |
||||
} |
||||
} |
@ -0,0 +1,154 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.context; |
||||
|
||||
import org.springframework.context.annotation.ConditionContext; |
||||
import org.springframework.core.env.Environment; |
||||
|
||||
/** |
||||
* <p>Description: 配置信息读取工具类 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/8/7 13:39 |
||||
*/ |
||||
public class PropertyResolver { |
||||
|
||||
/** |
||||
* 从环境信息中获取配置信息 |
||||
* |
||||
* @param environment Spring Boot Environment {@link Environment} |
||||
* @param property 配置名称 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static String getProperty(Environment environment, String property) { |
||||
return environment.getProperty(property); |
||||
} |
||||
|
||||
/** |
||||
* 从环境信息中获取配置信息 |
||||
* |
||||
* @param environment Spring Boot Environment {@link Environment} |
||||
* @param property 配置名称 |
||||
* @param defaultValue 默认值 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static String getProperty(Environment environment, String property, String defaultValue) { |
||||
return environment.getProperty(property, defaultValue); |
||||
} |
||||
|
||||
/** |
||||
* 从条件上下文中获取配置信息 |
||||
* |
||||
* @param conditionContext Spring Boot ConditionContext {@link ConditionContext} |
||||
* @param property 配置名称 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static String getProperty(ConditionContext conditionContext, String property) { |
||||
return getProperty(conditionContext.getEnvironment(), property); |
||||
} |
||||
|
||||
/** |
||||
* 从条件上下文中获取配置信息 |
||||
* |
||||
* @param conditionContext Spring Boot ConditionContext {@link ConditionContext} |
||||
* @param property 配置名称 |
||||
* @param defaultValue 默认值 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static String getProperty(ConditionContext conditionContext, String property, String defaultValue) { |
||||
return getProperty(conditionContext.getEnvironment(), property, defaultValue); |
||||
} |
||||
|
||||
public static <T> T getProperty(Environment environment, String property, Class<T> targetType) { |
||||
return environment.getProperty(property, targetType); |
||||
} |
||||
|
||||
public static <T> T getProperty(Environment environment, String property, Class<T> targetType, T defaultValue) { |
||||
return environment.getProperty(property, targetType, defaultValue); |
||||
} |
||||
|
||||
public static <T> T getProperty(ConditionContext conditionContext, String property, Class<T> targetType) { |
||||
return getProperty(conditionContext.getEnvironment(), property, targetType); |
||||
} |
||||
|
||||
public static <T> T getProperty(ConditionContext conditionContext, String property, Class<T> targetType, T defaultValue) { |
||||
return getProperty(conditionContext.getEnvironment(), property, targetType, defaultValue); |
||||
} |
||||
|
||||
public static boolean contains(Environment environment, String property) { |
||||
return environment.containsProperty(property); |
||||
} |
||||
|
||||
public static boolean contains(ConditionContext conditionContext, String property) { |
||||
return contains(conditionContext.getEnvironment(), property); |
||||
} |
||||
|
||||
/** |
||||
* 从条件上下文中获取Boolean类型值配置信息 |
||||
* |
||||
* @param environment Spring Boot ConditionContext {@link ConditionContext} |
||||
* @param property 配置名称 |
||||
* @param defaultValue 默认值 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static boolean getBoolean(Environment environment, String property, boolean defaultValue) { |
||||
return getProperty(environment, property, Boolean.class, defaultValue); |
||||
} |
||||
|
||||
/** |
||||
* 从条件上下文中获取Boolean类型值配置信息 |
||||
* |
||||
* @param environment Spring Boot ConditionContext {@link ConditionContext} |
||||
* @param property 配置名称 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static boolean getBoolean(Environment environment, String property) { |
||||
return getProperty(environment, property, Boolean.class, false); |
||||
} |
||||
|
||||
/** |
||||
* 从条件上下文中获取Boolean类型值配置信息 |
||||
* |
||||
* @param conditionContext Spring Boot ConditionContext {@link ConditionContext} |
||||
* @param property 配置名称 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static boolean getBoolean(ConditionContext conditionContext, String property) { |
||||
return getProperty(conditionContext, property, Boolean.class, false); |
||||
} |
||||
|
||||
/** |
||||
* 从条件上下文中获取Boolean类型值配置信息 |
||||
* |
||||
* @param conditionContext Spring Boot ConditionContext {@link ConditionContext} |
||||
* @param property 配置名称 |
||||
* @param defaultValue 默认值 |
||||
* @return 配置属性值 |
||||
*/ |
||||
public static boolean getBoolean(ConditionContext conditionContext, String property, boolean defaultValue) { |
||||
return getProperty(conditionContext, property, Boolean.class, defaultValue); |
||||
} |
||||
} |
@ -0,0 +1,51 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.context; |
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal; |
||||
|
||||
/** |
||||
* <p>Description: 存储/获取当前线程的租户信息 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/9/4 22:34 |
||||
*/ |
||||
public class TenantContextHolder { |
||||
|
||||
private static final ThreadLocal<String> CURRENT_CONTEXT = new TransmittableThreadLocal<>(); |
||||
|
||||
public static String getTenantId() { |
||||
return CURRENT_CONTEXT.get(); |
||||
} |
||||
|
||||
public static void setTenantId(final String tenantId) { |
||||
CURRENT_CONTEXT.set(tenantId); |
||||
} |
||||
|
||||
public static void clear() { |
||||
CURRENT_CONTEXT.remove(); |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition; |
||||
|
||||
import cn.zhxu.okhttps.HTTP; |
||||
import cn.zhxu.okhttps.MsgConvertor; |
||||
import cn.zhxu.okhttps.jackson.JacksonMsgConvertor; |
||||
|
||||
/** |
||||
* <p>File: AbstractRestApiService </p> |
||||
* |
||||
* <p>Description: 外部Rest API抽象服务 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/4/10 15:33 |
||||
*/ |
||||
public abstract class AbstractRest { |
||||
|
||||
/** |
||||
* 获取外部Rest API基础地址 |
||||
* @return 访问接口的统一BaseURL |
||||
*/ |
||||
protected abstract String getBaseUrl(); |
||||
|
||||
protected HTTP http() { |
||||
return HTTP.builder() |
||||
.baseUrl(getBaseUrl()) |
||||
.addMsgConvertor(getMsgConvertor()) |
||||
.build(); |
||||
} |
||||
|
||||
protected MsgConvertor getMsgConvertor() { |
||||
return new JacksonMsgConvertor(); |
||||
} |
||||
} |
@ -0,0 +1,39 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition; |
||||
|
||||
import com.liuhung.engine.assistant.core.domain.PrincipalDetails; |
||||
|
||||
/** |
||||
* <p>Description: 身份信息解析器 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/12/28 0:08 |
||||
*/ |
||||
public interface BearerTokenResolver { |
||||
|
||||
PrincipalDetails resolve(String token); |
||||
} |
@ -0,0 +1,79 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition; |
||||
|
||||
import com.liuhung.engine.assistant.core.json.jackson2.utils.JacksonUtils; |
||||
|
||||
/** |
||||
* <p>Description: 策略 Event 定义 </p> |
||||
* <p> |
||||
* 为了同时支持 分布式模式 和 单体式模式。所以很多事件均需要同时支持本地发送和远程发送两种模式。 |
||||
* 抽象本定义用于统一处理两种模式的事件支持。 |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/2/5 15:32 |
||||
*/ |
||||
public interface StrategyEvent<T> { |
||||
|
||||
/** |
||||
* 创建本地事件 |
||||
* |
||||
* @param data 事件携带数据 |
||||
*/ |
||||
void postLocalProcess(T data); |
||||
|
||||
/** |
||||
* 创建远程事件 |
||||
* |
||||
* @param data 事件携带数据。JSON 格式的数据。 |
||||
* @param originService 发送远程事件原始服务 |
||||
* @param destinationService 接收远程事件目的地 |
||||
*/ |
||||
void postRemoteProcess(String data, String originService, String destinationService); |
||||
|
||||
/** |
||||
* 是否是本地处理事件。 |
||||
* |
||||
* @param destinationService 接收远程事件目的地 |
||||
* @return false 远程事件,local 本地事件 |
||||
*/ |
||||
boolean isLocal(String destinationService); |
||||
|
||||
/** |
||||
* 发送事件 |
||||
* |
||||
* @param data 事件携带数据 |
||||
* @param originService 发送远程事件原始服务 |
||||
* @param destinationService 接收远程事件目的地 |
||||
*/ |
||||
default void postProcess(String originService, String destinationService, T data) { |
||||
if (isLocal(destinationService)) { |
||||
postLocalProcess(data); |
||||
} else { |
||||
postRemoteProcess(JacksonUtils.toJson(data), originService, destinationService); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,131 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.constants; |
||||
|
||||
/** |
||||
* <p>Description: 基础共用常量值常量 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/13 21:18 |
||||
*/ |
||||
public interface BaseConstants { |
||||
|
||||
String NONE = "none"; |
||||
String CODE = "code"; |
||||
String LOWERCASE_DEFAULT = "default"; |
||||
|
||||
String DEFAULT_TENANT_ID = "master"; |
||||
String DEFAULT_TREE_ROOT_ID = "0"; |
||||
|
||||
/* ---------- 配置属性通用常量 ---------- */ |
||||
|
||||
String PROPERTY_ENABLED = ".enabled"; |
||||
|
||||
String PROPERTY_PREFIX_SPRING = "spring"; |
||||
String PROPERTY_PREFIX_FEIGN = "feign"; |
||||
String PROPERTY_PREFIX_SERVER = "server"; |
||||
String PROPERTY_PREFIX_HERODOTUS = "quafer"; |
||||
|
||||
String PROPERTY_SPRING_CLOUD = PROPERTY_PREFIX_SPRING + ".cloud"; |
||||
String PROPERTY_SPRING_JPA = PROPERTY_PREFIX_SPRING + ".jpa"; |
||||
String PROPERTY_SPRING_REDIS = PROPERTY_PREFIX_SPRING + ".redis"; |
||||
|
||||
String ANNOTATION_PREFIX = "${"; |
||||
String ANNOTATION_SUFFIX = "}"; |
||||
|
||||
/* ---------- Quafer 自定义配置属性 ---------- */ |
||||
|
||||
String PROPERTY_PREFIX_PLATFORM = PROPERTY_PREFIX_HERODOTUS + ".platform"; |
||||
String PROPERTY_PREFIX_SECURITY = PROPERTY_PREFIX_HERODOTUS + ".security"; |
||||
String PROPERTY_PREFIX_REST = PROPERTY_PREFIX_HERODOTUS + ".rest"; |
||||
String PROPERTY_PREFIX_SWAGGER = PROPERTY_PREFIX_HERODOTUS + ".swagger"; |
||||
|
||||
String PROPERTY_PREFIX_EVENT = PROPERTY_PREFIX_HERODOTUS + ".event"; |
||||
|
||||
String ITEM_SWAGGER_ENABLED = PROPERTY_PREFIX_SWAGGER + PROPERTY_ENABLED; |
||||
|
||||
|
||||
/* ---------- Spring 家族配置属性 ---------- */ |
||||
|
||||
String ITEM_SPRING_APPLICATION_NAME = PROPERTY_PREFIX_SPRING + ".application.name"; |
||||
String ITEM_SPRING_SESSION_STORE_TYPE = PROPERTY_PREFIX_SPRING + ".session.store-type"; |
||||
String ITEM_SERVER_PORT = PROPERTY_PREFIX_SERVER + ".port"; |
||||
|
||||
String ANNOTATION_APPLICATION_NAME = ANNOTATION_PREFIX + ITEM_SPRING_APPLICATION_NAME + ANNOTATION_SUFFIX; |
||||
|
||||
|
||||
/* ---------- 通用缓存常量 ---------- */ |
||||
|
||||
String CACHE_PREFIX = "cache:"; |
||||
|
||||
String CACHE_SIMPLE_BASE_PREFIX = CACHE_PREFIX + "simple:"; |
||||
String CACHE_TOKEN_BASE_PREFIX = CACHE_PREFIX + "token:"; |
||||
|
||||
String AREA_PREFIX = "data:upms:"; |
||||
|
||||
|
||||
/* ---------- Oauth2 和 Security 通用缓存常量 ---------- */ |
||||
|
||||
/** |
||||
* Oauth2 模式类型 |
||||
*/ |
||||
String AUTHORIZATION_CODE = "authorization_code"; |
||||
String IMPLICIT = "implicit"; |
||||
String PASSWORD = "password"; |
||||
String CLIENT_CREDENTIALS = "client_credentials"; |
||||
String REFRESH_TOKEN = "refresh_token"; |
||||
String SOCIAL_CREDENTIALS = "social_credentials"; |
||||
|
||||
String DEFAULT_AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; |
||||
String DEFAULT_TOKEN_ENDPOINT = "/oauth2/token"; |
||||
String DEFAULT_JWK_SET_ENDPOINT = "/oauth2/jwks"; |
||||
String DEFAULT_TOKEN_REVOCATION_ENDPOINT = "/oauth2/revoke"; |
||||
String DEFAULT_TOKEN_INTROSPECTION_ENDPOINT = "/oauth2/introspect"; |
||||
String DEFAULT_OIDC_CLIENT_REGISTRATION_ENDPOINT = "/connect/register"; |
||||
String DEFAULT_OIDC_USER_INFO_ENDPOINT = "/userinfo"; |
||||
|
||||
String OPEN_API_SECURITY_SCHEME_BEARER_NAME = "HERODOTUS_AUTH"; |
||||
|
||||
String BEARER_TYPE = "Bearer"; |
||||
String BEARER_TOKEN = BEARER_TYPE + SymbolConstants.SPACE; |
||||
String BASIC_TYPE = "Basic"; |
||||
String BASIC_TOKEN = BASIC_TYPE + SymbolConstants.SPACE; |
||||
String ROLE_PREFIX = "ROLE_"; |
||||
String AUTHORITY_PREFIX = "OP_"; |
||||
|
||||
String AUTHORITIES = "authorities"; |
||||
String AVATAR = "avatar"; |
||||
String EMPLOYEE_ID = "employeeId"; |
||||
String LICENSE = "license"; |
||||
String OPEN_ID = "openid"; |
||||
String PRINCIPAL = "principal"; |
||||
String ROLES = "roles"; |
||||
String SOURCE = "source"; |
||||
String USERNAME = "username"; |
||||
|
||||
String SPRING_SESSION_ID_ATTR_NAME = "SPRING.SESSION.ID"; |
||||
|
||||
} |
@ -0,0 +1,194 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.constants; |
||||
|
||||
import org.apache.http.HttpStatus; |
||||
|
||||
/** |
||||
* <p>Description: 错误代码计数器 </p> |
||||
* <p> |
||||
* 都需要手动控制错误代码,通过代码的继承关系,方便的查看以及编写。 |
||||
* <p> |
||||
* 1** 信息,服务器收到请求,需要请求者继续执行操作 |
||||
* 2** 成功,操作被成功接收并处理 |
||||
* 3** 重定向,需要进一步的操作以完成请求 |
||||
* 4** 客户端错误,请求包含语法错误或无法完成请求 |
||||
* 5** 服务器错误,服务器在处理请求的过程中发生了错误 |
||||
* <p> |
||||
* 1开头的状态码 |
||||
* 100 Continue 继续。客户端应继续其请求 |
||||
* 101 Switching Protocols 切换协议。服务器根据客户端的请求切换协议。只能切换到更高级的协议,例如,切换到HTTP的新版本协议 |
||||
* <p> |
||||
* 2开头的状态码 |
||||
* 200 OK 请求成功。一般用于GET与POST请求 |
||||
* 201 Created 已创建。成功请求并创建了新的资源 |
||||
* 202 Accepted 已接受。已经接受请求,但未处理完成 |
||||
* 203 Non-Authoritative Information 非授权信息。请求成功。但返回的meta信息不在原始的服务器,而是一个副本 |
||||
* 204 No Content 无内容。服务器成功处理,但未返回内容。在未更新网页的情况下,可确保浏览器继续显示当前文档 |
||||
* 205 Reset Content 重置内容。服务器处理成功,用户终端(例如:浏览器)应重置文档视图。可通过此返回码清除浏览器的表单域 |
||||
* 206 Partial Content 部分内容。服务器成功处理了部分GET请求 |
||||
* <p> |
||||
* 3开头的状态码 |
||||
* 300 Multiple Choices 多种选择。请求的资源可包括多个位置,相应可返回一个资源特征与地址的列表用于用户终端(例如:浏览器)选择 |
||||
* 301 Moved Permanently 永久移动。请求的资源已被永久的移动到新URI,返回信息会包括新的URI,浏览器会自动定向到新URI。今后任何新的请求都应使用新的URI代替 |
||||
* 302 Found 临时移动。与301类似。但资源只是临时被移动。客户端应继续使用原有URI |
||||
* 303 See Other 查看其它地址。与301类似。使用GET和POST请求查看 |
||||
* 304 Not Modified 未修改。所请求的资源未修改,服务器返回此状态码时,不会返回任何资源。客户端通常会缓存访问过的资源,通过提供一个头信息指出客户端希望只返回在指定日期之后修改的资源 |
||||
* 305 Use Proxy 使用代理。所请求的资源必须通过代理访问 |
||||
* 306 Unused 已经被废弃的HTTP状态码 |
||||
* 307 Temporary Redirect 临时重定向。与302类似。使用GET请求重定向 |
||||
* <p> |
||||
* 4开头的状态码 |
||||
* 400 Bad Request 客户端请求的语法错误,服务器无法理解 |
||||
* 401 Unauthorized 请求要求用户的身份认证 |
||||
* 402 Payment Required 保留,将来使用 |
||||
* 403 Forbidden 服务器理解请求客户端的请求,但是拒绝执行此请求 |
||||
* 404 Not Found 服务器无法根据客户端的请求找到资源(网页)。通过此代码,网站设计人员可设置"您所请求的资源无法找到"的个性页面 |
||||
* 405 Method Not Allowed 客户端请求中的方法被禁止 |
||||
* 406 Not Acceptable 服务器无法根据客户端请求的内容特性完成请求 |
||||
* 407 Proxy Authentication Required 请求要求代理的身份认证,与401类似,但请求者应当使用代理进行授权 |
||||
* 408 Request Time-out 服务器等待客户端发送的请求时间过长,超时 |
||||
* 409 Conflict 服务器完成客户端的PUT请求是可能返回此代码,服务器处理请求时发生了冲突 |
||||
* 410 Gone 客户端请求的资源已经不存在。410不同于404,如果资源以前有现在被永久删除了可使用410代码,网站设计人员可通过301代码指定资源的新位置 |
||||
* 411 Length Required 服务器无法处理客户端发送的不带Content-Length的请求信息 |
||||
* 412 Precondition Failed 客户端请求信息的先决条件错误 |
||||
* 413 Request Entity Too Large 由于请求的实体过大,服务器无法处理,因此拒绝请求。为防止客户端的连续请求,服务器可能会关闭连接。如果只是服务器暂时无法处理,则会包含一个Retry-After的响应信息 |
||||
* 414 Request-URI Too Large 请求的URI过长(URI通常为网址),服务器无法处理 |
||||
* 415 Unsupported Media Type 服务器无法处理请求附带的媒体格式 |
||||
* 416 Requested range not satisfiable 客户端请求的范围无效 |
||||
* 417 Expectation Failed 服务器无法满足Expect的请求头信息 |
||||
* <p> |
||||
* 5开头的状态码 |
||||
* 500 Internal Server Error 服务器内部错误,无法完成请求 |
||||
* 501 Not Implemented 服务器不支持请求的功能,无法完成请求 |
||||
* 502 Bad Gateway 充当网关或代理的服务器,从远端服务器接收到了一个无效的请求 |
||||
* 503 Service Unavailable 由于超载或系统维护,服务器暂时的无法处理客户端的请求。延时的长度可包含在服务器的Retry-After头信息中 |
||||
* 504 Gateway Time-out 充当网关或代理的服务器,未及时从远端服务器获取请求 |
||||
* 505 HTTP Version not supported 服务器不支持请求的HTTP协议的版本,无法完成处理 |
||||
* <p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/5/2 0:22 |
||||
*/ |
||||
public interface ErrorCode { |
||||
|
||||
/* ---------- 401 ---------- */ |
||||
int UNAUTHORIZED = HttpStatus.SC_UNAUTHORIZED * 100; |
||||
int ACCESS_DENIED = UNAUTHORIZED + 1; |
||||
int ACCOUNT_DISABLED = ACCESS_DENIED + 1; |
||||
int ACCOUNT_ENDPOINT_LIMITED = ACCOUNT_DISABLED + 1; |
||||
|
||||
int ACCOUNT_EXPIRED = ACCOUNT_ENDPOINT_LIMITED + 1; |
||||
int ACCOUNT_LOCKED = ACCOUNT_EXPIRED + 1; |
||||
int BAD_CREDENTIALS = ACCOUNT_LOCKED + 1; |
||||
int CREDENTIALS_EXPIRED = BAD_CREDENTIALS + 1; |
||||
int INVALID_CLIENT = CREDENTIALS_EXPIRED + 1; |
||||
int INVALID_TOKEN = INVALID_CLIENT + 1; |
||||
int INVALID_GRANT = INVALID_TOKEN + 1; |
||||
int UNAUTHORIZED_CLIENT = INVALID_TOKEN + 1; |
||||
int USERNAME_NOT_FOUND = UNAUTHORIZED_CLIENT + 1; |
||||
int SESSION_EXPIRED = USERNAME_NOT_FOUND + 1; |
||||
|
||||
/* ---------- 403 ---------- */ |
||||
int FORBIDDEN = HttpStatus.SC_FORBIDDEN * 100; |
||||
int INSUFFICIENT_SCOPE = FORBIDDEN + 1; |
||||
int SQL_INJECTION_REQUEST = INSUFFICIENT_SCOPE + 1; |
||||
|
||||
/* ---------- 405 ---------- */ |
||||
int METHOD_NOT_ALLOWED = HttpStatus.SC_METHOD_NOT_ALLOWED * 100; |
||||
int HTTP_REQUEST_METHOD_NOT_SUPPORTED = METHOD_NOT_ALLOWED + 1; |
||||
|
||||
/* ---------- 406 ---------- */ |
||||
int NOT_ACCEPTABLE = HttpStatus.SC_NOT_ACCEPTABLE * 100; |
||||
int UNSUPPORTED_GRANT_TYPE = NOT_ACCEPTABLE + 1; |
||||
int UNSUPPORTED_RESPONSE_TYPE = UNSUPPORTED_GRANT_TYPE + 1; |
||||
int UNSUPPORTED_TOKEN_TYPE = UNSUPPORTED_RESPONSE_TYPE + 1; |
||||
|
||||
int CACHE_MODULE_406_BEGIN = UNSUPPORTED_TOKEN_TYPE; |
||||
int CACHE_MODULE_406_END = CACHE_MODULE_406_BEGIN + 4; |
||||
int REST_MODULE_406_BEGIN = CACHE_MODULE_406_END; |
||||
int REST_MODULE_406_END = CACHE_MODULE_406_BEGIN + 3; |
||||
|
||||
int MESSAGE_MODULE_406_BEGIN = REST_MODULE_406_END; |
||||
int MESSAGE_MODULE_406_END = MESSAGE_MODULE_406_BEGIN + 2; |
||||
|
||||
/* ---------- 412 ---------- */ |
||||
int PRECONDITION_FAILED = HttpStatus.SC_PRECONDITION_FAILED * 100; |
||||
int INVALID_REDIRECT_URI = PRECONDITION_FAILED + 1; |
||||
int INVALID_REQUEST = INVALID_REDIRECT_URI + 1; |
||||
int INVALID_SCOPE = INVALID_REQUEST + 1; |
||||
|
||||
int ACCESS_MODULE_406_BEGIN = INVALID_SCOPE; |
||||
|
||||
/* ---------- 415 ---------- */ |
||||
int UNSUPPORTED_MEDIA_TYPE = HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE * 100; |
||||
int HTTP_MEDIA_TYPE_NOT_ACCEPTABLE = UNSUPPORTED_MEDIA_TYPE + 1; |
||||
|
||||
/* ---------- 500 ---------- */ |
||||
int INTERNAL_SERVER_ERROR = HttpStatus.SC_INTERNAL_SERVER_ERROR * 100; |
||||
int SERVER_ERROR = INTERNAL_SERVER_ERROR + 1; |
||||
int HTTP_MESSAGE_NOT_READABLE_EXCEPTION = SERVER_ERROR + 1; |
||||
int ILLEGAL_ARGUMENT_EXCEPTION = HTTP_MESSAGE_NOT_READABLE_EXCEPTION + 1; |
||||
int IO_EXCEPTION = ILLEGAL_ARGUMENT_EXCEPTION + 1; |
||||
int MISSING_SERVLET_REQUEST_PARAMETER_EXCEPTION = IO_EXCEPTION + 1; |
||||
int NULL_POINTER_EXCEPTION = MISSING_SERVLET_REQUEST_PARAMETER_EXCEPTION + 1; |
||||
int TYPE_MISMATCH_EXCEPTION = NULL_POINTER_EXCEPTION + 1; |
||||
|
||||
int OSS_MODULE_500_BEGIN = TYPE_MISMATCH_EXCEPTION; |
||||
int OSS_MODULE_500_END = OSS_MODULE_500_BEGIN + 12; |
||||
int SMS_MODULE_500_BEGIN = OSS_MODULE_500_END; |
||||
int SMS_MODULE_500_END = OSS_MODULE_500_END + 2; |
||||
|
||||
/* ---------- 503 ---------- */ |
||||
int SERVICE_UNAVAILABLE = HttpStatus.SC_SERVICE_UNAVAILABLE * 100; |
||||
int COOKIE_THEFT = SERVICE_UNAVAILABLE + 1; |
||||
int INVALID_COOKIE = COOKIE_THEFT + 1; |
||||
int PROVIDER_NOT_FOUND = INVALID_COOKIE + 1; |
||||
int TEMPORARILY_UNAVAILABLE = PROVIDER_NOT_FOUND + 1; |
||||
|
||||
int WEB_MODULE_503_BEGIN = TEMPORARILY_UNAVAILABLE; |
||||
int WEB_MODULE_503_END = WEB_MODULE_503_BEGIN + 1; |
||||
|
||||
/* ---------- 600 ---------- */ |
||||
int DATABASE = 60000; |
||||
|
||||
/* ---------- 601 数据库操作运行前校验 ---------- */ |
||||
int DATABASE_VALIDATION = DATABASE + 100; |
||||
int METHOD_ARGUMENT_NOT_VALID = DATABASE_VALIDATION + 1; |
||||
|
||||
/* ---------- 602 数据库操作执行 ---------- */ |
||||
int DATABASE_EXECUTION = DATABASE_VALIDATION + 100; |
||||
int BAD_SQL_GRAMMAR = DATABASE_EXECUTION + 1; |
||||
int DATA_INTEGRITY_VIOLATION = BAD_SQL_GRAMMAR + 1; |
||||
int TRANSACTION_ROLLBACK = DATA_INTEGRITY_VIOLATION + 1; |
||||
|
||||
/* ---------- 700 基础设施交互错误 ---------- */ |
||||
int BASIC_FACILITIES = DATABASE + 10000; |
||||
|
||||
/* ---------- 701 Redis 相关错误 ---------- */ |
||||
int REDIS = BASIC_FACILITIES + 100; |
||||
int PIPELINE_INVALID_COMMANDS = REDIS + 1; |
||||
} |
@ -0,0 +1,46 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.constants; |
||||
|
||||
/** |
||||
* <p>Description: 自定义请求头 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/10/4 16:01 |
||||
*/ |
||||
public interface HttpHeaders { |
||||
|
||||
String UNKNOWN = "unknown"; |
||||
String PROXY_CLIENT_IP = "Proxy-Client-IP"; |
||||
String WL_PROXY_CLIENT_IP = "WL-Proxy-Client-IP"; |
||||
String HTTP_CLIENT_IP = "HTTP_CLIENT_IP"; |
||||
String HTTP_X_FORWARDED_FOR = "HTTP_X_FORWARDED_FOR"; |
||||
String X_REAL_IP = "X-Real-IP"; |
||||
String X_HERODOTUS_SESSION = "X-Quafer-Session"; |
||||
String X_HERODOTUS_FROM_IN = "X-Quafer-From-In"; |
||||
String X_HERODOTUS_TENANT_ID = "X-Quafer-Tenant-Id"; |
||||
String X_HERODOTUS_OPEN_ID = "X-Quafer-Open-Id"; |
||||
} |
@ -0,0 +1,45 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.constants; |
||||
|
||||
/** |
||||
* <p>Description: 统一的 Sandbox 管理 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/7 20:36 |
||||
*/ |
||||
public class Sandbox { |
||||
|
||||
/** |
||||
* 支付宝网关地址 |
||||
*/ |
||||
private static final String ALIPAY_PRODUCTION_SERVER_URL = "https://openapi.alipay.com/gateway.do"; |
||||
private static final String ALIPAY_SANDBOX_SERVER_URL = "https://openapi.alipaydev.com/gateway.do"; |
||||
|
||||
public static String getAliPayServerUrl(boolean sandbox) { |
||||
return sandbox ? ALIPAY_SANDBOX_SERVER_URL : ALIPAY_PRODUCTION_SERVER_URL; |
||||
} |
||||
} |
@ -0,0 +1,198 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.constants; |
||||
|
||||
/** |
||||
* @author liuh |
||||
*/ |
||||
public interface SymbolConstants { |
||||
|
||||
String AMPERSAND = "&"; |
||||
|
||||
String AMPERSAND_ENCODED = "&"; |
||||
|
||||
String APOSTROPHE = "'"; |
||||
|
||||
String APOSTROPHE_AND_COMMA = "',"; |
||||
|
||||
String APOSTROPHE_AND_COMMA_AND_APOSTROPHE = "','"; |
||||
|
||||
String AT = "@"; |
||||
|
||||
String BACK_SLASH = "\\"; |
||||
|
||||
String BETWEEN = "BETWEEN"; |
||||
|
||||
String BLANK = ""; |
||||
|
||||
String CDATA_OPEN = "<![CDATA["; |
||||
|
||||
String CDATA_CLOSE = "]]>"; |
||||
|
||||
String CLOSE_BRACKET = "]"; |
||||
|
||||
String CLOSE_CURLY_BRACE = "}"; |
||||
|
||||
String CLOSE_PARENTHESIS = ")"; |
||||
|
||||
String COLON = ":"; |
||||
|
||||
String COMMA = ","; |
||||
|
||||
String COMMA_AND_APOSTROPHE = ",'"; |
||||
|
||||
String COMMA_AND_SPACE = ", "; |
||||
|
||||
String DASH = "-"; |
||||
|
||||
String DOUBLE_APOSTROPHE = "''"; |
||||
|
||||
String DOUBLE_CLOSE_BRACKET = "]]"; |
||||
|
||||
String DOUBLE_OPEN_BRACKET = "[["; |
||||
|
||||
String DOUBLE_SLASH = "//"; |
||||
|
||||
String EQUAL = "="; |
||||
|
||||
String GREATER_THAN = ">"; |
||||
|
||||
String GREATER_THAN_OR_EQUAL = ">="; |
||||
|
||||
String FORWARD_SLASH = "/"; |
||||
|
||||
String FOUR_SPACES = " "; |
||||
|
||||
String FINISH_LEFT_ANGLE = "</"; |
||||
|
||||
String FINISH_RIGHT_ANGLE = "/>"; |
||||
|
||||
String GBK = "GBK"; |
||||
|
||||
String IS_NOT_NULL = "IS NOT NULL"; |
||||
|
||||
String IS_NULL = "IS NULL"; |
||||
|
||||
String IN = "IN"; |
||||
|
||||
String LEFT_ANGLE = "<"; |
||||
|
||||
String LESS_THAN = "<"; |
||||
|
||||
String LESS_THAN_OR_EQUAL = "<="; |
||||
|
||||
String LIKE = "LIKE"; |
||||
|
||||
String MINUS = "-"; |
||||
|
||||
String NBSP = " "; |
||||
|
||||
String NEW_LINE = "\n"; |
||||
|
||||
String NOT_EQUAL = "!="; |
||||
|
||||
String DB_NOT_EQUAL = "<>"; |
||||
|
||||
String NOT_LIKE = "NOT LIKE"; |
||||
|
||||
String NULL = "null"; |
||||
|
||||
String OPEN_BRACKET = "["; |
||||
|
||||
String OPEN_CURLY_BRACE = "{"; |
||||
|
||||
String OPEN_PARENTHESIS = "("; |
||||
|
||||
String PERCENT = "%"; |
||||
|
||||
String PERIOD = "."; |
||||
|
||||
String PIPE = "|"; |
||||
|
||||
String PLUS = "+"; |
||||
|
||||
String POUND = "#"; |
||||
|
||||
String QUESTION = "?"; |
||||
|
||||
String QUOTE = "\""; |
||||
|
||||
String RETURN = "\r"; |
||||
|
||||
String RETURN_NEW_LINE = "\r\n"; |
||||
|
||||
String RIGHT_ANGLE = ">"; |
||||
|
||||
String SEMICOLON = ";"; |
||||
|
||||
String SLASH = FORWARD_SLASH; |
||||
|
||||
String SPACE = " "; |
||||
|
||||
String STAR = "*"; |
||||
|
||||
String TAB = "\t"; |
||||
|
||||
String TILDE = "~"; |
||||
|
||||
String UNDERLINE = "_"; |
||||
|
||||
String SUFFIX_EXCEL_2003 = ".xls"; |
||||
|
||||
String SUFFIX_EXCEL_2007 = ".xlsx"; |
||||
|
||||
String SUFFIX_JPEG = ".jpg"; |
||||
|
||||
String SUFFIX_XML = ".xml"; |
||||
|
||||
String SUFFIX_PDF = ".pdf"; |
||||
|
||||
String SUFFIX_ZIP = ".zip"; |
||||
|
||||
String SUFFIX_DOC = ".doc"; |
||||
|
||||
String SUFFIX_DOCX = ".docx"; |
||||
|
||||
String SUFFIX_PPT = ".ppt"; |
||||
|
||||
String SUFFIX_PPTX = ".pptx"; |
||||
|
||||
String SUFFIX_EXCEL = ".xls"; |
||||
|
||||
String SUFFIX_EXCELX = ".xlsx"; |
||||
|
||||
String SUFFIX_SWF = ".swf"; |
||||
|
||||
String SUFFIX_PROPERTIES = ".properties"; |
||||
|
||||
String SUFFIX_YML = ".yml"; |
||||
|
||||
String SUFFIX_YAML = ".yaml"; |
||||
|
||||
String SUFFIX_JSON = ".json"; |
||||
|
||||
String XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
||||
} |
@ -0,0 +1,35 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.domain; |
||||
|
||||
/** |
||||
* <p>Description: AbstractDto </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/18 15:40 |
||||
*/ |
||||
public abstract class AbstractDto implements Entity { |
||||
} |
@ -0,0 +1,37 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.domain; |
||||
|
||||
|
||||
/** |
||||
* <p> Description : BaseCacheEntity </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2020/2/24 16:38 |
||||
*/ |
||||
public abstract class AbstractEntity implements Entity { |
||||
|
||||
} |
@ -0,0 +1,38 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.domain; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p>Description: BaseEntity </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2020/4/29 17:27 |
||||
*/ |
||||
public interface Entity extends Serializable { |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.enums; |
||||
|
||||
/** |
||||
* <p>Description: 基础工厂枚举 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/5/1 19:48 |
||||
*/ |
||||
public interface BaseFactoryEnum extends EnumValue<String>, EnumDescription{ |
||||
} |
@ -0,0 +1,36 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.enums; |
||||
|
||||
/** |
||||
* <p>Description: 基础枚举定义 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/26 16:52 |
||||
*/ |
||||
public interface BaseUiEnum<T> extends EnumValue<T>, EnumDescription { |
||||
|
||||
} |
@ -0,0 +1,42 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.enums; |
||||
|
||||
/** |
||||
* <p>Description: 枚举文字表述 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/26 16:50 |
||||
*/ |
||||
public interface EnumDescription { |
||||
|
||||
/** |
||||
* 获取枚举文字表述 |
||||
* |
||||
* @return 枚举文字表述 |
||||
*/ |
||||
String getDescription(); |
||||
} |
@ -0,0 +1,42 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.enums; |
||||
|
||||
/** |
||||
* <p>Description: 枚举值定义 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/26 16:49 |
||||
*/ |
||||
public interface EnumValue<T> { |
||||
|
||||
/** |
||||
* 获取枚举自定义值 |
||||
* |
||||
* @return 自定义枚举值 |
||||
*/ |
||||
T getValue(); |
||||
} |
@ -0,0 +1,68 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.exception; |
||||
|
||||
import com.liuhung.engine.assistant.core.domain.Result; |
||||
|
||||
/** |
||||
* <p>Description: 自定义错误基础类 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/4 18:31 |
||||
*/ |
||||
public abstract class AbstractQuaferException extends RuntimeException implements QuaferException { |
||||
|
||||
public AbstractQuaferException() { |
||||
super(); |
||||
} |
||||
|
||||
public AbstractQuaferException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public AbstractQuaferException(String message, Throwable cause) { |
||||
super(message, cause); |
||||
} |
||||
|
||||
public AbstractQuaferException(Throwable cause) { |
||||
super(cause); |
||||
} |
||||
|
||||
protected AbstractQuaferException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { |
||||
super(message, cause, enableSuppression, writableStackTrace); |
||||
} |
||||
|
||||
@Override |
||||
public Result<String> getResult() { |
||||
Result<String> result = Result.failure(); |
||||
result.code(getFeedback().getCode()); |
||||
result.message(getFeedback().getMessage()); |
||||
result.status(getFeedback().getStatus()); |
||||
result.stackTrace(super.getStackTrace()); |
||||
result.detail(super.getMessage()); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,52 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.definition.exception; |
||||
|
||||
import com.liuhung.engine.assistant.core.domain.Feedback; |
||||
import com.liuhung.engine.assistant.core.domain.Result; |
||||
|
||||
/** |
||||
* <p>Description: 核心 QuaferException 定义 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/8 9:06 |
||||
*/ |
||||
public interface QuaferException { |
||||
|
||||
/** |
||||
* 获取反馈信息 |
||||
* |
||||
* @return 反馈信息对象 {@link Feedback} |
||||
*/ |
||||
Feedback getFeedback(); |
||||
|
||||
/** |
||||
* 错误信息转换为 Result 对象。 |
||||
* |
||||
* @return 结果对象 {@link Result} |
||||
*/ |
||||
Result<String> getResult(); |
||||
} |
@ -0,0 +1,232 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.domain; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
/** |
||||
* <p>Description: 外部程序接入必要参数 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/1/25 16:53 |
||||
*/ |
||||
public class AccessPrincipal { |
||||
|
||||
/* ---------- 共性参数 ---------- */ |
||||
|
||||
@Schema(name = "后回调时带的参数code", title = "访问AuthorizeUrl后回调时带的参数code") |
||||
private String code; |
||||
|
||||
/* ---------- 微信小程序常用参数 ---------- */ |
||||
|
||||
@Schema(name = "小程序appId", title = "小程序appId") |
||||
private String appId; |
||||
|
||||
@Schema(name = "消息密文", title = "微信小程序消息密文") |
||||
private String encryptedData; |
||||
|
||||
@Schema(name = "加密算法的初始向量", title = "微信小程序加密算法的初始向量") |
||||
private String iv; |
||||
|
||||
@Schema(name = "小程序用户openId", title = "小程序用户openId") |
||||
private String openId; |
||||
|
||||
@Schema(name = "会话密钥", title = "微信小程序会话密钥") |
||||
private String sessionKey; |
||||
|
||||
@Schema(name = "唯一ID", title = "微信唯一ID") |
||||
private String unionId; |
||||
|
||||
@Schema(name = "用户非敏感信息", title = "微信小程序用户非敏感信息") |
||||
private String rawData; |
||||
|
||||
@Schema(name = "签名", title = "微信小程序签名") |
||||
private String signature; |
||||
|
||||
/* ---------- Just Auth 标准参数 ---------- */ |
||||
|
||||
@Schema(name = "后回调时带的参数auth_code", title = "该参数目前只使用于支付宝登录") |
||||
private String auth_code; |
||||
|
||||
@Schema(name = "后回调时带的参数state", title = "用于和请求AuthorizeUrl前的state比较,防止CSRF攻击") |
||||
private String state; |
||||
|
||||
@Schema(name = "华为授权登录接受code的参数名") |
||||
private String authorization_code; |
||||
|
||||
@Schema(name = "回调后返回的oauth_token", title = "Twitter回调后返回的oauth_token") |
||||
private String oauth_token; |
||||
|
||||
@Schema(name = "回调后返回的oauth_verifier", title = "Twitter回调后返回的oauth_verifier") |
||||
private String oauth_verifier; |
||||
|
||||
/* ---------- 手机短信验证码 ---------- */ |
||||
|
||||
@Schema(name = "手机号码", title = "手机短信登录唯一标识") |
||||
private String mobile; |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getAppId() { |
||||
return appId; |
||||
} |
||||
|
||||
public void setAppId(String appId) { |
||||
this.appId = appId; |
||||
} |
||||
|
||||
public String getEncryptedData() { |
||||
return encryptedData; |
||||
} |
||||
|
||||
public void setEncryptedData(String encryptedData) { |
||||
this.encryptedData = encryptedData; |
||||
} |
||||
|
||||
public String getIv() { |
||||
return iv; |
||||
} |
||||
|
||||
public void setIv(String iv) { |
||||
this.iv = iv; |
||||
} |
||||
|
||||
public String getOpenId() { |
||||
return openId; |
||||
} |
||||
|
||||
public void setOpenId(String openId) { |
||||
this.openId = openId; |
||||
} |
||||
|
||||
public String getSessionKey() { |
||||
return sessionKey; |
||||
} |
||||
|
||||
public void setSessionKey(String sessionKey) { |
||||
this.sessionKey = sessionKey; |
||||
} |
||||
|
||||
public String getUnionId() { |
||||
return unionId; |
||||
} |
||||
|
||||
public void setUnionId(String unionId) { |
||||
this.unionId = unionId; |
||||
} |
||||
|
||||
public String getRawData() { |
||||
return rawData; |
||||
} |
||||
|
||||
public void setRawData(String rawData) { |
||||
this.rawData = rawData; |
||||
} |
||||
|
||||
public String getSignature() { |
||||
return signature; |
||||
} |
||||
|
||||
public void setSignature(String signature) { |
||||
this.signature = signature; |
||||
} |
||||
|
||||
public String getAuth_code() { |
||||
return auth_code; |
||||
} |
||||
|
||||
public void setAuth_code(String auth_code) { |
||||
this.auth_code = auth_code; |
||||
} |
||||
|
||||
public String getState() { |
||||
return state; |
||||
} |
||||
|
||||
public void setState(String state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public String getAuthorization_code() { |
||||
return authorization_code; |
||||
} |
||||
|
||||
public void setAuthorization_code(String authorization_code) { |
||||
this.authorization_code = authorization_code; |
||||
} |
||||
|
||||
public String getOauth_token() { |
||||
return oauth_token; |
||||
} |
||||
|
||||
public void setOauth_token(String oauth_token) { |
||||
this.oauth_token = oauth_token; |
||||
} |
||||
|
||||
public String getOauth_verifier() { |
||||
return oauth_verifier; |
||||
} |
||||
|
||||
public void setOauth_verifier(String oauth_verifier) { |
||||
this.oauth_verifier = oauth_verifier; |
||||
} |
||||
|
||||
public String getMobile() { |
||||
return mobile; |
||||
} |
||||
|
||||
public void setMobile(String mobile) { |
||||
this.mobile = mobile; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("code", code) |
||||
.add("appId", appId) |
||||
.add("encryptedData", encryptedData) |
||||
.add("iv", iv) |
||||
.add("openId", openId) |
||||
.add("sessionKey", sessionKey) |
||||
.add("unionId", unionId) |
||||
.add("rawData", rawData) |
||||
.add("signature", signature) |
||||
.add("auth_code", auth_code) |
||||
.add("state", state) |
||||
.add("authorization_code", authorization_code) |
||||
.add("oauth_token", oauth_token) |
||||
.add("oauth_verifier", oauth_verifier) |
||||
.add("mobile", mobile) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,106 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.domain; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p>Description: 错误详情 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/8/18 15:48 |
||||
*/ |
||||
@Schema(title = "响应错误详情", description = "为兼容Validation而增加的Validation错误信息实体") |
||||
public class Error implements Serializable { |
||||
|
||||
@Schema(title = "Exception完整信息", type = "string") |
||||
private String detail; |
||||
|
||||
@Schema(title = "额外的错误信息,目前主要是Validation的Message") |
||||
private String message; |
||||
|
||||
@Schema(title = "额外的错误代码,目前主要是Validation的Code") |
||||
private String code; |
||||
|
||||
@Schema(title = "额外的错误字段,目前主要是Validation的Field") |
||||
private String field; |
||||
|
||||
@Schema(title = "错误堆栈信息") |
||||
private StackTraceElement[] stackTrace; |
||||
|
||||
public String getDetail() { |
||||
return detail; |
||||
} |
||||
|
||||
public void setDetail(String detail) { |
||||
this.detail = detail; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public void setMessage(String message) { |
||||
this.message = message; |
||||
} |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getField() { |
||||
return field; |
||||
} |
||||
|
||||
public void setField(String field) { |
||||
this.field = field; |
||||
} |
||||
|
||||
public StackTraceElement[] getStackTrace() { |
||||
return stackTrace; |
||||
} |
||||
|
||||
public void setStackTrace(StackTraceElement[] stackTrace) { |
||||
this.stackTrace = stackTrace; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("detail", detail) |
||||
.add("message", message) |
||||
.add("code", code) |
||||
.add("field", field) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,167 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.domain; |
||||
|
||||
import com.liuhung.engine.assistant.core.enums.ResultErrorCodes; |
||||
import com.google.common.base.MoreObjects; |
||||
import com.google.common.base.Objects; |
||||
import org.apache.http.HttpStatus; |
||||
|
||||
/** |
||||
* <p>Description: QuaferException 交互信息 </p> |
||||
* <p> |
||||
* 主要用于自定义 QuaferException 中,显示用户体验更好的错误信息。同时可以解决更好的分包,而不再需要统一在 ResultStatus里面定义。 |
||||
* 非自定义 QuaferException 还是在 ResultErrorCodes 中定义。 |
||||
* <p> |
||||
* 1** 信息,服务器收到请求,需要请求者继续执行操作 |
||||
* 2** 成功,操作被成功接收并处理 |
||||
* 3** 重定向,需要进一步的操作以完成请求 |
||||
* 4** 客户端错误,请求包含语法错误或无法完成请求 |
||||
* 5** 服务器错误,服务器在处理请求的过程中发生了错误 |
||||
* <p> |
||||
* 1开头的状态码 |
||||
* 100 Continue 继续。客户端应继续其请求 |
||||
* 101 Switching Protocols 切换协议。服务器根据客户端的请求切换协议。只能切换到更高级的协议,例如,切换到HTTP的新版本协议 |
||||
* <p> |
||||
* 2开头的状态码 |
||||
* 200 OK 请求成功。一般用于GET与POST请求 |
||||
* 201 Created 已创建。成功请求并创建了新的资源 |
||||
* 202 Accepted 已接受。已经接受请求,但未处理完成 |
||||
* 203 Non-Authoritative Information 非授权信息。请求成功。但返回的meta信息不在原始的服务器,而是一个副本 |
||||
* 204 No Content 无内容。服务器成功处理,但未返回内容。在未更新网页的情况下,可确保浏览器继续显示当前文档 |
||||
* 205 Reset Content 重置内容。服务器处理成功,用户终端(例如:浏览器)应重置文档视图。可通过此返回码清除浏览器的表单域 |
||||
* 206 Partial Content 部分内容。服务器成功处理了部分GET请求 |
||||
* <p> |
||||
* 3开头的状态码 |
||||
* 300 Multiple Choices 多种选择。请求的资源可包括多个位置,相应可返回一个资源特征与地址的列表用于用户终端(例如:浏览器)选择 |
||||
* 301 Moved Permanently 永久移动。请求的资源已被永久的移动到新URI,返回信息会包括新的URI,浏览器会自动定向到新URI。今后任何新的请求都应使用新的URI代替 |
||||
* 302 Found 临时移动。与301类似。但资源只是临时被移动。客户端应继续使用原有URI |
||||
* 303 See Other 查看其它地址。与301类似。使用GET和POST请求查看 |
||||
* 304 Not Modified 未修改。所请求的资源未修改,服务器返回此状态码时,不会返回任何资源。客户端通常会缓存访问过的资源,通过提供一个头信息指出客户端希望只返回在指定日期之后修改的资源 |
||||
* 305 Use Proxy 使用代理。所请求的资源必须通过代理访问 |
||||
* 306 Unused 已经被废弃的HTTP状态码 |
||||
* 307 Temporary Redirect 临时重定向。与302类似。使用GET请求重定向 |
||||
* <p> |
||||
* 4开头的状态码 |
||||
* 400 Bad Request 客户端请求的语法错误,服务器无法理解 |
||||
* 401 Unauthorized 请求要求用户的身份认证 |
||||
* 402 Payment Required 保留,将来使用 |
||||
* 403 Forbidden 服务器理解请求客户端的请求,但是拒绝执行此请求 |
||||
* 404 Not Found 服务器无法根据客户端的请求找到资源(网页)。通过此代码,网站设计人员可设置"您所请求的资源无法找到"的个性页面 |
||||
* 405 Method Not Allowed 客户端请求中的方法被禁止 |
||||
* 406 Not Acceptable 服务器无法根据客户端请求的内容特性完成请求 |
||||
* 407 Proxy Authentication Required 请求要求代理的身份认证,与401类似,但请求者应当使用代理进行授权 |
||||
* 408 Request Time-out 服务器等待客户端发送的请求时间过长,超时 |
||||
* 409 Conflict 服务器完成客户端的PUT请求是可能返回此代码,服务器处理请求时发生了冲突 |
||||
* 410 Gone 客户端请求的资源已经不存在。410不同于404,如果资源以前有现在被永久删除了可使用410代码,网站设计人员可通过301代码指定资源的新位置 |
||||
* 411 Length Required 服务器无法处理客户端发送的不带Content-Length的请求信息 |
||||
* 412 Precondition Failed 客户端请求信息的先决条件错误 |
||||
* 413 Request Entity Too Large 由于请求的实体过大,服务器无法处理,因此拒绝请求。为防止客户端的连续请求,服务器可能会关闭连接。如果只是服务器暂时无法处理,则会包含一个Retry-After的响应信息 |
||||
* 414 Request-URI Too Large 请求的URI过长(URI通常为网址),服务器无法处理 |
||||
* 415 Unsupported Media Type 服务器无法处理请求附带的媒体格式 |
||||
* 416 Requested range not satisfiable 客户端请求的范围无效 |
||||
* 417 Expectation Failed 服务器无法满足Expect的请求头信息 |
||||
* <p> |
||||
* 5开头的状态码 |
||||
* 500 Internal Server Error 服务器内部错误,无法完成请求 |
||||
* 501 Not Implemented 服务器不支持请求的功能,无法完成请求 |
||||
* 502 Bad Gateway 充当网关或代理的服务器,从远端服务器接收到了一个无效的请求 |
||||
* 503 Service Unavailable 由于超载或系统维护,服务器暂时的无法处理客户端的请求。延时的长度可包含在服务器的Retry-After头信息中 |
||||
* 504 Gateway Time-out 充当网关或代理的服务器,未及时从远端服务器获取请求 |
||||
* 505 HTTP Version not supported 服务器不支持请求的HTTP协议的版本,无法完成处理 |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/3/4 17:35 |
||||
*/ |
||||
public class Feedback { |
||||
|
||||
public static final Feedback OK = new Feedback(20000, "成功", HttpStatus.SC_OK); |
||||
public static final Feedback NO_CONTENT = new Feedback(20400, "无内容", HttpStatus.SC_NO_CONTENT); |
||||
public static final Feedback ERROR = new Feedback(50000, "服务器内部错误,无法完成请求", HttpStatus.SC_INTERNAL_SERVER_ERROR); |
||||
|
||||
/** |
||||
* 自定义错误代码 |
||||
*/ |
||||
private final int code; |
||||
|
||||
/** |
||||
* 用户友好的错误信息 |
||||
*/ |
||||
private final String message; |
||||
|
||||
/** |
||||
* 对应 Http 请求状态码 |
||||
*/ |
||||
private final int status; |
||||
|
||||
public Feedback(ResultErrorCodes resultErrorCodes, int status) { |
||||
this(resultErrorCodes.getCode(), resultErrorCodes.getMessage(), status); |
||||
} |
||||
|
||||
public Feedback(int code, String message, int status) { |
||||
this.code = code; |
||||
this.message = message; |
||||
this.status = status; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public int getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) { |
||||
return true; |
||||
} |
||||
if (o == null || getClass() != o.getClass()) { |
||||
return false; |
||||
} |
||||
Feedback that = (Feedback) o; |
||||
return code == that.code && status == that.status; |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(code, status); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("code", code) |
||||
.add("message", message) |
||||
.add("status", status) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,131 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Cloud 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.domain; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.constants.BaseConstants; |
||||
import com.google.common.base.MoreObjects; |
||||
import com.google.common.base.Objects; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* <p>Description: 用户登录额外信息 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/13 14:31 |
||||
*/ |
||||
public class PrincipalDetails { |
||||
|
||||
private String openId; |
||||
|
||||
private String userName; |
||||
|
||||
private Set<String> roles; |
||||
|
||||
private String employeeId; |
||||
|
||||
private String avatar; |
||||
|
||||
public String getOpenId() { |
||||
return openId; |
||||
} |
||||
|
||||
public void setOpenId(String openId) { |
||||
this.openId = openId; |
||||
} |
||||
|
||||
public String getUserName() { |
||||
return userName; |
||||
} |
||||
|
||||
public void setUserName(String userName) { |
||||
this.userName = userName; |
||||
} |
||||
|
||||
public Set<String> getRoles() { |
||||
return roles; |
||||
} |
||||
|
||||
public void setRoles(Set<String> roles) { |
||||
this.roles = roles; |
||||
} |
||||
|
||||
public String getEmployeeId() { |
||||
return employeeId; |
||||
} |
||||
|
||||
public void setEmployeeId(String employeeId) { |
||||
this.employeeId = employeeId; |
||||
} |
||||
|
||||
public String getAvatar() { |
||||
return avatar; |
||||
} |
||||
|
||||
public void setAvatar(String avatar) { |
||||
this.avatar = avatar; |
||||
} |
||||
|
||||
public Map<String, Object> toMap() { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put(BaseConstants.OPEN_ID, this.openId); |
||||
map.put(BaseConstants.USERNAME, this.userName); |
||||
map.put(BaseConstants.ROLES, this.roles); |
||||
map.put(BaseConstants.EMPLOYEE_ID, this.employeeId); |
||||
map.put(BaseConstants.AVATAR, this.avatar); |
||||
return map; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) { |
||||
return true; |
||||
} |
||||
if (o == null || getClass() != o.getClass()) { |
||||
return false; |
||||
} |
||||
PrincipalDetails that = (PrincipalDetails) o; |
||||
return Objects.equal(openId, that.openId); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(openId); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("openId", openId) |
||||
.add("userName", userName) |
||||
.add("roles", roles) |
||||
.add("employeeId", employeeId) |
||||
.add("avatar", avatar) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,313 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.domain; |
||||
|
||||
|
||||
import com.liuhung.engine.assistant.core.enums.ResultErrorCodes; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.google.common.base.MoreObjects; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import org.apache.commons.lang3.ArrayUtils; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.apache.http.HttpStatus; |
||||
import org.apache.skywalking.apm.toolkit.trace.TraceContext; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 统一响应实体 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2020/2/29 14:50 |
||||
*/ |
||||
@Schema(title = "统一响应返回实体", description = "所有Rest接口统一返回的实体定义", example = "new Result<T>().ok().message(\"XXX\")") |
||||
public class Result<T> implements Serializable { |
||||
|
||||
@Schema(title = "自定义响应编码") |
||||
private int code = 0; |
||||
|
||||
@Schema(title = "响应返回信息") |
||||
private String message; |
||||
|
||||
@Schema(title = "请求路径") |
||||
private String path; |
||||
|
||||
@Schema(title = "响应返回数据") |
||||
private T data; |
||||
|
||||
@Schema(title = "http状态码") |
||||
private int status; |
||||
|
||||
@Schema(title = "链路 TraceId") |
||||
private String traceId = TraceContext.traceId(); |
||||
|
||||
@Schema(title = "响应时间戳", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date timestamp = new Date(); |
||||
|
||||
@Schema(title = "校验错误信息") |
||||
private Error error = new Error(); |
||||
|
||||
public Result() { |
||||
super(); |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return path; |
||||
} |
||||
|
||||
public String getTraceId() { |
||||
return traceId; |
||||
} |
||||
|
||||
public T getData() { |
||||
return data; |
||||
} |
||||
|
||||
public int getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public Date getTimestamp() { |
||||
return timestamp; |
||||
} |
||||
|
||||
public Error getError() { |
||||
return error; |
||||
} |
||||
|
||||
public Result<T> code(int code) { |
||||
this.code = code; |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> message(String message) { |
||||
this.message = message; |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> data(T data) { |
||||
this.data = data; |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> path(String path) { |
||||
this.path = path; |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> type(ResultErrorCodes resultErrorCodes) { |
||||
this.code = resultErrorCodes.getCode(); |
||||
this.message = resultErrorCodes.getMessage(); |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> traceId(String traceId) { |
||||
this.traceId = traceId; |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> status(int httpStatus) { |
||||
this.status = httpStatus; |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> stackTrace(StackTraceElement[] stackTrace) { |
||||
this.error.setStackTrace(stackTrace); |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> detail(String detail) { |
||||
this.error.setDetail(detail); |
||||
return this; |
||||
} |
||||
|
||||
public Result<T> validation(String message, String code, String field) { |
||||
this.error.setMessage(message); |
||||
this.error.setCode(code); |
||||
this.error.setField(field); |
||||
return this; |
||||
} |
||||
|
||||
private static <T> Result<T> create(String message, String detail, int code, int status, T data, StackTraceElement[] stackTrace) { |
||||
Result<T> result = new Result<>(); |
||||
if (StringUtils.isNotBlank(message)) { |
||||
result.message(message); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(detail)) { |
||||
result.detail(detail); |
||||
} |
||||
|
||||
result.code(code); |
||||
result.status(status); |
||||
|
||||
if (ObjectUtils.isNotEmpty(data)) { |
||||
result.data(data); |
||||
} |
||||
|
||||
if (ArrayUtils.isNotEmpty(stackTrace)) { |
||||
result.stackTrace(stackTrace); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
public static <T> Result<T> success(String message, int code, int status, T data) { |
||||
return create(message, null, code, status, data, null); |
||||
} |
||||
|
||||
public static <T> Result<T> success(String message, int code, T data) { |
||||
return success(message, code, HttpStatus.SC_OK, data); |
||||
} |
||||
|
||||
public static <T> Result<T> success(ResultErrorCodes resultErrorCodes, T data) { |
||||
return success(resultErrorCodes.getMessage(), resultErrorCodes.getCode(), data); |
||||
} |
||||
|
||||
public static <T> Result<T> success(Feedback feedback, T data) { |
||||
return success(feedback.getMessage(), feedback.getCode(), feedback.getStatus(), data); |
||||
} |
||||
|
||||
public static <T> Result<T> success(String message, T data) { |
||||
return success(message, Feedback.OK.getCode(), data); |
||||
} |
||||
|
||||
public static <T> Result<T> success(String message) { |
||||
return success(message, null); |
||||
} |
||||
|
||||
public static <T> Result<T> success() { |
||||
return success("操作成功!"); |
||||
} |
||||
|
||||
public static <T> Result<T> content(T data) { |
||||
return success("操作成功!", data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message, String detail, int code, int status, T data, StackTraceElement[] stackTrace) { |
||||
return create(message, detail, code, status, data, stackTrace); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message, String detail, int code, int status, T data) { |
||||
return failure(message, detail, code, status, data, null); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message, int code, int status, T data) { |
||||
return failure(message, message, code, status, data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message, String detail, int code, T data) { |
||||
return failure(message, detail, code, HttpStatus.SC_INTERNAL_SERVER_ERROR, data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message, int code, T data) { |
||||
return failure(message, message, code, data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(ResultErrorCodes resultErrorCodes, T data) { |
||||
return failure(resultErrorCodes.getMessage(), resultErrorCodes.getCode(), data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(Feedback feedback, T data) { |
||||
return failure(feedback.getMessage(), feedback.getCode(), feedback.getStatus(), data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message, T data) { |
||||
return failure(message, Feedback.ERROR.getCode(), data); |
||||
} |
||||
|
||||
public static <T> Result<T> failure(String message) { |
||||
return failure(message, null); |
||||
} |
||||
|
||||
public static <T> Result<T> failure() { |
||||
return failure("操作失败!"); |
||||
} |
||||
|
||||
public static <T> Result<T> empty(String message, int code, int status) { |
||||
return create(message, null, code, status, null, null); |
||||
} |
||||
|
||||
public static <T> Result<T> empty(String message, int code) { |
||||
return empty(message, code, Feedback.NO_CONTENT.getStatus()); |
||||
} |
||||
|
||||
public static <T> Result<T> empty(Feedback feedback) { |
||||
return empty(feedback.getMessage(), feedback.getCode(), feedback.getStatus()); |
||||
} |
||||
|
||||
public static <T> Result<T> empty(ResultErrorCodes resultErrorCodes) { |
||||
return empty(resultErrorCodes.getMessage(), resultErrorCodes.getCode()); |
||||
} |
||||
|
||||
public static <T> Result<T> empty(String message) { |
||||
return empty(message, Feedback.NO_CONTENT.getCode()); |
||||
} |
||||
|
||||
public static <T> Result<T> empty() { |
||||
return empty("未查询到相关内容!"); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("code", code) |
||||
.add("message", message) |
||||
.add("path", path) |
||||
.add("data", data) |
||||
.add("status", status) |
||||
.add("timestamp", timestamp) |
||||
.add("error", error) |
||||
.add("traceId", traceId) |
||||
.toString(); |
||||
} |
||||
|
||||
public Map<String, Object> toModel() { |
||||
Map<String, Object> result = new HashMap<>(8); |
||||
result.put("code", code); |
||||
result.put("message", message); |
||||
result.put("path", path); |
||||
result.put("data", data); |
||||
result.put("status", status); |
||||
result.put("timestamp", timestamp); |
||||
result.put("error", error); |
||||
result.put("traceId", traceId); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,152 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.domain; |
||||
|
||||
import com.google.common.base.MoreObjects; |
||||
import com.google.common.base.Objects; |
||||
|
||||
import java.io.Serializable; |
||||
import java.sql.Timestamp; |
||||
|
||||
/** |
||||
* <p>Description: 秘钥缓存存储实体 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/9/30 18:17 |
||||
*/ |
||||
public class SecretKey implements Serializable { |
||||
|
||||
/** |
||||
* 数据存储身份标识 |
||||
*/ |
||||
private String identity; |
||||
/** |
||||
* 对称加密算法秘钥 |
||||
*/ |
||||
private String symmetricKey; |
||||
|
||||
/** |
||||
* 服务器端非对称加密算法公钥 |
||||
* 1. RSA 为 Base64 格式 |
||||
* 2. SM2 为 Hex 格式 |
||||
*/ |
||||
private String publicKey; |
||||
|
||||
/** |
||||
* 服务器端非对称加密算法私钥 |
||||
*/ |
||||
private String privateKey; |
||||
|
||||
/** |
||||
* 本系统授权码模式中后台返回的 State |
||||
*/ |
||||
private String state; |
||||
|
||||
/** |
||||
* 创建时间戳 |
||||
*/ |
||||
private Timestamp timestamp = new Timestamp(System.currentTimeMillis()); |
||||
|
||||
public SecretKey() { |
||||
} |
||||
|
||||
public String getIdentity() { |
||||
return identity; |
||||
} |
||||
|
||||
public void setIdentity(String identity) { |
||||
this.identity = identity; |
||||
} |
||||
|
||||
public String getSymmetricKey() { |
||||
return symmetricKey; |
||||
} |
||||
|
||||
public void setSymmetricKey(String symmetricKey) { |
||||
this.symmetricKey = symmetricKey; |
||||
} |
||||
|
||||
public String getPublicKey() { |
||||
return publicKey; |
||||
} |
||||
|
||||
public void setPublicKey(String publicKey) { |
||||
this.publicKey = publicKey; |
||||
} |
||||
|
||||
public String getPrivateKey() { |
||||
return privateKey; |
||||
} |
||||
|
||||
public void setPrivateKey(String privateKey) { |
||||
this.privateKey = privateKey; |
||||
} |
||||
|
||||
public Timestamp getTimestamp() { |
||||
return timestamp; |
||||
} |
||||
|
||||
public void setTimestamp(Timestamp timestamp) { |
||||
this.timestamp = timestamp; |
||||
} |
||||
|
||||
public String getState() { |
||||
return state; |
||||
} |
||||
|
||||
public void setState(String state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) { |
||||
return true; |
||||
} |
||||
if (o == null || getClass() != o.getClass()) { |
||||
return false; |
||||
} |
||||
SecretKey secretKey = (SecretKey) o; |
||||
return Objects.equal(identity, secretKey.identity) && Objects.equal(timestamp, secretKey.timestamp); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(identity, timestamp); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return MoreObjects.toStringHelper(this) |
||||
.add("identity", identity) |
||||
.add("symmetricKey", symmetricKey) |
||||
.add("publicKey", publicKey) |
||||
.add("privateKey", privateKey) |
||||
.add("state", state) |
||||
.add("timestamp", timestamp) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,166 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonValue; |
||||
import com.google.common.collect.ImmutableMap; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import me.zhyd.oauth.config.AuthDefaultSource; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author liuh |
||||
* 登录类型:password-密码、mobile-手机号、email-邮箱、weixin-微信、weibo-微博、qq-等等 |
||||
*/ |
||||
@Schema(title = "账号类型") |
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT) |
||||
public enum AccountType { |
||||
|
||||
/** |
||||
* 登录类型 |
||||
*/ |
||||
INSTITUTION("INSTITUTION", "", "机构人员"), |
||||
SMS("SMS", AccountType.PHONE_NUMBER_HANDLER, "手机验证码"), |
||||
WXAPP("WXAPP", AccountType.WECHAT_MINI_APP_HANDLER, "微信小程序"), |
||||
QQ(AuthDefaultSource.QQ.name(), AccountType.JUST_AUTH_HANDLER, "QQ"), |
||||
WEIBO(AuthDefaultSource.WEIBO.name(), AccountType.JUST_AUTH_HANDLER, "微博"), |
||||
BAIDU(AuthDefaultSource.BAIDU.name(), AccountType.JUST_AUTH_HANDLER, "百度"), |
||||
WECHAT_OPEN(AuthDefaultSource.WECHAT_OPEN.name(), AccountType.JUST_AUTH_HANDLER, "微信开放平台"), |
||||
WECHAT_MP(AuthDefaultSource.WECHAT_MP.name(), AccountType.JUST_AUTH_HANDLER, "微信公众号"), |
||||
WECHAT_ENTERPRISE(AuthDefaultSource.WECHAT_ENTERPRISE.name(), AccountType.JUST_AUTH_HANDLER, "企业微信二维码"), |
||||
WECHAT_ENTERPRISE_WEB(AuthDefaultSource.WECHAT_ENTERPRISE_WEB.name(), AccountType.JUST_AUTH_HANDLER, "企业微信网页"), |
||||
DINGTALK(AuthDefaultSource.DINGTALK.name(), AccountType.JUST_AUTH_HANDLER, "钉钉"), |
||||
DINGTALK_ACCOUNT(AuthDefaultSource.DINGTALK_ACCOUNT.name(), AccountType.JUST_AUTH_HANDLER, "钉钉账号"), |
||||
ALIYUN(AuthDefaultSource.ALIYUN.name(), AccountType.JUST_AUTH_HANDLER, "阿里云"), |
||||
TAOBAO(AuthDefaultSource.TAOBAO.name(), AccountType.JUST_AUTH_HANDLER, "淘宝"), |
||||
ALIPAY(AuthDefaultSource.ALIPAY.name(), AccountType.JUST_AUTH_HANDLER, "支付宝"), |
||||
TEAMBITION(AuthDefaultSource.TEAMBITION.name(), AccountType.JUST_AUTH_HANDLER, "Teambition"), |
||||
HUAWEI(AuthDefaultSource.HUAWEI.name(), AccountType.JUST_AUTH_HANDLER, "华为"), |
||||
FEISHU(AuthDefaultSource.FEISHU.name(), AccountType.JUST_AUTH_HANDLER, "飞书"), |
||||
JD(AuthDefaultSource.JD.name(), AccountType.JUST_AUTH_HANDLER, "京东"), |
||||
DOUYIN(AuthDefaultSource.DOUYIN.name(), AccountType.JUST_AUTH_HANDLER, "抖音"), |
||||
TOUTIAO(AuthDefaultSource.TOUTIAO.name(), AccountType.JUST_AUTH_HANDLER, "今日头条"), |
||||
MI(AuthDefaultSource.MI.name(), AccountType.JUST_AUTH_HANDLER, "小米"), |
||||
RENREN(AuthDefaultSource.RENREN.name(), AccountType.JUST_AUTH_HANDLER, "人人"), |
||||
MEITUAN(AuthDefaultSource.MEITUAN.name(), AccountType.JUST_AUTH_HANDLER, "美团"), |
||||
ELEME(AuthDefaultSource.ELEME.name(), AccountType.JUST_AUTH_HANDLER, "饿了么"), |
||||
KUJIALE(AuthDefaultSource.KUJIALE.name(), AccountType.JUST_AUTH_HANDLER, "酷家乐"), |
||||
XMLY(AuthDefaultSource.XMLY.name(), AccountType.JUST_AUTH_HANDLER, "喜马拉雅"), |
||||
GITEE(AuthDefaultSource.GITEE.name(), AccountType.JUST_AUTH_HANDLER, "码云"), |
||||
OSCHINA(AuthDefaultSource.OSCHINA.name(), AccountType.JUST_AUTH_HANDLER, "开源中国"), |
||||
CSDN(AuthDefaultSource.CSDN.name(), AccountType.JUST_AUTH_HANDLER, "CSDN"), |
||||
GITHUB(AuthDefaultSource.GITHUB.name(), AccountType.JUST_AUTH_HANDLER, "Github"), |
||||
GITLAB(AuthDefaultSource.GITLAB.name(), AccountType.JUST_AUTH_HANDLER, "Gitlab"), |
||||
STACK_OVERFLOW(AuthDefaultSource.STACK_OVERFLOW.name(), AccountType.JUST_AUTH_HANDLER, "Stackoverflow"), |
||||
CODING(AuthDefaultSource.CODING.name(), AccountType.JUST_AUTH_HANDLER, "Coding"), |
||||
GOOGLE(AuthDefaultSource.GOOGLE.name(), AccountType.JUST_AUTH_HANDLER, "谷歌"), |
||||
MICROSOFT(AuthDefaultSource.MICROSOFT.name(), AccountType.JUST_AUTH_HANDLER, "微软"), |
||||
FACEBOOK(AuthDefaultSource.FACEBOOK.name(), AccountType.JUST_AUTH_HANDLER, "脸书"), |
||||
LINKEDIN(AuthDefaultSource.LINKEDIN.name(), AccountType.JUST_AUTH_HANDLER, "领英"), |
||||
TWITTER(AuthDefaultSource.TWITTER.name(), AccountType.JUST_AUTH_HANDLER, "推特"), |
||||
AMAZON(AuthDefaultSource.AMAZON.name(), AccountType.JUST_AUTH_HANDLER, "亚马逊"), |
||||
SLACK(AuthDefaultSource.SLACK.name(), AccountType.JUST_AUTH_HANDLER, "Slack"), |
||||
LINE(AuthDefaultSource.LINE.name(), AccountType.JUST_AUTH_HANDLER, "Line"), |
||||
OKTA(AuthDefaultSource.OKTA.name(), AccountType.JUST_AUTH_HANDLER, "Okta"), |
||||
PINTEREST(AuthDefaultSource.PINTEREST.name(), AccountType.JUST_AUTH_HANDLER, "Pinterest"); |
||||
|
||||
@Schema(title = "枚举值") |
||||
private final String key; |
||||
@Schema(title = "处理器") |
||||
private final String handler; |
||||
@Schema(title = "文字") |
||||
private final String description; |
||||
|
||||
private static final Map<String, AccountType> INDEX_MAP = new HashMap<>(); |
||||
private static final List<Map<String, Object>> JSON_STRUCT = new ArrayList<>(); |
||||
|
||||
static { |
||||
for (AccountType accountType : AccountType.values()) { |
||||
INDEX_MAP.put(accountType.getKey(), accountType); |
||||
JSON_STRUCT.add(accountType.ordinal(), |
||||
ImmutableMap.<String, Object>builder() |
||||
.put("value", accountType.ordinal()) |
||||
.put("key", accountType.name()) |
||||
.put("text", accountType.getDescription()) |
||||
.build()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Just Auth 第三方社交登录 |
||||
*/ |
||||
public static final String JUST_AUTH_HANDLER = "JUST_AUTH"; |
||||
|
||||
/** |
||||
* 手机号验证码登录 |
||||
*/ |
||||
public static final String PHONE_NUMBER_HANDLER = "PHONE_NUMBER"; |
||||
|
||||
/** |
||||
* 手机号验证码登录 |
||||
*/ |
||||
public static final String WECHAT_MINI_APP_HANDLER = "WECHAT_MINI_APP"; |
||||
|
||||
AccountType(String key, String handler, String description) { |
||||
this.key = key; |
||||
this.handler = handler; |
||||
this.description = description; |
||||
} |
||||
|
||||
/** |
||||
* 不加@JsonValue,转换的时候转换出完整的对象。 |
||||
* 加了@JsonValue,只会显示相应的属性的值 |
||||
* <p> |
||||
* 不使用@JsonValue @JsonDeserializer类里面要做相应的处理 |
||||
* |
||||
* @return Enum枚举值 |
||||
*/ |
||||
@JsonValue |
||||
public String getKey() { |
||||
return key; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return this.description; |
||||
} |
||||
|
||||
public String getHandler() { |
||||
return handler; |
||||
} |
||||
|
||||
public static AccountType getAccountType(String key) { |
||||
return INDEX_MAP.get(key); |
||||
} |
||||
|
||||
public static List<Map<String, Object>> getJsonStruct() { |
||||
return JSON_STRUCT; |
||||
} |
||||
} |
@ -0,0 +1,105 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonValue; |
||||
import com.google.common.collect.ImmutableMap; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 权限资源类型 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2019/11/25 15:10 |
||||
*/ |
||||
@Schema(title = "权限类型") |
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT) |
||||
public enum AuthorityType { |
||||
|
||||
/** |
||||
* enum |
||||
*/ |
||||
API(0, "REST API"), |
||||
MENU(1, "功能菜单"), |
||||
PAGE(2, "Web Page"), |
||||
MINI_PAGE(3, "小程序页面"); |
||||
|
||||
@Schema(title = "枚举值") |
||||
private final Integer index; |
||||
@Schema(title = "文字") |
||||
private final String text; |
||||
|
||||
private static final Map<Integer, AuthorityType> indexMap = new HashMap<>(); |
||||
private static final List<Map<String, Object>> toJsonStruct = new ArrayList<>(); |
||||
|
||||
static { |
||||
for (AuthorityType authorityType : AuthorityType.values()) { |
||||
indexMap.put(authorityType.getIndex(), authorityType); |
||||
toJsonStruct.add(authorityType.getIndex(), |
||||
ImmutableMap.<String, Object>builder() |
||||
.put("value", authorityType.getIndex()) |
||||
.put("key", authorityType.name()) |
||||
.put("text", authorityType.getText()) |
||||
.build()); |
||||
} |
||||
} |
||||
|
||||
AuthorityType(Integer index, String text) { |
||||
this.index = index; |
||||
this.text = text; |
||||
} |
||||
|
||||
/** |
||||
* 不加@JsonValue,转换的时候转换出完整的对象。 |
||||
* 加了@JsonValue,只会显示相应的属性的值 |
||||
* <p> |
||||
* 不使用@JsonValue @JsonDeserializer类里面要做相应的处理 |
||||
* |
||||
* @return Enum枚举值 |
||||
*/ |
||||
@JsonValue |
||||
public Integer getIndex() { |
||||
return index; |
||||
} |
||||
|
||||
public String getText() { |
||||
return this.text; |
||||
} |
||||
|
||||
public static AuthorityType getAuthorityType(Integer index) { |
||||
return indexMap.get(index); |
||||
} |
||||
|
||||
public static List<Map<String, Object>> getToJsonStruct() { |
||||
return toJsonStruct; |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
/** |
||||
* <p>Description: 数据资源 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/9/10 16:48 |
||||
*/ |
||||
public enum DataResource { |
||||
DATABASE, PROPERTY; |
||||
} |
@ -0,0 +1,114 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.enums.BaseUiEnum; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonValue; |
||||
import com.google.common.collect.ImmutableMap; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 数据库类型 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/21 17:02 |
||||
*/ |
||||
@Schema(title = "数据库类别") |
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT) |
||||
public enum Database implements BaseUiEnum<Integer> { |
||||
/** |
||||
* 数据库类型 |
||||
*/ |
||||
ORACLE(0, "Oracle"), |
||||
POSTGRESQL(1, "PostgreSQL"), |
||||
MYSQL(2, "Mysql"), |
||||
MARIADB(3, "MariaDB"), |
||||
SQLSERVER(4, "SQLServer"), |
||||
SYBASE(5, "SyBase"), |
||||
SAPDB(6, "SAPDB"), |
||||
DB2(7, "DB2"), |
||||
H2(8, "H2"), |
||||
REDIS(9, "Redis"); |
||||
|
||||
@Schema(title = "枚举值") |
||||
private final Integer value; |
||||
@Schema(name = "文字") |
||||
private final String description; |
||||
|
||||
private static final Map<Integer, Database> INDEX_MAP = new HashMap<>(); |
||||
private static final List<Map<String, Object>> JSON_STRUCTURE = new ArrayList<>(); |
||||
|
||||
static { |
||||
for (Database database : Database.values()) { |
||||
INDEX_MAP.put(database.getValue(), database); |
||||
JSON_STRUCTURE.add(database.getValue(), |
||||
ImmutableMap.<String, Object>builder() |
||||
.put("value", database.getValue()) |
||||
.put("key", database.name()) |
||||
.put("text", database.getDescription()) |
||||
.put("index", database.getValue()) |
||||
.build()); |
||||
} |
||||
} |
||||
|
||||
Database(Integer value, String description) { |
||||
this.value = value; |
||||
this.description = description; |
||||
} |
||||
|
||||
/** |
||||
* 不加@JsonValue,转换的时候转换出完整的对象。 |
||||
* 加了@JsonValue,只会显示相应的属性的值 |
||||
* <p> |
||||
* 不使用@JsonValue @JsonDeserializer类里面要做相应的处理 |
||||
* |
||||
* @return Enum枚举值 |
||||
*/ |
||||
@JsonValue |
||||
@Override |
||||
public Integer getValue() { |
||||
return value; |
||||
} |
||||
|
||||
@Override |
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public static Database get(Integer index) { |
||||
return INDEX_MAP.get(index); |
||||
} |
||||
|
||||
public static List<Map<String, Object>> getPreprocessedJsonStructure() { |
||||
return JSON_STRUCTURE; |
||||
} |
||||
} |
@ -0,0 +1,56 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
/** |
||||
* <p>Description: Protocol枚举 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2021/6/12 14:48 |
||||
*/ |
||||
public enum Protocol { |
||||
/** |
||||
* 协议类型 |
||||
*/ |
||||
HTTP("http://", "http"), |
||||
HTTPS("https://", "https"); |
||||
|
||||
private final String format; |
||||
private final String prefix; |
||||
|
||||
Protocol(String format, String prefix) { |
||||
this.format = format; |
||||
this.prefix = prefix; |
||||
} |
||||
|
||||
public String getFormat() { |
||||
return format; |
||||
} |
||||
|
||||
public String getPrefix() { |
||||
return prefix; |
||||
} |
||||
} |
@ -0,0 +1,211 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.constants.ErrorCode; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
/** |
||||
* 统一异常处理器 |
||||
* 1** 信息,服务器收到请求,需要请求者继续执行操作 |
||||
* 2** 成功,操作被成功接收并处理 |
||||
* 3** 重定向,需要进一步的操作以完成请求 |
||||
* 4** 客户端错误,请求包含语法错误或无法完成请求 |
||||
* 5** 服务器错误,服务器在处理请求的过程中发生了错误 |
||||
* <p> |
||||
* 1开头的状态码 |
||||
* 100 Continue 继续。客户端应继续其请求 |
||||
* 101 Switching Protocols 切换协议。服务器根据客户端的请求切换协议。只能切换到更高级的协议,例如,切换到HTTP的新版本协议 |
||||
* <p> |
||||
* 2开头的状态码 |
||||
* 200 OK 请求成功。一般用于GET与POST请求 |
||||
* 201 Created 已创建。成功请求并创建了新的资源 |
||||
* 202 Accepted 已接受。已经接受请求,但未处理完成 |
||||
* 203 Non-Authoritative Information 非授权信息。请求成功。但返回的meta信息不在原始的服务器,而是一个副本 |
||||
* 204 No Content 无内容。服务器成功处理,但未返回内容。在未更新网页的情况下,可确保浏览器继续显示当前文档 |
||||
* 205 Reset Content 重置内容。服务器处理成功,用户终端(例如:浏览器)应重置文档视图。可通过此返回码清除浏览器的表单域 |
||||
* 206 Partial Content 部分内容。服务器成功处理了部分GET请求 |
||||
* <p> |
||||
* 3开头的状态码 |
||||
* 300 Multiple Choices 多种选择。请求的资源可包括多个位置,相应可返回一个资源特征与地址的列表用于用户终端(例如:浏览器)选择 |
||||
* 301 Moved Permanently 永久移动。请求的资源已被永久的移动到新URI,返回信息会包括新的URI,浏览器会自动定向到新URI。今后任何新的请求都应使用新的URI代替 |
||||
* 302 Found 临时移动。与301类似。但资源只是临时被移动。客户端应继续使用原有URI |
||||
* 303 See Other 查看其它地址。与301类似。使用GET和POST请求查看 |
||||
* 304 Not Modified 未修改。所请求的资源未修改,服务器返回此状态码时,不会返回任何资源。客户端通常会缓存访问过的资源,通过提供一个头信息指出客户端希望只返回在指定日期之后修改的资源 |
||||
* 305 Use Proxy 使用代理。所请求的资源必须通过代理访问 |
||||
* 306 Unused 已经被废弃的HTTP状态码 |
||||
* 307 Temporary Redirect 临时重定向。与302类似。使用GET请求重定向 |
||||
* <p> |
||||
* 4开头的状态码 |
||||
* 400 Bad Request 客户端请求的语法错误,服务器无法理解 |
||||
* 401 Unauthorized 请求要求用户的身份认证 |
||||
* 402 Payment Required 保留,将来使用 |
||||
* 403 Forbidden 服务器理解请求客户端的请求,但是拒绝执行此请求 |
||||
* 404 Not Found 服务器无法根据客户端的请求找到资源(网页)。通过此代码,网站设计人员可设置"您所请求的资源无法找到"的个性页面 |
||||
* 405 Method Not Allowed 客户端请求中的方法被禁止 |
||||
* 406 Not Acceptable 服务器无法根据客户端请求的内容特性完成请求 |
||||
* 407 Proxy Authentication Required 请求要求代理的身份认证,与401类似,但请求者应当使用代理进行授权 |
||||
* 408 Request Time-out 服务器等待客户端发送的请求时间过长,超时 |
||||
* 409 Conflict 服务器完成客户端的PUT请求是可能返回此代码,服务器处理请求时发生了冲突 |
||||
* 410 Gone 客户端请求的资源已经不存在。410不同于404,如果资源以前有现在被永久删除了可使用410代码,网站设计人员可通过301代码指定资源的新位置 |
||||
* 411 Length Required 服务器无法处理客户端发送的不带Content-Length的请求信息 |
||||
* 412 Precondition Failed 客户端请求信息的先决条件错误 |
||||
* 413 Request Entity Too Large 由于请求的实体过大,服务器无法处理,因此拒绝请求。为防止客户端的连续请求,服务器可能会关闭连接。如果只是服务器暂时无法处理,则会包含一个Retry-After的响应信息 |
||||
* 414 Request-URI Too Large 请求的URI过长(URI通常为网址),服务器无法处理 |
||||
* 415 Unsupported Media Type 服务器无法处理请求附带的媒体格式 |
||||
* 416 Requested range not satisfiable 客户端请求的范围无效 |
||||
* 417 Expectation Failed 服务器无法满足Expect的请求头信息 |
||||
* <p> |
||||
* 5开头的状态码 |
||||
* 500 Internal Server Error 服务器内部错误,无法完成请求 |
||||
* 501 Not Implemented 服务器不支持请求的功能,无法完成请求 |
||||
* 502 Bad Gateway 充当网关或代理的服务器,从远端服务器接收到了一个无效的请求 |
||||
* 503 Service Unavailable 由于超载或系统维护,服务器暂时的无法处理客户端的请求。延时的长度可包含在服务器的Retry-After头信息中 |
||||
* 504 Gateway Time-out 充当网关或代理的服务器,未及时从远端服务器获取请求 |
||||
* 505 HTTP Version not supported 服务器不支持请求的HTTP协议的版本,无法完成处理 |
||||
* <p> |
||||
* --- 自定义返回码 --- |
||||
* <p> |
||||
* 主要分类说明: |
||||
* 2**.** 成功,操作被成功接收并处理 |
||||
* 3**.** 需要后续操作,需要进一步的操作以完成请求 |
||||
* 4**.** HTTP请求错误,请求包含语法错误或无法完成请求, |
||||
* 5**.** 平台错误,平台相关组件运行及操作错误。 |
||||
* 6**.** 关系数据库错误,服务器在处理请求的过程中发生了数据SQL操作等底层错误 |
||||
* 600.** JDBC错误,服务器在处理请求的过程中发生了JDBC底层错误。 |
||||
* 601.** JPA错误,服务器在处理请求的过程中发生了JPA错误。 |
||||
* 602.** Hibernate错误,服务器在处理请求的过程中发生了Hibernate操作错误。 |
||||
* 603.** 接口参数Validation错误 |
||||
* <p> |
||||
* 其它内容逐步补充 |
||||
* |
||||
* @author liuh |
||||
*/ |
||||
@Schema(title = "响应结果状态", description = "自定义错误码以及对应的、友好的错误信息") |
||||
public enum ResultErrorCodes { |
||||
|
||||
/** |
||||
* 401.** 未经授权 Unauthorized 请求要求用户的身份认证 |
||||
*/ |
||||
ACCESS_DENIED(ErrorCode.ACCESS_DENIED, "您没有权限,拒绝访问"), |
||||
ACCOUNT_DISABLED(ErrorCode.ACCOUNT_DISABLED, "该账户已经被禁用"), |
||||
ACCOUNT_ENDPOINT_LIMITED(ErrorCode.ACCOUNT_ENDPOINT_LIMITED, "您已经使用其它终端登录,请先退出其它终端"), |
||||
ACCOUNT_EXPIRED(ErrorCode.ACCOUNT_EXPIRED, "该账户已经过期"), |
||||
ACCOUNT_LOCKED(ErrorCode.ACCOUNT_LOCKED, "该账户已经被锁定"), |
||||
BAD_CREDENTIALS(ErrorCode.BAD_CREDENTIALS, "用户名或密码错误"), |
||||
CREDENTIALS_EXPIRED(ErrorCode.CREDENTIALS_EXPIRED, "该账户密码凭证已过期"), |
||||
INVALID_CLIENT(ErrorCode.INVALID_CLIENT, "客户端身份验证失败"), |
||||
INVALID_TOKEN(ErrorCode.INVALID_TOKEN, "提供的访问令牌已过期、吊销、格式错误或无效"), |
||||
INVALID_GRANT(ErrorCode.INVALID_GRANT, "提供的授权授予或刷新令牌无效、已过期或已撤销"), |
||||
UNAUTHORIZED_CLIENT(ErrorCode.UNAUTHORIZED_CLIENT, "客户端无权使用此方法请求授权码或访问令牌"), |
||||
USERNAME_NOT_FOUND(ErrorCode.USERNAME_NOT_FOUND,"用户名或密码错误"), |
||||
SESSION_EXPIRED(ErrorCode.SESSION_EXPIRED,"Session 已过期,请刷新页面后再使用"), |
||||
|
||||
/** |
||||
* 403.** 禁止的请求,与403对应 |
||||
*/ |
||||
INSUFFICIENT_SCOPE(ErrorCode.INSUFFICIENT_SCOPE, "TOKEN权限不足,您需要更高级别的权限"), |
||||
SQL_INJECTION_REQUEST(ErrorCode.SQL_INJECTION_REQUEST, "疑似SQL注入请求"), |
||||
|
||||
/** |
||||
* 405.** 方法不允许 与405对应 |
||||
*/ |
||||
HTTP_REQUEST_METHOD_NOT_SUPPORTED(ErrorCode.HTTP_REQUEST_METHOD_NOT_SUPPORTED, "请求使用的方法类型不支持"), |
||||
|
||||
/** |
||||
* 406.** 不接受的请求,与406对应 |
||||
*/ |
||||
UNSUPPORTED_GRANT_TYPE(ErrorCode.UNSUPPORTED_GRANT_TYPE, "授权服务器不支持授权授予类型"), |
||||
UNSUPPORTED_RESPONSE_TYPE(ErrorCode.UNSUPPORTED_RESPONSE_TYPE, "授权服务器不支持使用此方法获取授权代码或访问令牌"), |
||||
UNSUPPORTED_TOKEN_TYPE(ErrorCode.UNSUPPORTED_TOKEN_TYPE, "授权服务器不支持撤销提供的令牌类型"), |
||||
|
||||
/** |
||||
* 412.* 未经授权 Precondition Failed 客户端请求信息的先决条件错误 |
||||
*/ |
||||
INVALID_REDIRECT_URI(ErrorCode.INVALID_REDIRECT_URI, "OAuth2 URI 重定向的值无效"), |
||||
INVALID_REQUEST(ErrorCode.INVALID_REQUEST, "无效的请求,参数使用错误或无效."), |
||||
INVALID_SCOPE(ErrorCode.INVALID_SCOPE, "授权范围错误"), |
||||
|
||||
/** |
||||
* 415.* Unsupported Media Type 服务器无法处理请求附带的媒体格式 |
||||
*/ |
||||
HTTP_MEDIA_TYPE_NOT_ACCEPTABLE(ErrorCode.HTTP_MEDIA_TYPE_NOT_ACCEPTABLE, "不支持的 Media Type"), |
||||
|
||||
/** |
||||
* 500.* Internal Server Error 服务器内部错误,无法完成请求 |
||||
*/ |
||||
SERVER_ERROR(ErrorCode.SERVER_ERROR, "授权服务器遇到意外情况,无法满足请求"), |
||||
HTTP_MESSAGE_NOT_READABLE_EXCEPTION(ErrorCode.HTTP_MESSAGE_NOT_READABLE_EXCEPTION, "JSON字符串反序列化为实体出错!"), |
||||
ILLEGAL_ARGUMENT_EXCEPTION(ErrorCode.ILLEGAL_ARGUMENT_EXCEPTION, "参数不合法错误,请仔细确认参数使用是否正确。"), |
||||
IO_EXCEPTION(ErrorCode.IO_EXCEPTION, "IO异常"), |
||||
MISSING_SERVLET_REQUEST_PARAMETER_EXCEPTION(ErrorCode.MISSING_SERVLET_REQUEST_PARAMETER_EXCEPTION, "接口参数使用错误或必要参数缺失,请查阅接口文档!"), |
||||
NULL_POINTER_EXCEPTION(ErrorCode.NULL_POINTER_EXCEPTION, "后台代码执行过程中出现了空值"), |
||||
TYPE_MISMATCH_EXCEPTION(ErrorCode.TYPE_MISMATCH_EXCEPTION, "类型不匹配"), |
||||
|
||||
/** |
||||
* 503.* Service Unavailable 由于超载或系统维护,服务器暂时的无法处理客户端的请求。延时的长度可包含在服务器的Retry-After头信息中 |
||||
*/ |
||||
SERVICE_UNAVAILABLE(ErrorCode.SERVICE_UNAVAILABLE, "服务不可用"), |
||||
TEMPORARILY_UNAVAILABLE(ErrorCode.TEMPORARILY_UNAVAILABLE, "由于服务器临时超载或维护,授权服务器当前无法处理该请求"), |
||||
PROVIDER_NOT_FOUND(ErrorCode.PROVIDER_NOT_FOUND, "授权服务器代码逻辑配置错误"), |
||||
COOKIE_THEFT(ErrorCode.COOKIE_THEFT, "Cookie 信息不安全"), |
||||
INVALID_COOKIE(ErrorCode.INVALID_COOKIE, "不可用的 Cookie 信息"), |
||||
|
||||
/** |
||||
* 6*.* 为数据操作相关错误 |
||||
*/ |
||||
METHOD_ARGUMENT_NOT_VALID(ErrorCode.METHOD_ARGUMENT_NOT_VALID, "接口参数校验失败,参数使用错误或者未接收到参数"), |
||||
BAD_SQL_GRAMMAR(ErrorCode.BAD_SQL_GRAMMAR, "低级SQL语法错误,检查SQL能否正常运行或者字段名称是否正确"), |
||||
DATA_INTEGRITY_VIOLATION(ErrorCode.DATA_INTEGRITY_VIOLATION, "该数据正在被其它数据引用,请先删除引用关系,再进行数据删除操作"), |
||||
TRANSACTION_ROLLBACK(ErrorCode.TRANSACTION_ROLLBACK, "数据事务处理失败,数据回滚"), |
||||
|
||||
/** |
||||
* 7*.* 基础设施交互错误 |
||||
* 71.* Redis 操作出现错误 |
||||
* 72.* Cache 操作出现错误 |
||||
*/ |
||||
PIPELINE_INVALID_COMMANDS(71000, "Redis管道包含一个或多个无效命令"); |
||||
|
||||
|
||||
@Schema(title = "结果代码") |
||||
private final int code; |
||||
@Schema(title = "结果信息") |
||||
private final String message; |
||||
|
||||
|
||||
ResultErrorCodes(int code, String message) { |
||||
this.code = code; |
||||
this.message = message; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
} |
@ -0,0 +1,107 @@ |
||||
/* |
||||
* Copyright (c) 2020-2030 liuhung<ov_001@163.com> |
||||
* |
||||
* quafer Engine Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
* quafer Engine 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
||||
* |
||||
* 1.请不要删除和修改根目录下的LICENSE文件。 |
||||
* 2.请不要删除和修改 quafer Engine 源码头部的版权声明。 |
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。 |
||||
* 4.分发源码时候,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://git.liuhung.com/gz/quafer-engine
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权 |
||||
*/ |
||||
|
||||
package com.liuhung.engine.assistant.core.enums; |
||||
|
||||
import com.liuhung.engine.assistant.core.definition.enums.BaseUiEnum; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonValue; |
||||
import com.google.common.collect.ImmutableMap; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <p>Description: 服务器类型 </p> |
||||
* |
||||
* @author : liuh |
||||
* @date : 2022/7/21 16:29 |
||||
*/ |
||||
@Schema(name = "令牌格式") |
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT) |
||||
public enum ServerDevice implements BaseUiEnum<Integer> { |
||||
|
||||
/** |
||||
* enum |
||||
*/ |
||||
PHYSICAL_MACHINE(0, "实体机"), |
||||
VIRTUAL_MACHINE(1, "虚拟机"); |
||||
|
||||
@Schema(title = "枚举值") |
||||
private final Integer value; |
||||
@Schema(name = "文字") |
||||
private final String description; |
||||
|
||||
private static final Map<Integer, ServerDevice> INDEX_MAP = new HashMap<>(); |
||||
private static final List<Map<String, Object>> JSON_STRUCTURE = new ArrayList<>(); |
||||
|
||||
static { |
||||
for (ServerDevice serverDevice : ServerDevice.values()) { |
||||
INDEX_MAP.put(serverDevice.getValue(), serverDevice); |
||||
JSON_STRUCTURE.add(serverDevice.getValue(), |
||||
ImmutableMap.<String, Object>builder() |
||||
.put("value", serverDevice.getValue()) |
||||
.put("key", serverDevice.name()) |
||||
.put("text", serverDevice.getDescription()) |
||||
.put("index", serverDevice.getValue()) |
||||
.build()); |
||||
} |
||||
} |
||||
|
||||
ServerDevice(Integer value, String description) { |
||||
this.value = value; |
||||
this.description = description; |
||||
} |
||||
|
||||
/** |
||||
* 不加@JsonValue,转换的时候转换出完整的对象。 |
||||
* 加了@JsonValue,只会显示相应的属性的值 |
||||
* <p> |
||||
* 不使用@JsonValue @JsonDeserializer类里面要做相应的处理 |
||||
* |
||||
* @return Enum枚举值 |
||||
*/ |
||||
@JsonValue |
||||
@Override |
||||
public Integer getValue() { |
||||
return value; |
||||
} |
||||
|
||||
@Override |
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public static ServerDevice get(Integer index) { |
||||
return INDEX_MAP.get(index); |
||||
} |
||||
|
||||
public static List<Map<String, Object>> getPreprocessedJsonStructure() { |
||||
return JSON_STRUCTURE; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue