From 5d06d78cbf238c383a229f61bf16d3c59051ee9e Mon Sep 17 00:00:00 2001
From: aix <vip_xiaobin810@163.com>
Date: Wed, 14 Aug 2024 20:40:36 +0800
Subject: [PATCH] 拍照录像接口

---
 src/main/java/com/dji/sample/component/mqtt/service/impl/MessageSenderServiceImpl.java |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/dji/sample/component/mqtt/service/impl/MessageSenderServiceImpl.java b/src/main/java/com/dji/sample/component/mqtt/service/impl/MessageSenderServiceImpl.java
index 57718c6..23b265a 100644
--- a/src/main/java/com/dji/sample/component/mqtt/service/impl/MessageSenderServiceImpl.java
+++ b/src/main/java/com/dji/sample/component/mqtt/service/impl/MessageSenderServiceImpl.java
@@ -21,8 +21,8 @@
 
 /**
  * @author sean.zhou
- * @date 2021/11/16
  * @version 0.1
+ * @date 2021/11/16
  */
 @Service
 @Slf4j
@@ -43,6 +43,7 @@
     public void publish(String topic, CommonTopicResponse response) {
         this.publish(topic, 1, response);
     }
+
     public void sendRabbitMQ(String topic, Object data) {
         try {
             if (sendRabbitMQ) {
@@ -139,6 +140,35 @@
     }
 
     @Override
+    public <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid, Long timestamp) {
+        String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.SERVICES_SUF;
+        ServiceReply reply = this.publishWithReply(ServiceReply.class, topic,
+                CommonTopicResponse.builder()
+                        .tid(UUID.randomUUID().toString())
+                        .bid(StringUtils.hasText(bid) ? bid : UUID.randomUUID().toString())
+                        .timestamp(timestamp)
+                        .method(method)
+                        .data(Objects.requireNonNullElse(data, ""))
+                        .build());
+        if (Objects.isNull(clazz)) {
+            return reply;
+        }
+        // put together in "output"
+        if (Objects.nonNull(reply.getInfo())) {
+            reply.setOutput(mapper.convertValue(reply.getInfo(), clazz));
+        }
+        if (Objects.nonNull(reply.getOutput())) {
+            reply.setOutput(mapper.convertValue(reply.getOutput(), clazz));
+        }
+        return reply;
+    }
+
+    @Override
+    public ServiceReply publishServicesTopic(String sn, String method, Object data, String bid, Long timestamp) {
+        return this.publishServicesTopic(null, sn, method, data, bid, timestamp);
+    }
+
+    @Override
     public ServiceReply publishServicesTopic(String sn, String method, Object data, String bid) {
         return this.publishServicesTopic(null, sn, method, data, bid);
     }
@@ -154,7 +184,7 @@
     }
 
     @Override
-    public  <T> ServiceReply<T> publishRequestsTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid) {
+    public <T> ServiceReply<T> publishRequestsTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid) {
         String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.REQUESTS_SUF;
         ServiceReply reply = this.publishWithReply(ServiceReply.class, topic,
                 CommonTopicResponse.builder()

--
Gitblit v1.9.3