Browse Source

获取协议支持的网络协议时去重

zhouhao 5 years ago
parent
commit
a901f6db1e

+ 7 - 6
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/ProtocolSupportController.java

@@ -28,7 +28,7 @@ import reactor.core.publisher.Mono;
 @Authorize
 @Authorize
 @Resource(id = "protocol-supports", name = "协议管理")
 @Resource(id = "protocol-supports", name = "协议管理")
 public class ProtocolSupportController implements
 public class ProtocolSupportController implements
-        ReactiveServiceCrudController<ProtocolSupportEntity, String> {
+    ReactiveServiceCrudController<ProtocolSupportEntity, String> {
 
 
     @Autowired
     @Autowired
     @Getter
     @Getter
@@ -53,7 +53,7 @@ public class ProtocolSupportController implements
     @Authorize(merge = false)
     @Authorize(merge = false)
     public Flux<ProtocolInfo> allProtocols() {
     public Flux<ProtocolInfo> allProtocols() {
         return protocolSupports.getProtocols()
         return protocolSupports.getProtocols()
-                .map(ProtocolInfo::of);
+            .map(ProtocolInfo::of);
     }
     }
 
 
     @GetMapping("/{id}/{transport}/configuration")
     @GetMapping("/{id}/{transport}/configuration")
@@ -61,16 +61,17 @@ public class ProtocolSupportController implements
     @Authorize(merge = false)
     @Authorize(merge = false)
     public Mono<ConfigMetadata> getTransportConfiguration(@PathVariable String id, @PathVariable DefaultTransport transport) {
     public Mono<ConfigMetadata> getTransportConfiguration(@PathVariable String id, @PathVariable DefaultTransport transport) {
         return protocolSupports.getProtocol(id)
         return protocolSupports.getProtocol(id)
-                .flatMap(support -> support.getConfigMetadata(transport));
+            .flatMap(support -> support.getConfigMetadata(transport));
     }
     }
 
 
     @GetMapping("/{id}/transports")
     @GetMapping("/{id}/transports")
     @Authorize(merge = false)
     @Authorize(merge = false)
     public Flux<TransportInfo> getAllTransport(@PathVariable String id) {
     public Flux<TransportInfo> getAllTransport(@PathVariable String id) {
         return protocolSupports
         return protocolSupports
-                .getProtocol(id)
-                .flatMapMany(ProtocolSupport::getSupportedTransport)
-                .map(TransportInfo::of);
+            .getProtocol(id)
+            .flatMapMany(ProtocolSupport::getSupportedTransport)
+            .distinct()
+            .map(TransportInfo::of);
     }
     }
 
 
     @GetMapping("/units")
     @GetMapping("/units")