From 435c3e59682795fddaa9663e2f1e8401b90896e9 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sat, 23 Sep 2023 15:29:00 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/main'
---
src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java | 2
src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java | 41 +++++++++++++-------
src/main/java/com/dji/sample/component/websocket/service/impl/SendMessageServiceImpl.java | 12 +++--
src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java | 7 +++
src/main/java/com/dji/sample/component/AuthInterceptor.java | 2 +
5 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/dji/sample/component/AuthInterceptor.java b/src/main/java/com/dji/sample/component/AuthInterceptor.java
index 0d3b8f7..8b5fae8 100644
--- a/src/main/java/com/dji/sample/component/AuthInterceptor.java
+++ b/src/main/java/com/dji/sample/component/AuthInterceptor.java
@@ -21,6 +21,8 @@
public static final String PARAM_TOKEN = "x-auth-token";
+ public static final String WORKSPACE_ID = "workspace-id";
+
public static final String TOKEN_CLAIM = "customClaim";
@Override
diff --git a/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java b/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java
index 05fbd2d..e444d6f 100644
--- a/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java
+++ b/src/main/java/com/dji/sample/component/websocket/config/AuthPrincipalHandler.java
@@ -31,6 +31,7 @@
if (request instanceof ServletServerHttpRequest) {
HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();
String token = servletRequest.getParameter(AuthInterceptor.PARAM_TOKEN);
+ String workspaceId = servletRequest.getParameter(AuthInterceptor.WORKSPACE_ID);
if (!StringUtils.hasText(token)) {
return false;
@@ -42,6 +43,7 @@
}
servletRequest.setAttribute(AuthInterceptor.TOKEN_CLAIM, customClaim.get());
+ servletRequest.setAttribute(AuthInterceptor.WORKSPACE_ID, workspaceId);
return true;
}
return false;
@@ -63,7 +65,10 @@
CustomClaim claim = (CustomClaim) ((ServletServerHttpRequest) request).getServletRequest()
.getAttribute(AuthInterceptor.TOKEN_CLAIM);
- return () -> claim.getWorkspaceId() + "/" + claim.getUserType() + "/" + claim.getId();
+ String workspaceId = (String) ((ServletServerHttpRequest) request).getServletRequest()
+ .getAttribute(AuthInterceptor.WORKSPACE_ID);
+
+ return () -> workspaceId + "/" + claim.getUserType() + "/" + claim.getId();
}
return () -> null;
}
diff --git a/src/main/java/com/dji/sample/component/websocket/service/impl/SendMessageServiceImpl.java b/src/main/java/com/dji/sample/component/websocket/service/impl/SendMessageServiceImpl.java
index a54b97f..ff57dd4 100644
--- a/src/main/java/com/dji/sample/component/websocket/service/impl/SendMessageServiceImpl.java
+++ b/src/main/java/com/dji/sample/component/websocket/service/impl/SendMessageServiceImpl.java
@@ -62,12 +62,14 @@
TextMessage data = new TextMessage(mapper.writeValueAsBytes(message));
for (ConcurrentWebSocketSession session : sessions) {
- if (!session.isOpen()) {
- session.close();
- log.debug("This session is closed.");
- return;
+ if (!Objects.isNull(session)) {
+ if (!session.isOpen()) {
+ session.close();
+ log.debug("This session is closed.");
+ return;
+ }
+ session.sendMessage(data);
}
- session.sendMessage(data);
}
} catch (IOException e) {
diff --git a/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java b/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java
index 02e7925..a0070d4 100644
--- a/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java
+++ b/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java
@@ -75,7 +75,7 @@
return RedisOpsUtils.hashKeys(key)
.stream()
.map(SESSIONS::get)
-// .filter(this.getValueWithWorkspace(workspaceId)::contains)
+ .filter(this.getValueWithWorkspace(workspaceId)::contains)
.collect(Collectors.toSet());
}
diff --git a/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java b/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java
index 918835e..49cdad2 100644
--- a/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java
+++ b/src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java
@@ -34,10 +34,10 @@
private IWaylineFileService waylineFileService;
/**
- * Query the basic data of the wayline file according to the query conditions.
- * The query condition field in pilot is fixed.
- * @param orderBy Sorted fields. Spliced at the end of the sql statement.
- * @param favorited Whether the wayline file is favorited or not.
+ * 根据查询条件查询航路线文件的基本数据。
+ * pilot中的查询条件字段是固定的。
+ * @param orderBy 排序的字段。在sql语句的末尾拼接。
+ * @param favorited 路径线文件是否为收藏夹。
* @param page
* @param pageSize
* @param templateType
@@ -62,8 +62,8 @@
}
/**
- * Query the download address of the file according to the wayline file id,
- * and redirect to this address directly for download.
+ * 根据wayline文件id查询文件的下载地址;
+ * 和重定向到此地址直接下载。
* @param workspaceId
* @param waylineId
* @param response
@@ -81,9 +81,22 @@
}
}
+ @GetMapping("/{workspace_id}/waylines/{wayline_id}/urlData")
+ public ResponseResult getFileUrlData(@PathVariable(name = "workspace_id") String workspaceId,
+ @PathVariable(name = "wayline_id") String waylineId, HttpServletResponse response) {
+
+ URL url = null;
+ try {
+ url = waylineFileService.getObjectUrl(workspaceId, waylineId);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return ResponseResult.success(url);
+ }
+
/**
- * When the wayline file is uploaded to the storage server by pilot,
- * the basic information of the file is reported through this interface.
+ * 当航路线文件被飞行员上传到存储服务器时,
+ * 通过该接口报告文件的基本信息。
* @param request
* @param workspaceId
* @param uploadFile
@@ -107,7 +120,7 @@
}
/**
- * Favorite the wayline file according to the wayline file id.
+ * 根据路径线文件id收藏路径线文件。
* @param workspaceId
* @param ids wayline file id
* @return
@@ -121,7 +134,7 @@
}
/**
- * Delete the favorites of this wayline file based on the wayline file id.
+ * 根据航路线文件id删除此航路线文件的收藏夹。
* @param workspaceId
* @param ids wayline file id
* @return
@@ -135,8 +148,8 @@
}
/**
- * Checking whether the name already exists according to the wayline name must ensure the uniqueness of the wayline name.
- * This interface will be called when uploading waylines and must be available.
+ * 根据航路线名称检查名称是否已经存在,必须保证航路线名称的唯一性。
+ * 此接口将在上传航路线时被调用,并且必须可用。
* @param workspaceId
* @param names
* @return
@@ -150,7 +163,7 @@
}
/**
- * Delete the wayline file in the workspace according to the wayline id.
+ * 根据航路线id删除工作区中的航路线文件。
* @param workspaceId
* @param waylineId
* @return
@@ -163,7 +176,7 @@
}
/**
- * Import kmz wayline files.
+ * 上传kmz航线文件
* @param file
* @return
*/
--
Gitblit v1.9.3