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;
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.http.IotHttpConfig;
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
*/
@NotEmpty(message = "协议类型不能为空")
private String type;
private String protocol;
/**
* 服务端口
*/

View File

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

View File

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