Compare commits
158 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
6abc815cdf | |
|
|
c7a226bd4b | |
|
|
d6eb169f32 | |
|
|
f2b99b501d | |
|
|
5b32a0f813 | |
|
|
51a600af70 | |
|
|
2ef1a7840a | |
|
|
dbcf9c8f3a | |
|
|
fff6038c5c | |
|
|
7c46400585 | |
|
|
b952f34719 | |
|
|
58e91a5097 | |
|
|
deff207dd8 | |
|
|
4d7d40696d | |
|
|
00f9391534 | |
|
|
70e42b11fc | |
|
|
bfb61547a3 | |
|
|
ccd7f8b806 | |
|
|
fbc756f8b7 | |
|
|
c03c318b85 | |
|
|
87d75c22a6 | |
|
|
60ecc9f65d | |
|
|
2fde2a25e3 | |
|
|
23ce017844 | |
|
|
0515c78a88 | |
|
|
26e555f881 | |
|
|
5dca15e76a | |
|
|
bc758c2885 | |
|
|
0429233c31 | |
|
|
e3aa51a3ab | |
|
|
a3edb86a49 | |
|
|
6a0fff01b6 | |
|
|
fc7d09ce8b | |
|
|
89968c8e87 | |
|
|
069b7dace7 | |
|
|
5879d8bbe5 | |
|
|
67789af77d | |
|
|
fd196fbaf8 | |
|
|
7c1617337c | |
|
|
d99dac0041 | |
|
|
472e1dc89c | |
|
|
3811266945 | |
|
|
8e829817c5 | |
|
|
c28de1741c | |
|
|
fd3455f173 | |
|
|
766584426d | |
|
|
79b2257a8b | |
|
|
cbe852e290 | |
|
|
a7f5b03e6c | |
|
|
dcdba73994 | |
|
|
960b940b5c | |
|
|
20f589999a | |
|
|
886d918739 | |
|
|
b6510fe9c0 | |
|
|
8e72147362 | |
|
|
b9cf1b3db5 | |
|
|
773f9f4bb1 | |
|
|
488989d9a0 | |
|
|
1ee2c16a48 | |
|
|
c711b0e627 | |
|
|
0878f81361 | |
|
|
c53e4522c1 | |
|
|
12ec7dfcb3 | |
|
|
4494701946 | |
|
|
2621efa6ce | |
|
|
6392775e9a | |
|
|
2c891e5d20 | |
|
|
6e3c92dc48 | |
|
|
24899e1b1f | |
|
|
916736c1ec | |
|
|
705929a713 | |
|
|
5497beff58 | |
|
|
99015efd8e | |
|
|
8af4d7eecc | |
|
|
bfa8c8ea03 | |
|
|
e5a68aab20 | |
|
|
edce20eeca | |
|
|
1ffc0e6070 | |
|
|
2c52227714 | |
|
|
b529059e69 | |
|
|
7b2ea0913f | |
|
|
9a07c28499 | |
|
|
863466a518 | |
|
|
248e15ece1 | |
|
|
c22152ede9 | |
|
|
0b1b233fa2 | |
|
|
a7887857c9 | |
|
|
cac929d71e | |
|
|
ee13e07799 | |
|
|
b543c55b4a | |
|
|
38622f04ee | |
|
|
084c55bd9a | |
|
|
dc6b1b118b | |
|
|
bed9337550 | |
|
|
9f15c5333b | |
|
|
317fc42c6b | |
|
|
a8b211ad21 | |
|
|
555d6ec5d7 | |
|
|
821a9ec736 | |
|
|
780b14187b | |
|
|
ff336cdae0 | |
|
|
f4af008ed1 | |
|
|
dae843fe49 | |
|
|
d6628c52f5 | |
|
|
7fe35252f3 | |
|
|
da121cefee | |
|
|
0782dac6b6 | |
|
|
791ca8b2c8 | |
|
|
1db6e43a25 | |
|
|
0cb9988e20 | |
|
|
2e1907b74d | |
|
|
50b2ca9b44 | |
|
|
2157880905 | |
|
|
beaef36d91 | |
|
|
2ffd0f3183 | |
|
|
9fb37d826c | |
|
|
75dea78c0a | |
|
|
f27a8c8685 | |
|
|
fc62dab895 | |
|
|
ab95bb1d37 | |
|
|
22cdb6862a | |
|
|
a809a8c33d | |
|
|
0cf365e2b3 | |
|
|
6e51235d49 | |
|
|
bb687f9484 | |
|
|
5cfd92cd2f | |
|
|
8ee188c13c | |
|
|
8b30ab68e4 | |
|
|
0440a9f964 | |
|
|
f052b01f07 | |
|
|
4d7285a3d5 | |
|
|
02962158b7 | |
|
|
ff2e36e77a | |
|
|
94342f13dc | |
|
|
54143df3e1 | |
|
|
2667b3d8a0 | |
|
|
54763c8cbd | |
|
|
3d7515ad24 | |
|
|
20b70771e4 | |
|
|
4f6c622e4c | |
|
|
20bc184a9f | |
|
|
b962f822c5 | |
|
|
b7adcf0a0e | |
|
|
06b9c3e1e3 | |
|
|
f194946492 | |
|
|
3be58dce1e | |
|
|
545e66e130 | |
|
|
dab9244249 | |
|
|
c57dbda68a | |
|
|
3ae7e668c2 | |
|
|
93b973a56d | |
|
|
f57165e320 | |
|
|
09a786b2b6 | |
|
|
bcdc66c68a | |
|
|
7d4ade0b37 | |
|
|
587c4f4d48 | |
|
|
79e8f22cd5 | |
|
|
757f3f6f77 |
|
|
@ -0,0 +1,45 @@
|
|||
name: Auto Deploy Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "2.10","2.11" ]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
- name: Cache Maven Repository
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: Build with Maven
|
||||
run: ./mvnw clean install -Dmaven.build.timestamp="$(date "+%Y-%m-%d %H:%M:%S")" -Dmaven.test.skip=true -Pbuild
|
||||
- name: Get Maven project version
|
||||
id: maven-version
|
||||
run: |
|
||||
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Project version: $VERSION"
|
||||
- name: Log in to Aliyun ACR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.cn-shenzhen.aliyuncs.com
|
||||
username: ${{ secrets.ALIYUN_DOCKER_REPO_USERNAME }}
|
||||
password: ${{ secrets.ALIYUN_DOCKER_REPO_PWD }}
|
||||
- name: build and docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./jetlinks-standalone
|
||||
file: ./jetlinks-standalone/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64/v8
|
||||
push: true
|
||||
tags: |
|
||||
registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-community:${{ steps.maven-version.outputs.version }}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# This workflow will build a Java project with Maven
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Pull Request 2.10 with java17
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "2.10","2.11" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 17
|
||||
- name: Cache Maven Repository
|
||||
uses: actions/cache@v4.2.3
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: jetlinks-community-maven-repository
|
||||
- name: Build with Maven
|
||||
run: ./mvnw package -Dmaven.test.skip=true -Pbuild
|
||||
|
|
@ -29,4 +29,5 @@ docker/data
|
|||
!demo-protocol-1.0.jar
|
||||
application-local.yml
|
||||
dev/
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
.java-version
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="JetLinksApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
|
||||
<option name="ACTIVE_PROFILES" value="default,dev,local" />
|
||||
<module name="jetlinks-standalone" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="org.jetlinks.community.standalone.JetLinksApplication" />
|
||||
<option name="VM_PARAMETERS" value="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.scripting/javax.script=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED -XX:+EnableDynamicAgentLoading" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
50
README.md
50
README.md
|
|
@ -1,7 +1,7 @@
|
|||
# JetLinks 物联网基础平台
|
||||
|
||||

