diff --git a/README.md b/README.md
index 1821d7241430ccaf1042ce0571ae23be791f70d4..9f195113e4032314ac46a2bcf1d233b3d3c4a290 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ com.mqttsnet.thinglinks
│ └── thinglinks-modules-tdengine // TDengine服务 [19304]
│ └── thinglinks-modules-link // Link服务 [19305]
└── thinglinks-modules-broker // broker服务 [19306]、[MQTT-TCP:11883]、[MQTT-SSL:18443]、[MQTT-WS:18999]
+├── thinglinks-registry // 注册中心微应用
├── thinglinks-visual // 图形化管理模块
│ └── thinglinks-visual-monitor // 监控中心 [19400]
│ └── thinglinks-visual-collection // 服务器监控采集服务 [19401]
@@ -89,6 +90,8 @@ com.mqttsnet.thinglinks
*、设备管理页面展示优化(实现中)
+*、产品管理(后台接口已完成,web实现中)
+
*、设备消息列表(实现中)
*、Docker容器化部署(实现中)
diff --git a/doc/nacos-config/DEFAULT_GROUP/application-dev.yml b/doc/nacos-config/DEFAULT_GROUP/application-dev.yml
index 3e6ca550278f189c76ce938f08b0b80e05b4018f..1c14e8244cb0f937f14726691ce3bdf5f177f963 100644
--- a/doc/nacos-config/DEFAULT_GROUP/application-dev.yml
+++ b/doc/nacos-config/DEFAULT_GROUP/application-dev.yml
@@ -1,5 +1,6 @@
spring:
main:
+ allow-circular-references: true
allow-bean-definition-overriding: true
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
diff --git a/doc/nacos-config/DEFAULT_GROUP/thinglinks-broker-dev.yml b/doc/nacos-config/DEFAULT_GROUP/thinglinks-broker-dev.yml
index a5aaec2017bf6a319f42b9f5106d4301cc2a279e..989b5dddb1015ffbede5f43d39d4b50b32f99893 100644
--- a/doc/nacos-config/DEFAULT_GROUP/thinglinks-broker-dev.yml
+++ b/doc/nacos-config/DEFAULT_GROUP/thinglinks-broker-dev.yml
@@ -73,13 +73,13 @@ seata:
nacos:
serverAddr: 127.0.0.1:8848
group: SEATA_GROUP
- namespace: 1e1aff6c-da73-43e2-9e5f-8e0b890189d9
+ namespace: 8ea40c2e-64ba-4430-9bd8-a25336b2b45a
registry:
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
- namespace: 1e1aff6c-da73-43e2-9e5f-8e0b890189d9
+ namespace: 8ea40c2e-64ba-4430-9bd8-a25336b2b45a
#smqtt官方配置文件V1.1.2
smqtt:
diff --git a/doc/nacos-config/DEFAULT_GROUP/thinglinks-link-dev.yml b/doc/nacos-config/DEFAULT_GROUP/thinglinks-link-dev.yml
index 8b91d290ac24614616002488f5733f11c53b8265..4c80ecd37694f700df5fb5a55125da17e665c5f4 100644
--- a/doc/nacos-config/DEFAULT_GROUP/thinglinks-link-dev.yml
+++ b/doc/nacos-config/DEFAULT_GROUP/thinglinks-link-dev.yml
@@ -23,6 +23,8 @@ spring:
loginUsername: admin
loginPassword: 123456
dynamic:
+ # 开启seata代理
+ seata: true
druid:
initial-size: 5
min-idle: 5
@@ -52,26 +54,6 @@ spring:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
-#kafka
- kafka:
- bootstrap-servers: 127.0.0.1:9092
- producer:
- retries: 0
- batch-size: 16384
- buffer-memory: 33554432
- key-serializer: org.apache.kafka.common.serialization.StringSerializer
- value-serializer: org.apache.kafka.common.serialization.StringSerializer
- properties:
- linger.ms: 1
-
- consumer:
- enable-auto-commit: false
- auto-commit-interval: 100ms
- key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
- value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
- properties:
- session.timeout.ms: 15000
- group-id: thinglinks
# rocketmq地址
rocketmq:
@@ -97,31 +79,30 @@ thinglinks:
# seata配置
seata:
- # 默认关闭,如需启用spring.datasource.dynami.seata需要同时开启
- enabled: false
+ enabled: true
# Seata 应用编号,默认为 ${spring.application.name}
- application-id: ${spring.application.name}
+ application-id: thinglinks-link
# Seata 事务组编号,用于 TC 集群名
- tx-service-group: ${spring.application.name}-group
+ tx-service-group: thinglinks-link-group
# 关闭自动代理
enable-auto-data-source-proxy: false
# 服务配置项
service:
# 虚拟组和分组的映射
vgroup-mapping:
- ruoyi-system-group: default
+ thinglinks-link-group: default
config:
type: nacos
nacos:
serverAddr: 127.0.0.1:8848
group: SEATA_GROUP
- namespace: 1e1aff6c-da73-43e2-9e5f-8e0b890189d9
+ namespace:
registry:
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
- namespace: 1e1aff6c-da73-43e2-9e5f-8e0b890189d9
+ namespace:
# mybatis配置
mybatis:
diff --git a/doc/nacos-config/SEATA_GROUP/seataServer.properties b/doc/nacos-config/SEATA_GROUP/seataServer.properties
new file mode 100644
index 0000000000000000000000000000000000000000..3f6577e37c31ab8b8ebbea51338a4cf34a7ca3cf
--- /dev/null
+++ b/doc/nacos-config/SEATA_GROUP/seataServer.properties
@@ -0,0 +1,15 @@
+service.vgroupMapping.thinglinks-link-group=default
+store.mode=db
+store.db.datasource=druid
+store.db.dbType=mysql
+store.db.driverClassName=com.mysql.jdbc.Driver
+store.db.url=jdbc:mysql://127.0.0.1:3306/thinglinks_seata?useUnicode=true
+store.db.user=thinglinks_seata
+store.db.password=6d5zMnpZ4BNh54Sw
+store.db.minConn=5
+store.db.maxConn=30
+store.db.globalTable=global_table
+store.db.branchTable=branch_table
+store.db.queryLimit=100
+store.db.lockTable=lock_table
+store.db.maxWait=5000
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5b39ce3e7845530a6d2a1a427aaeede456329754..59d29a9a9553363fbec682e354bf4a64284ea36d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -260,6 +260,7 @@
thinglinks-modules
thinglinks-api
thinglinks-common
+ thinglinks-registry
pom
diff --git a/sql/thinglinks_seata_20210128.sql b/sql/thinglinks_seata_20210128.sql
index 1c59c8c63493a5f2eaabd902774684c1009233d9..9b57ab26ba79fb349dcf3464bd68dfdbe81a72d0 100644
--- a/sql/thinglinks_seata_20210128.sql
+++ b/sql/thinglinks_seata_20210128.sql
@@ -1,11 +1,11 @@
-DROP DATABASE IF EXISTS `mqtts_seata`;
+DROP DATABASE IF EXISTS `thinglinks_seata`;
-CREATE DATABASE `mqtts_seata` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
+CREATE DATABASE `thinglinks_seata` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-USE `mqtts_seata`;
+USE `thinglinks_seata`;
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
diff --git a/thinglinks-common/thinglinks-common-redis/src/main/java/com/mqttsnet/thinglinks/common/redis/service/RedisService.java b/thinglinks-common/thinglinks-common-redis/src/main/java/com/mqttsnet/thinglinks/common/redis/service/RedisService.java
index 7110144d15a1b08d6c283f4039b8705ac1c7f963..89106f8d3c3c6fb1a9d32fc369af371ebcaaf285 100644
--- a/thinglinks-common/thinglinks-common-redis/src/main/java/com/mqttsnet/thinglinks/common/redis/service/RedisService.java
+++ b/thinglinks-common/thinglinks-common-redis/src/main/java/com/mqttsnet/thinglinks/common/redis/service/RedisService.java
@@ -1,16 +1,10 @@
package com.mqttsnet.thinglinks.common.redis.service;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.BoundSetOperations;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.data.redis.connection.DataType;
+import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
/**
@@ -242,4 +236,1303 @@ public class RedisService
{
return redisTemplate.keys(pattern);
}
+
+ /** -------------------key相关操作--------------------- */
+
+ /**
+ * 删除key
+ *
+ * @param key
+ */
+ public void delete(String key) {
+ redisTemplate.delete(key);
+ }
+
+ /**
+ * 批量删除key
+ *
+ * @param keys
+ */
+ public void delete(Collection keys) {
+ redisTemplate.delete(keys);
+ }
+
+ /**
+ * 序列化key
+ *
+ * @param key
+ * @return
+ */
+ public byte[] dump(String key) {
+ return redisTemplate.dump(key);
+ }
+
+
+ /**
+ * 设置过期时间
+ *
+ * @param key
+ * @param date
+ * @return
+ */
+ public Boolean expireAt(String key, Date date) {
+ return redisTemplate.expireAt(key, date);
+ }
+
+
+ /**
+ * 将当前数据库的 key 移动到给定的数据库 db 当中
+ *
+ * @param key
+ * @param dbIndex
+ * @return
+ */
+ public Boolean move(String key, int dbIndex) {
+ return redisTemplate.move(key, dbIndex);
+ }
+
+ /**
+ * 移除 key 的过期时间,key 将持久保持
+ *
+ * @param key
+ * @return
+ */
+ public Boolean persist(String key) {
+ return redisTemplate.persist(key);
+ }
+
+ /**
+ * 返回 key 的剩余的过期时间
+ *
+ * @param key
+ * @param unit
+ * @return
+ */
+ public Long getExpire(String key, TimeUnit unit) {
+ return redisTemplate.getExpire(key, unit);
+ }
+
+ /**
+ * 返回 key 的剩余的过期时间
+ *
+ * @param key
+ * @return
+ */
+ public Long getExpire(String key) {
+ return redisTemplate.getExpire(key);
+ }
+
+ /**
+ * 从当前数据库中随机返回一个 key
+ *
+ * @return
+ */
+ public String randomKey() {
+ return (String) redisTemplate.randomKey();
+ }
+
+ /**
+ * 修改 key 的名称
+ *
+ * @param oldKey
+ * @param newKey
+ */
+ public void rename(String oldKey, String newKey) {
+ redisTemplate.rename(oldKey, newKey);
+ }
+
+ /**
+ * 仅当 newkey 不存在时,将 oldKey 改名为 newkey
+ *
+ * @param oldKey
+ * @param newKey
+ * @return
+ */
+ public Boolean renameIfAbsent(String oldKey, String newKey) {
+ return redisTemplate.renameIfAbsent(oldKey, newKey);
+ }
+
+ /**
+ * 返回 key 所储存的值的类型
+ *
+ * @param key
+ * @return
+ */
+ public DataType type(String key) {
+ return redisTemplate.type(key);
+ }
+
+ /** -------------------string相关操作--------------------- */
+
+ /**
+ * 设置指定 key 的值
+ * @param key
+ * @param value
+ */
+ public void set(String key, String value) {
+ redisTemplate.opsForValue().set(key, value);
+ }
+
+ /**
+ * 获取指定 key 的值
+ * @param key
+ * @return
+ */
+ public String get(String key) {
+ return (String) redisTemplate.opsForValue().get(key);
+ }
+
+ /**
+ * 返回 key 中字符串值的子字符
+ * @param key
+ * @param start
+ * @param end
+ * @return
+ */
+ public String getRange(String key, long start, long end) {
+ return redisTemplate.opsForValue().get(key, start, end);
+ }
+
+ /**
+ * 将给定 key 的值设为 value ,并返回 key 的旧值(old value)
+ *
+ * @param key
+ * @param value
+ * @return
+ */
+ public String getAndSet(String key, String value) {
+ return (String) redisTemplate.opsForValue().getAndSet(key, value);
+ }
+
+ /**
+ * 对 key 所储存的字符串值,获取指定偏移量上的位(bit)
+ *
+ * @param key
+ * @param offset
+ * @return
+ */
+ public Boolean getBit(String key, long offset) {
+ return redisTemplate.opsForValue().getBit(key, offset);
+ }
+
+ /**
+ * 批量获取
+ *
+ * @param keys
+ * @return
+ */
+ public List multiGet(Collection keys) {
+ return redisTemplate.opsForValue().multiGet(keys);
+ }
+
+ /**
+ * 设置ASCII码, 字符串'a'的ASCII码是97, 转为二进制是'01100001', 此方法是将二进制第offset位值变为value
+ *
+ * @param key
+ * @param offset
+ * 位置
+ * @param value
+ * 值,true为1, false为0
+ * @return
+ */
+ public boolean setBit(String key, long offset, boolean value) {
+ return redisTemplate.opsForValue().setBit(key, offset, value);
+ }
+
+ /**
+ * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
+ *
+ * @param key
+ * @param value
+ * @param timeout
+ * 过期时间
+ * @param unit
+ * 时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
+ * 秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
+ */
+ public void setEx(String key, String value, long timeout, TimeUnit unit) {
+ redisTemplate.opsForValue().set(key, value, timeout, unit);
+ }
+
+ /**
+ * 只有在 key 不存在时设置 key 的值
+ *
+ * @param key
+ * @param value
+ * @return 之前已经存在返回false,不存在返回true
+ */
+ public boolean setIfAbsent(String key, String value) {
+ return redisTemplate.opsForValue().setIfAbsent(key, value);
+ }
+
+ /**
+ * 用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始
+ *
+ * @param key
+ * @param value
+ * @param offset
+ * 从指定位置开始覆写
+ */
+ public void setRange(String key, String value, long offset) {
+ redisTemplate.opsForValue().set(key, value, offset);
+ }
+
+ /**
+ * 获取字符串的长度
+ *
+ * @param key
+ * @return
+ */
+ public Long size(String key) {
+ return redisTemplate.opsForValue().size(key);
+ }
+
+ /**
+ * 批量添加
+ *
+ * @param maps
+ */
+ public void multiSet(Map maps) {
+ redisTemplate.opsForValue().multiSet(maps);
+ }
+
+ /**
+ * 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
+ *
+ * @param maps
+ * @return 之前已经存在返回false,不存在返回true
+ */
+ public boolean multiSetIfAbsent(Map maps) {
+ return redisTemplate.opsForValue().multiSetIfAbsent(maps);
+ }
+
+ /**
+ * 增加(自增长), 负数则为自减
+ *
+ * @param key
+ * @param increment
+ * @return
+ */
+ public Long incrBy(String key, long increment) {
+ return redisTemplate.opsForValue().increment(key, increment);
+ }
+
+ /**
+ *
+ * @param key
+ * @param increment
+ * @return
+ */
+ public Double incrByFloat(String key, double increment) {
+ return redisTemplate.opsForValue().increment(key, increment);
+ }
+
+ /**
+ * 追加到末尾
+ *
+ * @param key
+ * @param value
+ * @return
+ */
+ public Integer append(String key, String value) {
+ return redisTemplate.opsForValue().append(key, value);
+ }
+
+ /** -------------------hash相关操作------------------------- */
+
+ /**
+ * 获取存储在哈希表中指定字段的值
+ *
+ * @param key
+ * @param field
+ * @return
+ */
+ public Object hGet(String key, String field) {
+ return redisTemplate.opsForHash().get(key, field);
+ }
+
+ /**
+ * 获取所有给定字段的值
+ *
+ * @param key
+ * @return
+ */
+ public Map