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 | 1 | package cn.iocoder.yudao.module.iot.gateway.config; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum; | |
| 3 | 4 | import cn.iocoder.yudao.module.iot.gateway.protocol.coap.IotCoapConfig; |
| 4 | 5 | import cn.iocoder.yudao.module.iot.gateway.protocol.http.IotHttpConfig; |
| 5 | 6 | import cn.iocoder.yudao.module.iot.gateway.protocol.mqtt.IotMqttConfig; |
| ... | ... | @@ -279,7 +280,7 @@ public class IotGatewayProperties { |
| 279 | 280 | * @see cn.iocoder.yudao.module.iot.core.enums.IotProtocolTypeEnum |
| 280 | 281 | */ |
| 281 | 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 | 91 | */ |
| 92 | 92 | @SuppressWarnings({"EnhancedSwitchMigration"}) |
| 93 | 93 | private IotProtocol createProtocol(IotGatewayProperties.ProtocolInstanceProperties config) { |
| 94 | - IotProtocolTypeEnum protocolType = IotProtocolTypeEnum.of(config.getType()); | |
| 94 | + IotProtocolTypeEnum protocolType = IotProtocolTypeEnum.of(config.getProtocol()); | |
| 95 | 95 | if (protocolType == null) { |
| 96 | - log.error("[createProtocol][协议实例 {} 的协议类型 {} 不存在]", config.getId(), config.getType()); | |
| 96 | + log.error("[createProtocol][协议实例 {} 的协议类型 {} 不存在]", config.getId(), config.getProtocol()); | |
| 97 | 97 | return null; |
| 98 | 98 | } |
| 99 | 99 | switch (protocolType) { | ... | ... |
yudao-module-iot/yudao-module-iot-gateway/src/main/resources/application.yaml
| ... | ... | @@ -48,7 +48,7 @@ yudao: |
| 48 | 48 | # 针对引入的 HTTP 组件的配置 |
| 49 | 49 | # ==================================== |
| 50 | 50 | - id: http-json |
| 51 | - type: http | |
| 51 | + protocol: http | |
| 52 | 52 | port: 8092 |
| 53 | 53 | enabled: false |
| 54 | 54 | http: |
| ... | ... | @@ -58,7 +58,7 @@ yudao: |
| 58 | 58 | # ==================================== |
| 59 | 59 | - id: tcp-json |
| 60 | 60 | enabled: false |
| 61 | - type: tcp | |
| 61 | + protocol: tcp | |
| 62 | 62 | port: 8091 |
| 63 | 63 | serialize: json |
| 64 | 64 | tcp: |
| ... | ... | @@ -80,7 +80,7 @@ yudao: |
| 80 | 80 | # ==================================== |
| 81 | 81 | - id: udp-json |
| 82 | 82 | enabled: false |
| 83 | - type: udp | |
| 83 | + protocol: udp | |
| 84 | 84 | port: 8093 |
| 85 | 85 | serialize: json |
| 86 | 86 | udp: |
| ... | ... | @@ -93,7 +93,7 @@ yudao: |
| 93 | 93 | # ==================================== |
| 94 | 94 | - id: websocket-json |
| 95 | 95 | enabled: true |
| 96 | - type: websocket | |
| 96 | + protocol: websocket | |
| 97 | 97 | port: 8094 |
| 98 | 98 | serialize: json |
| 99 | 99 | websocket: |
| ... | ... | @@ -107,7 +107,7 @@ yudao: |
| 107 | 107 | # ==================================== |
| 108 | 108 | - id: coap-json |
| 109 | 109 | enabled: false |
| 110 | - type: coap | |
| 110 | + protocol: coap | |
| 111 | 111 | port: 5683 |
| 112 | 112 | coap: |
| 113 | 113 | max-message-size: 1024 # 最大消息大小(字节) |
| ... | ... | @@ -118,7 +118,7 @@ yudao: |
| 118 | 118 | # ==================================== |
| 119 | 119 | - id: mqtt-json |
| 120 | 120 | enabled: true |
| 121 | - type: mqtt | |
| 121 | + protocol: mqtt | |
| 122 | 122 | port: 1883 |
| 123 | 123 | serialize: json |
| 124 | 124 | mqtt: | ... | ... |