|
||||

|
||||

|
||||
[](https://app.codacy.com/gh/jetlinks/jetlinks-community?utm_source=github.com&utm_medium=referral&utm_content=jetlinks/jetlinks-community&utm_campaign=Badge_Grade_Settings)
|
||||
[](https://www.oscs1024.com/project/jetlinks/jetlinks-community?ref=badge_small)
|
||||
[](https://github.com/jetlinks/jetlinks-community)
|
||||
|
|
@ -14,10 +14,9 @@
|
|||
[](https://qm.qq.com/cgi-bin/qm/qr?k=IMas2cH-TNsYxUcY8lRbsXqPnA2sGHYQ&jump_from=webapi)
|
||||
[](https://qm.qq.com/cgi-bin/qm/qr?k=LGf0OPQqvLGdJIZST3VTcypdVWhdfAOG&jump_from=webapi)
|
||||
|
||||
JetLinks 基于Java8,Spring Boot 2.x,WebFlux,Netty,Vert.x,Reactor等开发,
|
||||
JetLinks 2.1x 基于Java 17,Spring Boot 3.x,WebFlux,Netty,Vert.x,Reactor等开发,
|
||||
是一个开箱即用,可二次开发的企业级物联网基础平台。平台实现了物联网相关的众多基础功能,
|
||||
能帮助你快速建立物联网相关业务系统。
|
||||
|
||||
|
||||
## 核心特性
|
||||
|
||||
|
|
@ -25,25 +24,35 @@ JetLinks 基于Java8,Spring Boot 2.x,WebFlux,Netty,Vert.x,Reactor等开发,
|
|||
|
||||
全部源代码开放,可自由拓展功能,不再受制于人.前后端分离,接口全开放。
|
||||
|
||||
#### 部署简单
|
||||
|
||||
最小化运行仅需要`java 17`,`redis`,`timescaledb`即可,无需部署大量中间件。
|
||||
|
||||
#### 统一设备接入,海量设备管理
|
||||
|
||||
TCP/UDP/MQTT/HTTP、TLS/DTLS、不同厂商、不同设备、不同报文、统一接入,统一管理。
|
||||
|
||||
#### 规则引擎
|
||||
|
||||
灵活的规则模型配置,支持多种规则模型以及自定义规则模型. 设备告警,场景联动,均由统一的规则引擎管理。
|
||||
|
||||
#### 数据权限控制
|
||||
|
||||
灵活的非侵入数据权限控制。可实现菜单、按钮、数据三维维度的数据权限控制。可控制单条数据的操作权限。
|
||||
|
||||
## 技术栈
|
||||
|
||||
1. [Spring Boot 2.7.x](https://spring.io/projects/spring-boot)
|
||||
1. [Spring Boot 3.4.x](https://spring.io/projects/spring-boot)
|
||||
2. [Spring WebFlux](https://spring.io/) 响应式Web支持
|
||||
3. [R2DBC](https://r2dbc.io/) 响应式关系型数据库驱动
|
||||
4. [Project Reactor](https://projectreactor.io/) 响应式编程框架
|
||||
4. [Netty](https://netty.io/),[Vert.x](https://vertx.io/) 高性能网络编程框架
|
||||
5. [ElasticSearch](https://www.elastic.co/cn/products/enterprise-search) 全文检索,日志,时序数据存储
|
||||
6. [PostgreSQL](https://www.postgresql.org) 业务功能数据管理
|
||||
7. [hsweb framework 4](https://github.com/hs-web) 业务功能基础框架
|
||||
5. [Netty](https://netty.io/),[Vert.x](https://vertx.io/) 高性能网络编程框架
|
||||
6. [hsweb framework 4](https://github.com/hs-web) 业务功能基础框架
|
||||
7. [ElasticSearch](https://www.elastic.co/cn/products/enterprise-search) 全文检索,日志,时序数据存储 (可选)
|
||||
8. [TDengine](https://www.taosdata.com/) 设备时序数据存储(可选)
|
||||
9. [Redis](https://redis.io/) 缓存数据
|
||||
10. [TimescaleDB](https://www.timescale.com/) 时序数据存储(可选)
|
||||
11. [PostgreSQL](https://www.postgresql.org) 业务功能数据管理
|
||||
|
||||
## 架构
|
||||
|
||||
|
|
@ -59,7 +68,7 @@ TCP/UDP/MQTT/HTTP、TLS/DTLS、不同厂商、不同设备、不同报文、统
|
|||
--jetlinks-community
|
||||
------|----docker
|
||||
------|------|----dev-env # 启动开发环境
|
||||
------|------|----run-all # 启动全部,通过http://localhost:9000 访问系统.
|
||||
------|------|----run-all # 启动全部,通过http://localhost:8848 访问系统.
|
||||
------|----jetlinks-components # 公共组件模块
|
||||
------|-------|----common-component # 通用组件.
|
||||
------|-------|----configuration-component # 通用配置.
|
||||
|
|
@ -90,22 +99,20 @@ TCP/UDP/MQTT/HTTP、TLS/DTLS、不同厂商、不同设备、不同报文、统
|
|||
------|----simulator # 设备模拟器
|
||||
```
|
||||
|
||||
|
||||
## 服务支持
|
||||
|
||||
我们提供了各种服务方式帮助您深入了解物联网平台和代码,通过产品文档、技术交流群、付费教学等方式,你将获得如下服务:
|
||||
|
||||
|
||||
| 服务项 | 服务内容 | 服务收费 | 服务方式 |
|
||||
|-----------|-----------------|--------|-------------|
|
||||
| 基础问题答疑 | 问题答疑 | 免费 | 技术交流群支持 [](https://qm.qq.com/cgi-bin/qm/qr?k=jiirLiyFUecy_gsankzVQ-cl6SrZCnv9&&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=Gj47w9kg7TlV5ceD5Bqew_M_O0PIjh_l&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=K5m27CkhDn3B_Owr-g6rfiTBC5DKEY59&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=IMas2cH-TNsYxUcY8lRbsXqPnA2sGHYQ&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=LGf0OPQqvLGdJIZST3VTcypdVWhdfAOG&jump_from=webapi) |
|
||||
| 系统部署 | 系统部署 | 免费 | 文档自助。[源码部署](https://hanta.yuque.com/px7kg1/yfac2l/vvoa3u2ztymtp4oh) [Docker部署](https://hanta.yuque.com/px7kg1/yfac2l/mzq23z4iey5ev1a5) |
|
||||
| 产品使用 | 教学产品各功能使用 | 免费 | 文档自助。[产品文档](https://hanta.yuque.com/px7kg1/yfac2l) |
|
||||
| 二次开发 | 教学平台源码开发过程、工具使用等;| 免费 | 文档自助。[开发文档](https://hanta.yuque.com/px7kg1/dev) |
|
||||
| 系统部署 | 在客户指定的网络和硬件环境中完成社区版服务部署;提供**模拟**设备接入到平台中,并能完成正常设备上线、数据上下行 | 199元 | 线上部署支持 |
|
||||
| 技术支持 | 提供各类部署、功能使用中遇到的问题答疑 | 100元 | 半小时内 线上远程支持|
|
||||
| 设备接入协议开发 | 根据提供的设备型号,编写并提供接入平台协议包的源码。| 3000+元 | 定制化开发 |
|
||||
| 其他服务 | 企业版源码购买;定制化开发;定制化时长、功能服务等 | 面议 | 面议 |
|
||||
| 服务项 | 服务内容 | 服务收费 | 服务方式 |
|
||||
|----------|-----------------------------------------------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 基础问题答疑 | 问题答疑 | 免费 | 技术交流群支持 [](https://qm.qq.com/cgi-bin/qm/qr?k=jiirLiyFUecy_gsankzVQ-cl6SrZCnv9&&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=Gj47w9kg7TlV5ceD5Bqew_M_O0PIjh_l&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=K5m27CkhDn3B_Owr-g6rfiTBC5DKEY59&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=IMas2cH-TNsYxUcY8lRbsXqPnA2sGHYQ&jump_from=webapi) [](https://qm.qq.com/cgi-bin/qm/qr?k=LGf0OPQqvLGdJIZST3VTcypdVWhdfAOG&jump_from=webapi) |
|
||||
| 系统部署 | 系统部署 | 免费 | 文档自助。[源码部署](https://hanta.yuque.com/px7kg1/yfac2l/vvoa3u2ztymtp4oh) [Docker部署](https://hanta.yuque.com/px7kg1/yfac2l/mzq23z4iey5ev1a5) |
|
||||
| 产品使用 | 教学产品各功能使用 | 免费 | 文档自助。[产品文档](https://hanta.yuque.com/px7kg1/yfac2l) |
|
||||
| 二次开发 | 教学平台源码开发过程、工具使用等; | 免费 | 文档自助。[开发文档](https://hanta.yuque.com/px7kg1/dev) |
|
||||
| 系统部署 | 在客户指定的网络和硬件环境中完成社区版服务部署;提供**模拟**设备接入到平台中,并能完成正常设备上线、数据上下行 | 199元 | 线上部署支持 |
|
||||
| 技术支持 | 提供各类部署、功能使用中遇到的问题答疑 | 100元 | 半小时内 线上远程支持 |
|
||||
| 设备接入协议开发 | 根据提供的设备型号,编写并提供接入平台协议包的源码。 | 3000+元 | 定制化开发 |
|
||||
| 其他服务 | 企业版源码购买;定制化开发;定制化时长、功能服务等 | 面议 | 面议 |
|
||||
|
||||
### **付费**服务支持或商务合作请联系
|
||||
|
||||
|
|
@ -113,7 +120,6 @@ TCP/UDP/MQTT/HTTP、TLS/DTLS、不同厂商、不同设备、不同报文、统
|
|||
|
||||
## 文档
|
||||
|
||||
|
||||
[产品文档](https://hanta.yuque.com/px7kg1/yfac2l)
|
||||
[快速开始](https://hanta.yuque.com/px7kg1/yfac2l/raspyc4p1asfuxks)
|
||||
[开发文档](https://hanta.yuque.com/px7kg1/nn1gdr)
|
||||
|
|
|
|||
|
|
@ -1,50 +1,24 @@
|
|||
version: '2'
|
||||
services:
|
||||
redis:
|
||||
image: redis:5.0.4
|
||||
container_name: jetlinks-ce-redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- "./data/redis:/data"
|
||||
command: redis-server --appendonly yes
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
elasticsearch:
|
||||
image: elasticsearch:6.8.11
|
||||
container_name: jetlinks-ce-elasticsearch
|
||||
environment:
|
||||
ES_JAVA_OPTS: -Djava.net.preferIPv4Stack=true -Xms1g -Xmx1g
|
||||
transport.host: 0.0.0.0
|
||||
discovery.type: single-node
|
||||
bootstrap.memory_lock: "true"
|
||||
discovery.zen.minimum_master_nodes: 1
|
||||
discovery.zen.ping.unicast.hosts: elasticsearch
|
||||
ports:
|
||||
- "9200:9200"
|
||||
- "9300:9300"
|
||||
kibana:
|
||||
image: kibana:6.8.11
|
||||
container_name: jetlinks-ce-kibana
|
||||
environment:
|
||||
ELASTICSEARCH_URL: http://elasticsearch:9200
|
||||
links:
|
||||
- elasticsearch:elasticsearch
|
||||
ports:
|
||||
- "5601:5601"
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
postgres:
|
||||
image: postgres:11-alpine
|
||||
container_name: jetlinks-ce-postgres
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- "./data/pg:/var/lib/postgresql/data"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: jetlinks
|
||||
POSTGRES_DB: jetlinks
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
postgres-volume:
|
||||
redis-volume:
|
||||
redis:
|
||||
image: redis:6
|
||||
container_name: jetlinks-ce-redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- "./data/redis:/data"
|
||||
command: redis-server --appendonly yes
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
postgres:
|
||||
image: timescale/timescaledb:latest-pg16
|
||||
container_name: jetlinks-postgres-16
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- "./data/postgres:/var/lib/postgresql/data"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: jetlinks
|
||||
POSTGRES_DB: jetlinks
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
TZ: Asia/Shanghai
|
||||
|
|
@ -0,0 +1 @@
|
|||
data
|
||||
|
|
@ -1,116 +1,92 @@
|
|||
version: '2'
|
||||
version: '3'
|
||||
services:
|
||||
redis:
|
||||
image: redis:5.0.4
|
||||
container_name: jetlinks-ce-redis
|
||||
# ports:
|
||||
# - "6379:6379"
|
||||
volumes:
|
||||
- "./data/redis:/data"
|
||||
command: redis-server --appendonly yes --requirepass "JetLinks@redis"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
elasticsearch:
|
||||
image: elasticsearch:6.8.11
|
||||
container_name: jetlinks-ce-elasticsearch
|
||||
environment:
|
||||
ES_JAVA_OPTS: -Djava.net.preferIPv4Stack=true -Xms1g -Xmx1g
|
||||
transport.host: 0.0.0.0
|
||||
discovery.type: single-node
|
||||
bootstrap.memory_lock: "true"
|
||||
discovery.zen.minimum_master_nodes: 1
|
||||
discovery.zen.ping.unicast.hosts: elasticsearch
|
||||
# volumes:
|
||||
# - ./data/elasticsearch:/usr/share/elasticsearch/data
|
||||
# ports:
|
||||
# - "9200:9200"
|
||||
# - "9300:9300"
|
||||
kibana:
|
||||
image: kibana:6.8.11
|
||||
container_name: jetlinks-ce-kibana
|
||||
environment:
|
||||
ELASTICSEARCH_URL: http://elasticsearch:9200
|
||||
links:
|
||||
- elasticsearch:elasticsearch
|
||||
ports:
|
||||
- "5601:5601"
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
postgres:
|
||||
image: postgres:11-alpine
|
||||
container_name: jetlinks-ce-postgres
|
||||
volumes:
|
||||
- "./data/postgres:/var/lib/postgresql/data"
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: jetlinks
|
||||
POSTGRES_DB: jetlinks
|
||||
TZ: Asia/Shanghai
|
||||
ui:
|
||||
image: registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:2.3.0-SNAPSHOT
|
||||
container_name: jetlinks-ce-ui
|
||||
ports:
|
||||
- 9000:80
|
||||
environment:
|
||||
- "API_BASE_PATH=http://jetlinks:8848/" #API根路径
|
||||
volumes:
|
||||
- "./data/jetlinks-ui:/usr/share/nginx/html/upload"
|
||||
links:
|
||||
- jetlinks:jetlinks
|
||||
jetlinks:
|
||||
image: registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-community:2.3.0-SNAPSHOT
|
||||
container_name: jetlinks-ce
|
||||
redis:
|
||||
image: redis:6
|
||||
container_name: jetlinks-ce-redis
|
||||
# ports:
|
||||
# - "6379:6379" # 仅供jetlinks-ce访问
|
||||
volumes:
|
||||
- "./data/redis:/data"
|
||||
command: redis-server --appendonly yes --requirepass "JetLinks@redis"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
healthcheck:
|
||||
test: [ "CMD", "redis-cli", "-h", "localhost", "-p", "6379", "-a", "JetLinks@redis", "ping" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
postgres:
|
||||
image: timescale/timescaledb:latest-pg16
|
||||
container_name: jetlinks-ce-postgres
|
||||
# ports:
|
||||
# - "5432:5432" # 仅供jetlinks-ce访问
|
||||
volumes:
|
||||
- "./data/postgres:/var/lib/postgresql/data"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: JetLinks@postgres
|
||||
POSTGRES_DB: jetlinks
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
TZ: Asia/Shanghai
|
||||
healthcheck:
|
||||
test: [ "CMD", "pg_isready", "-U", "postgres" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
jetlinks:
|
||||
image: registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-community:2.11.0-SNAPSHOT
|
||||
container_name: jetlinks-ce
|
||||
ports:
|
||||
- "8848:8848" # 平台访问端口
|
||||
- "1883-1890:1883-1890" # 预留
|
||||
- "8800-8810:8800-8810" # 预留
|
||||
- "5060-5061:5060-5061" # 预留
|
||||
volumes:
|
||||
- "./data/jetlinks:/application/data"
|
||||
environment:
|
||||
- "JAVA_OPTS=-Duser.language=zh"
|
||||
- "TZ=Asia/Shanghai"
|
||||
- "EXTERNAL_HOST=local-host.cn" # 对外提供访问的域名或者ip地址
|
||||
- "EXTERNAL_PORT=8848" # 对外提供访问的端口,修改了端口映射同时也需要修改这里.
|
||||
- "ADMIN_USER_PASSWORD=JetLinks.C0mmVn1ty" # admin用户的初始密码
|
||||
- "spring.r2dbc.url=r2dbc:postgresql://postgres:5432/jetlinks" #数据库连接地址
|
||||
- "spring.r2dbc.username=postgres"
|
||||
- "spring.r2dbc.password=JetLinks@postgres"
|
||||
- "spring.data.redis.host=redis"
|
||||
- "spring.data.redis.port=6379"
|
||||
- "file.manager.storage-base-path=/application/data/files"
|
||||
- "spring.data.redis.password=JetLinks@redis"
|
||||
- "logging.level.io.r2dbc=warn"
|
||||
- "logging.level.org.springframework.data=warn"
|
||||
- "logging.level.org.springframework=warn"
|
||||
- "logging.level.org.jetlinks=warn"
|
||||
- "logging.level.org.hswebframework=warn"
|
||||
- "logging.level.org.springframework.data.r2dbc.connectionfactory=warn"
|
||||
- "network.resources[0]=0.0.0.0:8800-8810/tcp"
|
||||
- "network.resources[1]=0.0.0.0:1883-1890"
|
||||
- "hsweb.cors.enable=true"
|
||||
- "hsweb.cors.configs[0].path=/**"
|
||||
- "hsweb.cors.configs[0].allowed-credentials=true"
|
||||
- "hsweb.cors.configs[0].allowed-headers=*"
|
||||
- "hsweb.cors.configs[0].allowed-origins=*"
|
||||
- "hsweb.cors.configs[0].allowed-methods[0]=GET"
|
||||
- "hsweb.cors.configs[0].allowed-methods[1]=POST"
|
||||
- "hsweb.cors.configs[0].allowed-methods[2]=PUT"
|
||||
- "hsweb.cors.configs[0].allowed-methods[3]=PATCH"
|
||||
- "hsweb.cors.configs[0].allowed-methods[4]=DELETE"
|
||||
- "hsweb.cors.configs[0].allowed-methods[5]=OPTIONS"
|
||||
links:
|
||||
- redis:redis
|
||||
- postgres:postgres
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
# ui: # 如果通过访问内嵌的前端存在问题,可以使用这个镜像
|
||||
# image: registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:2.11.0
|
||||
# ports:
|
||||
# - "9000:9000"
|
||||
# environment:
|
||||
# API_BASE_PATH: "http://jetlinks:8848/"
|
||||
# TZ: Asia/Shanghai
|
||||
|
||||
ports:
|
||||
- "8848:8848" # API端口
|
||||
- "1883-1890:1883-1890" # 预留
|
||||
- "8800-8810:8800-8810" # 预留
|
||||
- "5060-5061:5060-5061" # 预留
|
||||
volumes:
|
||||
- "./data/jetlinks/upload:/application/static/upload"
|
||||
- "./data/jetlinks:/application/data"
|
||||
#entrypoint: /entrypoint.sh -d redis:5601,postgres:5432,elasticsearch:9200 'echo "start jetlinks service here"';
|
||||
environment:
|
||||
# - "SLEEP_SECOND=4"
|
||||
- "JAVA_OPTS=-Duser.language=zh -XX:+UseG1GC"
|
||||
- "TZ=Asia/Shanghai"
|
||||
- "hsweb.file.upload.static-location=http://127.0.0.1:8848/upload" #上传的静态文件访问根地址,为ui的地址.
|
||||
- "spring.r2dbc.url=r2dbc:postgresql://postgres:5432/jetlinks" #数据库连接地址
|
||||
- "spring.r2dbc.username=postgres"
|
||||
- "spring.r2dbc.password=jetlinks"
|
||||
- "spring.elasticsearch.uris=elasticsearch:9200"
|
||||
# - "spring.elasticsearch.username=admin"
|
||||
# - "spring.elasticsearch.password=admin"
|
||||
# - "spring.reactor.debug-agent.enabled=false" #设置为false能提升性能
|
||||
- "spring.redis.host=redis"
|
||||
- "spring.redis.port=6379"
|
||||
- "file.manager.storage-base-path=/application/data/files"
|
||||
- "spring.redis.password=JetLinks@redis"
|
||||
- "logging.level.io.r2dbc=warn"
|
||||
- "logging.level.org.springframework.data=warn"
|
||||
- "logging.level.org.springframework=warn"
|
||||
- "logging.level.org.jetlinks=warn"
|
||||
- "logging.level.org.hswebframework=warn"
|
||||
- "logging.level.org.springframework.data.r2dbc.connectionfactory=warn"
|
||||
- "network.resources[0]=0.0.0.0:8800-8810/tcp"
|
||||
- "network.resources[1]=0.0.0.0:1883-1890"
|
||||
- "hsweb.cors.enable=true"
|
||||
- "hsweb.cors.configs[0].path=/**"
|
||||
- "hsweb.cors.configs[0].allowed-credentials=true"
|
||||
- "hsweb.cors.configs[0].allowed-headers=*"
|
||||
- "hsweb.cors.configs[0].allowed-origins=*"
|
||||
- "hsweb.cors.configs[0].allowed-methods[0]=GET"
|
||||
- "hsweb.cors.configs[0].allowed-methods[1]=POST"
|
||||
- "hsweb.cors.configs[0].allowed-methods[2]=PUT"
|
||||
- "hsweb.cors.configs[0].allowed-methods[3]=PATCH"
|
||||
- "hsweb.cors.configs[0].allowed-methods[4]=DELETE"
|
||||
- "hsweb.cors.configs[0].allowed-methods[5]=OPTIONS"
|
||||
links:
|
||||
- redis:redis
|
||||
- postgres:postgres
|
||||
- elasticsearch:elasticsearch
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
- elasticsearch
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>jetlinks-components</artifactId>
|
||||
<groupId>org.jetlinks.community</groupId>
|
||||
<version>2.3.0-SNAPSHOT</version>
|
||||
<version>2.11.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
|
@ -80,9 +80,12 @@
|
|||
<dependency>
|
||||
<groupId>com.cronutils</groupId>
|
||||
<artifactId>cron-utils</artifactId>
|
||||
<version>9.2.0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.el</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.el</artifactId>
|
||||
|
|
@ -95,5 +98,11 @@
|
|||
<artifactId>spring-data-redis</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.expressly</groupId>
|
||||
<artifactId>expressly</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import org.jetlinks.core.config.ConfigKey;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
|
|
@ -37,6 +52,23 @@ public class Interval {
|
|||
|
||||
private String expression;
|
||||
|
||||
public Interval(String expr) {
|
||||
char[] chars = expr.toCharArray();
|
||||
int numIndex = 0;
|
||||
for (char c : expr.toCharArray()) {
|
||||
if (c == '-' || c == '.' || (c >= '0' && c <= '9')) {
|
||||
numIndex++;
|
||||
} else {
|
||||
BigDecimal val = new BigDecimal(chars, 0, numIndex);
|
||||
this.expression = expr.substring(numIndex);
|
||||
this.number = val;
|
||||
}
|
||||
}
|
||||
if (this.expression == null) {
|
||||
throw new IllegalArgumentException("can not parse interval expression:" + expr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (number) + expression;
|
||||
|
|
@ -52,6 +84,11 @@ public class Interval {
|
|||
return of(days, Interval.days);
|
||||
}
|
||||
|
||||
@Generated
|
||||
public static Interval ofWeeks(int weeks) {
|
||||
return of(weeks, Interval.weeks);
|
||||
}
|
||||
|
||||
@Generated
|
||||
public static Interval ofHours(int hours) {
|
||||
return of(hours, Interval.hours);
|
||||
|
|
@ -73,20 +110,7 @@ public class Interval {
|
|||
}
|
||||
|
||||
public static Interval of(String expr) {
|
||||
|
||||
char[] chars = expr.toCharArray();
|
||||
int numIndex = 0;
|
||||
for (char c : expr.toCharArray()) {
|
||||
if (c == '-' || c == '.' || (c >= '0' && c <= '9')) {
|
||||
numIndex++;
|
||||
} else {
|
||||
BigDecimal val = new BigDecimal(chars, 0, numIndex);
|
||||
return new Interval(val, expr.substring(numIndex));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("can not parse interval expression:" + expr);
|
||||
return new Interval(expr);
|
||||
}
|
||||
|
||||
public String getDefaultFormat() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import org.hswebframework.web.exception.I18nSupportException;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
public interface OperationType {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import lombok.Generated;
|
||||
|
|
@ -38,13 +53,6 @@ public interface PropertyConstants {
|
|||
*/
|
||||
Key<List<Map<String, Object>>> relations = Key.of("relations");
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*
|
||||
* @see org.jetlinks.pro.tenant.TenantMember
|
||||
*/
|
||||
Key<List<String>> tenantId = Key.of("tenantId");
|
||||
|
||||
//分组ID
|
||||
Key<List<String>> groupId = Key.of("groupId");
|
||||
|
||||
|
|
@ -71,7 +79,7 @@ public interface PropertyConstants {
|
|||
/**
|
||||
* 设备接入方式
|
||||
*
|
||||
* @see org.jetlinks.pro.gateway.supports.DeviceGatewayProvider#getId
|
||||
* @see org.jetlinks.community.gateway.supports.DeviceGatewayProvider#getId
|
||||
*/
|
||||
Key<String> accessProvider = Key.of("accessProvider");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,22 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import org.jetlinks.community.utils.ConverterUtils;
|
||||
import org.jetlinks.core.config.ConfigKey;
|
||||
import org.jetlinks.core.message.DeviceMessage;
|
||||
import org.jetlinks.core.message.HeaderKey;
|
||||
import org.jetlinks.core.metadata.PropertyMetadata;
|
||||
|
|
@ -56,38 +72,34 @@ public interface PropertyMetadataConstants {
|
|||
* 属性读写模式
|
||||
*/
|
||||
interface AccessMode {
|
||||
String id = "accessMode";
|
||||
String id = "type";
|
||||
|
||||
//读
|
||||
String read = "r";
|
||||
String read = "read";
|
||||
//写
|
||||
String write = "w";
|
||||
String write = "write";
|
||||
//上报
|
||||
String report = "u";
|
||||
String report = "report";
|
||||
|
||||
static boolean isRead(PropertyMetadata property) {
|
||||
return property
|
||||
.getExpand(id)
|
||||
.map(val -> val.toString().contains(read))
|
||||
.orElse(true);
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
static boolean isWrite(PropertyMetadata property) {
|
||||
return property
|
||||
.getExpand(id)
|
||||
.map(val -> val.toString().contains(write))
|
||||
.orElseGet(() -> property
|
||||
.getExpand("readOnly")
|
||||
.map(readOnly -> !CastUtils.castBoolean(readOnly))
|
||||
.orElse(true)
|
||||
);
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
static boolean isReport(PropertyMetadata property) {
|
||||
return property
|
||||
.getExpand(id)
|
||||
.map(val -> val.toString().contains(report))
|
||||
.orElse(true);
|
||||
.orElse(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +107,7 @@ public interface PropertyMetadataConstants {
|
|||
String id = "metrics";
|
||||
|
||||
|
||||
static Map<String,Object> metricsToExpands(List<PropertyMetric> metrics) {
|
||||
static Map<String, Object> metricsToExpands(List<PropertyMetric> metrics) {
|
||||
return Collections.singletonMap(id, metrics);
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +123,7 @@ public interface PropertyMetadataConstants {
|
|||
.getExpand(id)
|
||||
.map(obj -> {
|
||||
for (PropertyMetric propertyMetric : ConverterUtils.convertToList(obj, PropertyMetric::of)) {
|
||||
if(Objects.equals(metric, propertyMetric.getId())){
|
||||
if (Objects.equals(metric, propertyMetric.getId())) {
|
||||
return propertyMetric;
|
||||
}
|
||||
}
|
||||
|
|
@ -120,4 +132,22 @@ public interface PropertyMetadataConstants {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
interface Group {
|
||||
ConfigKey<String> id = ConfigKey.of("groupId", "分组ID", String.class);
|
||||
ConfigKey<String> name = ConfigKey.of("groupName", "分组名称", String.class);
|
||||
|
||||
|
||||
static String getId(PropertyMetadata metadata) {
|
||||
return metadata
|
||||
.getExpand(id)
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
static String getName(PropertyMetadata metadata) {
|
||||
return metadata
|
||||
.getExpand(name)
|
||||
.orElse("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
@ -6,7 +21,7 @@ import org.hswebframework.web.bean.FastBeanCopier;
|
|||
import org.jetlinks.community.utils.ConverterUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import com.cronutils.builder.CronBuilder;
|
||||
|
|
@ -28,8 +43,8 @@ import reactor.core.scheduler.Scheduler;
|
|||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.time.*;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import org.hswebframework.web.bean.FastBeanCopier;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -8,6 +23,6 @@ public class Version {
|
|||
|
||||
private final String edition = "community";
|
||||
|
||||
private final String version = "2.2.0-SNAPSHOT";
|
||||
private final String version = "2.11.0-SNAPSHOT";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.annotation.command;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.authorize;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.authorize;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.authorize;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import org.jetlinks.community.Operation;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
public enum ConsumeStrategy {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
public interface MemoryUsage {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
|
|
@ -370,6 +385,9 @@ public class PersistenceBuffer<T extends Serializable> implements EvictionContex
|
|||
return Mono
|
||||
.fromRunnable(() -> write(data))
|
||||
.subscribeOn(writer)
|
||||
// 切换到parallel线程池,避免浪费writer线程性能。
|
||||
// 但是线程切换本身也是消耗。
|
||||
.publishOn(Schedulers.parallel())
|
||||
.then();
|
||||
}
|
||||
|
||||
|
|
@ -381,6 +399,7 @@ public class PersistenceBuffer<T extends Serializable> implements EvictionContex
|
|||
return Mono
|
||||
.fromRunnable(() -> data.forEach(this::write))
|
||||
.subscribeOn(writer)
|
||||
.publishOn(Schedulers.parallel())
|
||||
.then();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.buffer;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.codec;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,31 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.codec;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.concurrent.FastThreadLocal;
|
||||
import lombok.SneakyThrows;
|
||||
import org.jetlinks.core.utils.SerializeUtils;
|
||||
import org.nustaq.serialization.FSTConfiguration;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Base64;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Serializers {
|
||||
|
||||
|
|
@ -67,5 +88,72 @@ public class Serializers {
|
|||
return DEFAULT;
|
||||
}
|
||||
|
||||
public static String serializeToBase64(Object source) {
|
||||
return Base64.getEncoder().encodeToString(serialize(source));
|
||||
}
|
||||
|
||||
public static Object deserializeFromBase64(String base64) {
|
||||
return deserialize(Base64.getDecoder().decode(base64));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private static final FastThreadLocal<ByteArrayOutputStream>
|
||||
SHARED_STREAM = new FastThreadLocal<ByteArrayOutputStream>() {
|
||||
@Override
|
||||
protected ByteArrayOutputStream initialValue() {
|
||||
return new ByteArrayOutputStream();
|
||||
}
|
||||
};
|
||||
|
||||
@SneakyThrows
|
||||
public static ByteBuf serializeExternal(Externalizable source) {
|
||||
ByteArrayOutputStream outputStream = SHARED_STREAM.get();
|
||||
if (outputStream.size() != 0) {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
}
|
||||
try (ObjectOutput output = getDefault().createOutput(outputStream)) {
|
||||
source.writeExternal(output);
|
||||
output.flush();
|
||||
return Unpooled.wrappedBuffer(outputStream.toByteArray());
|
||||
} finally {
|
||||
outputStream.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static <T extends Externalizable> T deserializeExternal(ByteBuf buffer, Supplier<T> instance) {
|
||||
try (ObjectInput input = getDefault().createInput(new ByteBufInputStream(buffer, true))) {
|
||||
T data = instance.get();
|
||||
data.readExternal(input);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public static byte[] serialize(Object source) {
|
||||
ByteArrayOutputStream outputStream = SHARED_STREAM.get();
|
||||
if (outputStream.size() != 0) {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
}
|
||||
try (ObjectOutput output = getDefault().createOutput(outputStream)) {
|
||||
SerializeUtils.writeObject(source, output);
|
||||
output.flush();
|
||||
return outputStream.toByteArray();
|
||||
} finally {
|
||||
outputStream.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static Object deserialize(byte[] data) {
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(data);
|
||||
try (ObjectInput input = getDefault().createInput(stream)) {
|
||||
return SerializeUtils.readObject(input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command;
|
||||
|
||||
import org.jetlinks.core.command.CommandSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.crud;
|
||||
|
||||
import org.hswebframework.web.crud.service.ReactiveCrudService;
|
||||
|
||||
public interface CrudCommandHandler<T, PK>
|
||||
extends QueryCommandHandler<T, PK>, SaveCommandHandler<T, PK>, DeleteCommandHandler<T, PK> {
|
||||
|
||||
@Override
|
||||
ReactiveCrudService<T, PK> getService();
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.crud;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import org.hswebframework.web.authorization.annotation.SaveAction;
|
||||
import org.hswebframework.web.crud.service.ReactiveCrudService;
|
||||
import org.jetlinks.core.annotation.command.CommandHandler;
|
||||
import org.jetlinks.sdk.server.commons.cmd.DeleteByIdCommand;
|
||||
import org.jetlinks.sdk.server.commons.cmd.DeleteCommand;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface DeleteCommandHandler<T, PK> {
|
||||
|
||||
ReactiveCrudService<T, PK> getService();
|
||||
|
||||
@CommandHandler
|
||||
@SaveAction
|
||||
default Mono<Integer> deleteById(DeleteByIdCommand<Integer> command) {
|
||||
return getService()
|
||||
.deleteById(Flux.fromIterable(
|
||||
Collections2
|
||||
.transform(command.getIdList(),
|
||||
v -> (PK) v)));
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@SaveAction
|
||||
default Mono<Integer> delete(DeleteCommand command) {
|
||||
return command
|
||||
.applyDelete(getService().createDelete())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.crud;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.authorization.annotation.QueryAction;
|
||||
import org.hswebframework.web.crud.service.ReactiveCrudService;
|
||||
import org.jetlinks.core.annotation.command.CommandHandler;
|
||||
import org.jetlinks.sdk.server.commons.cmd.CountCommand;
|
||||
import org.jetlinks.sdk.server.commons.cmd.QueryByIdCommand;
|
||||
import org.jetlinks.sdk.server.commons.cmd.QueryListCommand;
|
||||
import org.jetlinks.sdk.server.commons.cmd.QueryPagerCommand;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface QueryCommandHandler<T, PK> {
|
||||
|
||||
ReactiveCrudService<T, PK> getService();
|
||||
|
||||
@CommandHandler
|
||||
@QueryAction
|
||||
default Flux<T> queryById(QueryByIdCommand<T> command) {
|
||||
return getService()
|
||||
.findById(
|
||||
Collections2.transform(command.getIdList(),
|
||||
v -> (PK) v)
|
||||
);
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@QueryAction
|
||||
default Flux<T> queryList(QueryListCommand<T> command) {
|
||||
return getService().query(command.asQueryParam());
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@QueryAction
|
||||
default Mono<PagerResult<T>> queryPager(QueryPagerCommand<T> command) {
|
||||
return getService().queryPager(command.asQueryParam());
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@QueryAction
|
||||
default Mono<Integer> count(CountCommand command) {
|
||||
return getService().count(command.asQueryParam());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.crud;
|
||||
|
||||
import org.hswebframework.web.authorization.annotation.SaveAction;
|
||||
import org.hswebframework.web.bean.FastBeanCopier;
|
||||
import org.hswebframework.web.crud.service.ReactiveCrudService;
|
||||
import org.jetlinks.core.annotation.command.CommandHandler;
|
||||
import org.jetlinks.sdk.server.commons.cmd.AddCommand;
|
||||
import org.jetlinks.sdk.server.commons.cmd.SaveCommand;
|
||||
import org.jetlinks.sdk.server.commons.cmd.UpdateCommand;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SaveCommandHandler<T, PK> {
|
||||
|
||||
ReactiveCrudService<T, PK> getService();
|
||||
|
||||
default T convertData(Object data) {
|
||||
return FastBeanCopier.copy(data, getService().getRepository().newInstanceNow());
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@SaveAction
|
||||
default Flux<T> save(SaveCommand<T> command) {
|
||||
List<T> data = command.dataList(this::convertData);
|
||||
return getService()
|
||||
.save(data)
|
||||
.thenMany(Flux.fromIterable(data));
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@SaveAction
|
||||
default Flux<T> add(AddCommand<T> command) {
|
||||
List<T> data = command.dataList(this::convertData);
|
||||
return getService()
|
||||
.save(data)
|
||||
.thenMany(Flux.fromIterable(data));
|
||||
}
|
||||
|
||||
@CommandHandler
|
||||
@SaveAction
|
||||
default Mono<Integer> update(UpdateCommand<T> command) {
|
||||
return command
|
||||
.applyUpdate(getService().createUpdate(),
|
||||
this::convertData)
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.register;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.register;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule;
|
||||
|
||||
public interface RuleCommandServices {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule.data;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.command.rule.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
import org.jetlinks.community.ValueObject;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config.entity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config.verification;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.config.web;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.configuration;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
|
@ -13,6 +28,8 @@ import org.hswebframework.web.dict.EnumDict;
|
|||
import org.hswebframework.web.dict.defaults.DefaultItemDefine;
|
||||
import org.jetlinks.community.Interval;
|
||||
import org.jetlinks.community.JvmErrorException;
|
||||
import org.jetlinks.community.command.CommandSupportManagerProvider;
|
||||
import org.jetlinks.community.command.CommandSupportManagerProviders;
|
||||
import org.jetlinks.community.command.register.CommandServiceEndpointRegister;
|
||||
import org.jetlinks.community.config.ConfigManager;
|
||||
import org.jetlinks.community.config.ConfigScopeCustomizer;
|
||||
|
|
@ -20,8 +37,11 @@ import org.jetlinks.community.config.ConfigScopeProperties;
|
|||
import org.jetlinks.community.config.SimpleConfigManager;
|
||||
import org.jetlinks.community.config.entity.ConfigEntity;
|
||||
import org.jetlinks.community.dictionary.DictionaryJsonDeserializer;
|
||||
import org.jetlinks.community.form.type.FieldTypeProvider;
|
||||
import org.jetlinks.community.reactorql.aggregation.InternalAggregationSupports;
|
||||
import org.jetlinks.community.reactorql.function.InternalFunctionSupport;
|
||||
import org.jetlinks.community.reactorql.term.TermTypeSupport;
|
||||
import org.jetlinks.community.reactorql.term.TermTypes;
|
||||
import org.jetlinks.community.reference.DataReferenceManager;
|
||||
import org.jetlinks.community.reference.DataReferenceProvider;
|
||||
import org.jetlinks.community.reference.DefaultDataReferenceManager;
|
||||
|
|
@ -45,6 +65,7 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.ReactiveRedisOperations;
|
||||
|
|
@ -185,15 +206,20 @@ public class CommonConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public BeanPostProcessor globalReactorQlFeatureRegister() {
|
||||
return new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(@Nonnull Object bean, @Nonnull String beanName) throws BeansException {
|
||||
if (bean instanceof Feature) {
|
||||
DefaultReactorQLMetadata.addGlobal(((Feature) bean));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
public ApplicationContextAware staticBeanRegister() {
|
||||
|
||||
return ctx -> {
|
||||
ctx.getBeanProvider(Feature.class)
|
||||
.forEach(DefaultReactorQLMetadata::addGlobal);
|
||||
|
||||
ctx.getBeanProvider(CommandSupportManagerProvider.class)
|
||||
.forEach(CommandSupportManagerProviders::register);
|
||||
|
||||
ctx.getBeanProvider(TermTypeSupport.class)
|
||||
.forEach(TermTypes::register);
|
||||
|
||||
ctx.getBeanProvider(FieldTypeProvider.class)
|
||||
.forEach(provider -> FieldTypeProvider.supports.register(provider.getProvider(), provider));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.configuration;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.configuration;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.configuration;
|
||||
|
||||
import org.jetlinks.community.resource.ui.UiMenuResourceProvider;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import org.hswebframework.web.dict.EnumDict;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.Codec;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import org.hswebframework.ezorm.rdb.metadata.RDBColumnMetadata;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,23 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import org.hswebframework.web.crud.events.EntityEventListenerCustomizer;
|
||||
import org.hswebframework.web.dictionary.entity.DictionaryEntity;
|
||||
import org.hswebframework.web.dictionary.entity.DictionaryItemEntity;
|
||||
import org.hswebframework.web.dictionary.service.DefaultDictionaryItemService;
|
||||
import org.hswebframework.web.dictionary.service.DefaultDictionaryService;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
@ -9,15 +27,22 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@AutoConfiguration
|
||||
public class DictionaryConfiguration {
|
||||
|
||||
|
||||
@Configuration
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass(DefaultDictionaryItemService.class)
|
||||
//@ConditionalOnBean(DefaultDictionaryItemService.class)
|
||||
public static class DictionaryManagerConfiguration {
|
||||
|
||||
@Bean
|
||||
public EntityEventListenerCustomizer dictionaryEntityEventListenerCustomizer() {
|
||||
return configure -> {
|
||||
configure.enable(DictionaryItemEntity.class);
|
||||
configure.enable(DictionaryEntity.class);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DictionaryEventHandler dictionaryEventHandler(DefaultDictionaryItemService service) {
|
||||
|
|
@ -44,5 +69,6 @@ public class DictionaryConfiguration {
|
|||
DefaultDictionaryItemService itemService) {
|
||||
return new DictionaryInitManager(initInfo, defaultDictionaryService, itemService);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
public interface DictionaryConstants {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -7,16 +22,21 @@ import org.hswebframework.web.crud.events.*;
|
|||
import org.hswebframework.web.dictionary.entity.DictionaryEntity;
|
||||
import org.hswebframework.web.dictionary.entity.DictionaryItemEntity;
|
||||
import org.hswebframework.web.dictionary.service.DefaultDictionaryItemService;
|
||||
import org.hswebframework.web.dictionary.service.DefaultDictionaryService;
|
||||
import org.hswebframework.web.exception.BusinessException;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bestfeng
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class DictionaryEventHandler implements EntityEventListenerCustomizer {
|
||||
public class DictionaryEventHandler {
|
||||
|
||||
|
||||
private final DefaultDictionaryItemService itemService;
|
||||
|
||||
|
|
@ -68,28 +88,23 @@ public class DictionaryEventHandler implements EntityEventListenerCustomizer {
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(EntityEventListenerConfigure configure) {
|
||||
configure.enable(DictionaryItemEntity.class);
|
||||
configure.enable(DictionaryEntity.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听字典删除前事件,阻止删除分类标识为系统的字典
|
||||
*
|
||||
* @param event 字典删除前事件
|
||||
*/
|
||||
@EventListener
|
||||
public void handleDictionaryBeforeDelete(EntityBeforeDeleteEvent<DictionaryEntity> event) {
|
||||
event.async(
|
||||
Flux.fromIterable(event.getEntity())
|
||||
.any(dictionary ->
|
||||
StringUtils.equals(dictionary.getClassified(), DictionaryConstants.CLASSIFIED_SYSTEM))
|
||||
.flatMap(any -> {
|
||||
if (any) {
|
||||
return Mono.error(() -> new BusinessException("error.system_dictionary_can_not_delete"));
|
||||
}
|
||||
return Mono.empty();
|
||||
})
|
||||
Flux.fromIterable(event.getEntity())
|
||||
.any(dictionary ->
|
||||
StringUtils.equals(dictionary.getClassified(), DictionaryConstants.CLASSIFIED_SYSTEM))
|
||||
.flatMap(any -> {
|
||||
if (any) {
|
||||
return Mono.error(() -> new BusinessException("error.system_dictionary_can_not_delete"));
|
||||
}
|
||||
return Mono.empty();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import com.fasterxml.jackson.core.JacksonException;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.dictionary;
|
||||
|
||||
import org.hswebframework.web.dict.EnumDict;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.doc;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import org.jetlinks.community.Operation;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import org.jetlinks.core.utils.StringBuilderUtils;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.event;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.form.type;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.form.type;
|
||||
|
||||
import org.hswebframework.ezorm.core.ValueCodec;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.form.type;
|
||||
|
||||
import org.jetlinks.community.spi.Provider;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.form.type;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,24 @@
|
|||
/*
|
||||
* Copyright 2025 JetLinks https://www.jetlinks.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.
|
||||
*/
|
||||
package org.jetlinks.community.lock;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscription;
|
||||
import reactor.core.CoreSubscriber;
|
||||
|
|
@ -19,6 +38,7 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
|||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Slf4j
|
||||
class DefaultReactiveLock implements ReactiveLock {
|
||||
@SuppressWarnings("all")
|
||||
static final AtomicReferenceFieldUpdater<DefaultReactiveLock, LockingSubscriber>
|
||||
|
|
@ -27,8 +47,22 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
|
||||
final Deque<LockingSubscriber<?>> queue = new ConcurrentLinkedDeque<>();
|
||||
|
||||
protected final LockName lockName;
|
||||
|
||||
volatile LockingSubscriber<?> pending;
|
||||
|
||||
static final AtomicIntegerFieldUpdater<DefaultReactiveLock> WIP =
|
||||
AtomicIntegerFieldUpdater.newUpdater(DefaultReactiveLock.class, "wip");
|
||||
|
||||
volatile int wip;
|
||||
|
||||
DefaultReactiveLock(String lockName) {
|
||||
this.lockName = new LockName(lockName);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return queue.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Flux<T> lock(Flux<T> job) {
|
||||
|
|
@ -61,28 +95,34 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
}
|
||||
|
||||
protected void drain() {
|
||||
if (PENDING.get(this) != null) {
|
||||
if (WIP.getAndIncrement(this) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
LockingSubscriber<?> locking;
|
||||
|
||||
for (; ; ) {
|
||||
locking = queue.pollFirst();
|
||||
if (locking == null) {
|
||||
return;
|
||||
do {
|
||||
for (; ; ) {
|
||||
locking = queue.pollFirst();
|
||||
if (locking == null) {
|
||||
break;
|
||||
}
|
||||
if (locking.isDisposed()) {
|
||||
continue;
|
||||
}
|
||||
if (PENDING.compareAndSet(this, null, locking)) {
|
||||
try {
|
||||
locking.subscribe();
|
||||
} catch (Throwable e) {
|
||||
PENDING.compareAndSet(this, locking, null);
|
||||
queue.addLast(locking);
|
||||
}
|
||||
} else {
|
||||
queue.addLast(locking);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (locking.isDisposed()) {
|
||||
continue;
|
||||
}
|
||||
if (PENDING.compareAndSet(this, null, locking)) {
|
||||
//使用单独的线程池来调度,防止参与锁太多导致栈溢出.
|
||||
Schedulers.parallel().schedule(locking::subscribe);
|
||||
} else {
|
||||
queue.addLast(locking);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (WIP.decrementAndGet(this) != 0);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -136,6 +176,12 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
|
||||
@Override
|
||||
public void subscribe(@Nonnull CoreSubscriber<? super T> actual) {
|
||||
if (actual.currentContext().hasKey(main.lockName)) {
|
||||
log.debug("reactive lock {} already locked in current context, skip.", main.lockName);
|
||||
//如果当前上下文已经有锁了,则不再重复注册订阅者
|
||||
source.subscribe(actual);
|
||||
return;
|
||||
}
|
||||
Consumer<CoreSubscriber<? super T>> subscribeCallback = source::subscribe;
|
||||
main.registerSubscriber(actual, subscribeCallback, timeout, timeoutFallback);
|
||||
}
|
||||
|
|
@ -168,6 +214,12 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
|
||||
@Override
|
||||
public void subscribe(@Nonnull CoreSubscriber<? super T> actual) {
|
||||
if (actual.currentContext().hasKey(main.lockName)) {
|
||||
log.debug("reactive lock {} already locked in current context, skip.", main.lockName);
|
||||
//如果当前上下文已经有锁了,则不再重复注册订阅者
|
||||
source.subscribe(actual);
|
||||
return;
|
||||
}
|
||||
Consumer<CoreSubscriber<? super T>> subscribeCallback = source::subscribe;
|
||||
main.registerSubscriber(actual, subscribeCallback, timeout, fallback);
|
||||
}
|
||||
|
|
@ -175,7 +227,7 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
|
||||
}
|
||||
|
||||
static class LockingSubscriber<T> extends BaseSubscriber<T> {
|
||||
static class LockingSubscriber<T> extends BaseSubscriber<T> implements Runnable {
|
||||
protected final DefaultReactiveLock main;
|
||||
protected final CoreSubscriber<? super T> actual;
|
||||
private final Consumer<CoreSubscriber<? super T>> subscriber;
|
||||
|
|
@ -186,6 +238,7 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
AtomicIntegerFieldUpdater.newUpdater(LockingSubscriber.class, "status");
|
||||
|
||||
private volatile int status;
|
||||
private final Context context;
|
||||
|
||||
//初始
|
||||
private static final int INIT = 0;
|
||||
|
|
@ -208,6 +261,11 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
this.main = main;
|
||||
this.subscriber = subscriber;
|
||||
this.timeoutFallback = timeoutFallback;
|
||||
this.context = actual
|
||||
.currentContext()
|
||||
.put(DefaultReactiveLock.class, main)
|
||||
.put(main.lockName, true);
|
||||
|
||||
if (timeout != null) {
|
||||
this.timeoutTask = Schedulers
|
||||
.parallel()
|
||||
|
|
@ -223,8 +281,12 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
if (timeoutFallback != null) {
|
||||
timeoutFallback.subscribe(actual);
|
||||
} else {
|
||||
this.onError(new TimeoutException("Lock timed out"));
|
||||
Operators.error(
|
||||
actual, new TimeoutException("Lock [" + main.lockName + "] timeout")
|
||||
);
|
||||
}
|
||||
} else {
|
||||
main.drain();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -234,15 +296,21 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
timeoutTask.dispose();
|
||||
}
|
||||
subscriber.accept(this);
|
||||
} else {
|
||||
main.drain();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void complete() {
|
||||
if (statusUpdater.compareAndSet(this, INIT, UN_SUB) || statusUpdater.compareAndSet(this, SUB_SOURCE, UN_SUB)) {
|
||||
if (statusUpdater.compareAndSet(this, INIT, UN_SUB)
|
||||
|| statusUpdater.compareAndSet(this, SUB_SOURCE, UN_SUB)) {
|
||||
if (timeoutTask != null && !timeoutTask.isDisposed()) {
|
||||
timeoutTask.dispose();
|
||||
}
|
||||
doComplete();
|
||||
} else {
|
||||
main.drain();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,9 +319,8 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
if (!this.isDisposed()) {
|
||||
this.cancel();
|
||||
}
|
||||
if (PENDING.compareAndSet(main, this, null)) {
|
||||
main.drain();
|
||||
}
|
||||
PENDING.compareAndSet(main, this, null);
|
||||
main.drain();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -289,8 +356,25 @@ class DefaultReactiveLock implements ReactiveLock {
|
|||
@Override
|
||||
@Nonnull
|
||||
public Context currentContext() {
|
||||
return actual.currentContext();
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
protected static class LockName {
|
||||
final String name;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue