Commit d357105d7f8edd1d90b4b42787166c7204180829
1 parent
4f6ee4c5
feat(iot):【协议改造】将 protocols 的 type 字段,改成 protocol 更好理解。
Showing
3 changed files
with
10 additions
and
9 deletions
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/config/IotGatewayProperties.java
| 1 | package cn.iocoder.yudao.module.iot.gateway.config; | 1 | package cn.iocoder.yudao.module.iot.gateway.config; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum; | ||
| 3 | import cn.iocoder.yudao.module.iot.gateway.protocol.coap.IotCoapConfig; | 4 | import cn.iocoder.yudao.module.iot.gateway.protocol.coap.IotCoapConfig; |
| 4 | import cn.iocoder.yudao.module.iot.gateway.protocol.http.IotHttpConfig; | 5 | import cn.iocoder.yudao.module.iot.gateway.protocol.http.IotHttpConfig; |
| 5 | import cn.iocoder.yudao.module.iot.gateway.protocol.mqtt.IotMqttConfig; | 6 | import cn.iocoder.yudao.module.iot.gateway.protocol.mqtt.IotMqttConfig; |
| @@ -279,7 +280,7 @@ public class IotGatewayProperties { | @@ -279,7 +280,7 @@ public class IotGatewayProperties { | ||
| 279 | * @see cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum | 280 | * @see cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum |
| 280 | */ | 281 | */ |
| 281 | @NotEmpty(message = "协议类型不能为空") | 282 | @NotEmpty(message = "协议类型不能为空") |
| 282 | - private String type; | 283 | + private String protocol; |
| 283 | /** | 284 | /** |
| 284 | * 服务端口 | 285 | * 服务端口 |
| 285 | */ | 286 | */ |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/IotProtocolManager.java
| @@ -91,9 +91,9 @@ public class IotProtocolManager implements SmartLifecycle { | @@ -91,9 +91,9 @@ public class IotProtocolManager implements SmartLifecycle { | ||
| 91 | */ | 91 | */ |
| 92 | @SuppressWarnings({"EnhancedSwitchMigration"}) | 92 | @SuppressWarnings({"EnhancedSwitchMigration"}) |
| 93 | private IotProtocol createProtocol(IotGatewayProperties.ProtocolInstanceProperties config) { | 93 | private IotProtocol createProtocol(IotGatewayProperties.ProtocolInstanceProperties config) { |
| 94 | - IotProtocolTypeEnum protocolType = IotProtocolTypeEnum.of(config.getType()); | 94 | + IotProtocolTypeEnum protocolType = IotProtocolTypeEnum.of(config.getProtocol()); |
| 95 | if (protocolType == null) { | 95 | if (protocolType == null) { |
| 96 | - log.error("[createProtocol][协议实例 {} 的协议类型 {} 不存在]", config.getId(), config.getType()); | 96 | + log.error("[createProtocol][协议实例 {} 的协议类型 {} 不存在]", config.getId(), config.getProtocol()); |
| 97 | return null; | 97 | return null; |
| 98 | } | 98 | } |
| 99 | switch (protocolType) { | 99 | switch (protocolType) { |
yudao-module-iot/yudao-module-iot-gateway/src/main/resources/application.yaml
| @@ -48,7 +48,7 @@ yudao: | @@ -48,7 +48,7 @@ yudao: | ||
| 48 | # 针对引入的 HTTP 组件的配置 | 48 | # 针对引入的 HTTP 组件的配置 |
| 49 | # ==================================== | 49 | # ==================================== |
| 50 | - id: http-json | 50 | - id: http-json |
| 51 | - type: http | 51 | + protocol: http |
| 52 | port: 8092 | 52 | port: 8092 |
| 53 | enabled: false | 53 | enabled: false |
| 54 | http: | 54 | http: |
| @@ -58,7 +58,7 @@ yudao: | @@ -58,7 +58,7 @@ yudao: | ||
| 58 | # ==================================== | 58 | # ==================================== |
| 59 | - id: tcp-json | 59 | - id: tcp-json |
| 60 | enabled: false | 60 | enabled: false |
| 61 | - type: tcp | 61 | + protocol: tcp |
| 62 | port: 8091 | 62 | port: 8091 |
| 63 | serialize: json | 63 | serialize: json |
| 64 | tcp: | 64 | tcp: |
| @@ -80,7 +80,7 @@ yudao: | @@ -80,7 +80,7 @@ yudao: | ||
| 80 | # ==================================== | 80 | # ==================================== |
| 81 | - id: udp-json | 81 | - id: udp-json |
| 82 | enabled: false | 82 | enabled: false |
| 83 | - type: udp | 83 | + protocol: udp |
| 84 | port: 8093 | 84 | port: 8093 |
| 85 | serialize: json | 85 | serialize: json |
| 86 | udp: | 86 | udp: |
| @@ -93,7 +93,7 @@ yudao: | @@ -93,7 +93,7 @@ yudao: | ||
| 93 | # ==================================== | 93 | # ==================================== |
| 94 | - id: websocket-json | 94 | - id: websocket-json |
| 95 | enabled: true | 95 | enabled: true |
| 96 | - type: websocket | 96 | + protocol: websocket |
| 97 | port: 8094 | 97 | port: 8094 |
| 98 | serialize: json | 98 | serialize: json |
| 99 | websocket: | 99 | websocket: |
| @@ -107,7 +107,7 @@ yudao: | @@ -107,7 +107,7 @@ yudao: | ||
| 107 | # ==================================== | 107 | # ==================================== |
| 108 | - id: coap-json | 108 | - id: coap-json |
| 109 | enabled: false | 109 | enabled: false |
| 110 | - type: coap | 110 | + protocol: coap |
| 111 | port: 5683 | 111 | port: 5683 |
| 112 | coap: | 112 | coap: |
| 113 | max-message-size: 1024 # 最大消息大小(字节) | 113 | max-message-size: 1024 # 最大消息大小(字节) |
| @@ -118,7 +118,7 @@ yudao: | @@ -118,7 +118,7 @@ yudao: | ||
| 118 | # ==================================== | 118 | # ==================================== |
| 119 | - id: mqtt-json | 119 | - id: mqtt-json |
| 120 | enabled: true | 120 | enabled: true |
| 121 | - type: mqtt | 121 | + protocol: mqtt |
| 122 | port: 1883 | 122 | port: 1883 |
| 123 | serialize: json | 123 | serialize: json |
| 124 | mqtt: | 124 | mqtt: |