feat(iot):【协议改造】将 protocols 的 type 字段,改成 protocol 更好理解。

This commit is contained in:
YunaiV
2026-02-03 08:34:34 +08:00
parent 4f6ee4c5eb
commit d357105d7f
3 changed files with 10 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.iot.gateway.config; package cn.iocoder.yudao.module.iot.gateway.config;
import cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum;
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.IotCoapConfig; import cn.iocoder.yudao.module.iot.gateway.protocol.coap.IotCoapConfig;
import cn.iocoder.yudao.module.iot.gateway.protocol.http.IotHttpConfig; import cn.iocoder.yudao.module.iot.gateway.protocol.http.IotHttpConfig;
import cn.iocoder.yudao.module.iot.gateway.protocol.mqtt.IotMqttConfig; import cn.iocoder.yudao.module.iot.gateway.protocol.mqtt.IotMqttConfig;
@@ -279,7 +280,7 @@ public class IotGatewayProperties {
* @see cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum * @see cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum
*/ */
@NotEmpty(message = "协议类型不能为空") @NotEmpty(message = "协议类型不能为空")
private String type; private String protocol;
/** /**
* 服务端口 * 服务端口
*/ */

View File

@@ -91,9 +91,9 @@ public class IotProtocolManager implements SmartLifecycle {
*/ */
@SuppressWarnings({"EnhancedSwitchMigration"}) @SuppressWarnings({"EnhancedSwitchMigration"})
private IotProtocol createProtocol(IotGatewayProperties.ProtocolInstanceProperties config) { private IotProtocol createProtocol(IotGatewayProperties.ProtocolInstanceProperties config) {
IotProtocolTypeEnum protocolType = IotProtocolTypeEnum.of(config.getType()); IotProtocolTypeEnum protocolType = IotProtocolTypeEnum.of(config.getProtocol());
if (protocolType == null) { if (protocolType == null) {
log.error("[createProtocol][协议实例 {} 的协议类型 {} 不存在]", config.getId(), config.getType()); log.error("[createProtocol][协议实例 {} 的协议类型 {} 不存在]", config.getId(), config.getProtocol());
return null; return null;
} }
switch (protocolType) { switch (protocolType) {

View File

@@ -48,7 +48,7 @@ yudao:
# 针对引入的 HTTP 组件的配置 # 针对引入的 HTTP 组件的配置
# ==================================== # ====================================
- id: http-json - id: http-json
type: http protocol: http
port: 8092 port: 8092
enabled: false enabled: false
http: http:
@@ -58,7 +58,7 @@ yudao:
# ==================================== # ====================================
- id: tcp-json - id: tcp-json
enabled: false enabled: false
type: tcp protocol: tcp
port: 8091 port: 8091
serialize: json serialize: json
tcp: tcp:
@@ -80,7 +80,7 @@ yudao:
# ==================================== # ====================================
- id: udp-json - id: udp-json
enabled: false enabled: false
type: udp protocol: udp
port: 8093 port: 8093
serialize: json serialize: json
udp: udp:
@@ -93,7 +93,7 @@ yudao:
# ==================================== # ====================================
- id: websocket-json - id: websocket-json
enabled: true enabled: true
type: websocket protocol: websocket
port: 8094 port: 8094
serialize: json serialize: json
websocket: websocket:
@@ -107,7 +107,7 @@ yudao:
# ==================================== # ====================================
- id: coap-json - id: coap-json
enabled: false enabled: false
type: coap protocol: coap
port: 5683 port: 5683
coap: coap:
max-message-size: 1024 # 最大消息大小(字节) max-message-size: 1024 # 最大消息大小(字节)
@@ -118,7 +118,7 @@ yudao:
# ==================================== # ====================================
- id: mqtt-json - id: mqtt-json
enabled: true enabled: true
type: mqtt protocol: mqtt
port: 1883 port: 1883
serialize: json serialize: json
mqtt: mqtt: