|
|
@ -1,6 +1,7 @@ |
|
|
|
package org.dromara.sample.wayline.controller; |
|
|
|
|
|
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
import jakarta.validation.Valid; |
|
|
@ -36,53 +37,57 @@ import java.util.stream.Collectors; |
|
|
|
* @date 2021/12/22 |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@Tag(name="凭证信息") |
|
|
|
public class WaylineFileController implements IHttpWaylineService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IWaylineFileService waylineFileService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据waylineID删除工作区中的wayline文件。 |
|
|
|
* Delete the wayline file in the workspace according to the wayline id. |
|
|
|
* @param waylineId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@DeleteMapping("${url.wayline.prefix}${url.wayline.version}/workspaces/waylines/{wayline_id}") |
|
|
|
public HttpResultResponse deleteWayline(@PathVariable(name = "wayline_id") String waylineId) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
boolean isDel = waylineFileService.deleteByWaylineId(loginUser.getTenantId(), waylineId); |
|
|
|
@DeleteMapping("${url.wayline.prefix}${url.wayline.version}/workspaces/{workspace_id}/waylines/{wayline_id}") |
|
|
|
public HttpResultResponse deleteWayline(@PathVariable(name = "workspace_id") String workspaceId,@PathVariable(name = "wayline_id") String waylineId) { |
|
|
|
boolean isDel = waylineFileService.deleteByWaylineId(workspaceId, waylineId); |
|
|
|
return isDel ? HttpResultResponse.success() : HttpResultResponse.error("航线删除失败"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入kmz航路文件。 |
|
|
|
* Import kmz wayline files. |
|
|
|
* @param file |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("${url.wayline.prefix}${url.wayline.version}/workspaces/waylines/file/upload") |
|
|
|
public HttpResultResponse importKmzFile(HttpServletRequest request, MultipartFile file) { |
|
|
|
@PostMapping("${url.wayline.prefix}${url.wayline.version}/workspaces/{workspace_id}/waylines/file/upload") |
|
|
|
public HttpResultResponse importKmzFile(@PathVariable(name = "workspace_id") String workspaceId,HttpServletRequest request, MultipartFile file) { |
|
|
|
if (Objects.isNull(file)) { |
|
|
|
return HttpResultResponse.error("No file received."); |
|
|
|
return HttpResultResponse.error("未收到文件。"); |
|
|
|
} |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
String creator = loginUser.getUsername(); |
|
|
|
waylineFileService.importKmzFile(file, loginUser.getTenantId(), creator); |
|
|
|
waylineFileService.importKmzFile(file, workspaceId, creator); |
|
|
|
return HttpResultResponse.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据查询条件查询路线文件的基本数据。 |
|
|
|
* 试点中的查询条件字段是固定的。 |
|
|
|
* Query the basic data of the wayline file according to the query conditions. |
|
|
|
* The query condition field in pilot is fixed. |
|
|
|
* @param request |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HttpResultResponse<PaginationData<GetWaylineListResponse>> getWaylineList(@Valid GetWaylineListRequest request, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
PaginationData<GetWaylineListResponse> data = waylineFileService.getWaylinesByParam(loginUser.getTenantId(), request); |
|
|
|
public HttpResultResponse<PaginationData<GetWaylineListResponse>> getWaylineList(@Valid GetWaylineListRequest request,String workspaceId, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
PaginationData<GetWaylineListResponse> data = waylineFileService.getWaylinesByParam(workspaceId, request); |
|
|
|
return HttpResultResponse.success(data); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据 wayline 文件 ID 查询文件的下载地址,并直接重定向到此地址进行下载。 |
|
|
|
* Query the download address of the file according to the wayline file id, |
|
|
|
* and redirect to this address directly for download. |
|
|
|
* @param waylineId |
|
|
@ -90,10 +95,9 @@ public class WaylineFileController implements IHttpWaylineService { |
|
|
|
* @param rsp |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void getWaylineFileDownloadAddress( String waylineId, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
public void getWaylineFileDownloadAddress( String workspaceId,String waylineId, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
try { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
URL url = waylineFileService.getObjectUrl(loginUser.getTenantId(), waylineId); |
|
|
|
URL url = waylineFileService.getObjectUrl(workspaceId, waylineId); |
|
|
|
rsp.sendRedirect(url.toString()); |
|
|
|
|
|
|
|
} catch (IOException | SQLException e) { |
|
|
@ -102,27 +106,30 @@ public class WaylineFileController implements IHttpWaylineService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查名称是否已经存在,根据方式名称必须确保方式名称的唯一性。 |
|
|
|
* 当上传路径线时,将调用此接口,并且必须可用。 |
|
|
|
* 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 names |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HttpResultResponse<List<String>> getDuplicatedWaylineName(@NotNull @Size(min = 1) List<String> names, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
List<String> existNamesList = waylineFileService.getDuplicateNames(loginUser.getTenantId(), names); |
|
|
|
public HttpResultResponse<List<String>> getDuplicatedWaylineName(String workspaceId,@NotNull @Size(min = 1) List<String> names, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
List<String> existNamesList = waylineFileService.getDuplicateNames(workspaceId, names); |
|
|
|
|
|
|
|
return HttpResultResponse.success(existNamesList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 当航线文件由飞行员上传到存储服务器时, |
|
|
|
* 通过此接口报告文件的基本信息。 |
|
|
|
* 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 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HttpResultResponse fileUploadResultReport( @Valid WaylineUploadCallbackRequest request, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
public HttpResultResponse fileUploadResultReport(String workspaceId, @Valid WaylineUploadCallbackRequest request, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
|
|
|
|
WaylineUploadCallbackMetadata metadata = request.getMetadata(); |
|
|
@ -136,38 +143,40 @@ public class WaylineFileController implements IHttpWaylineService { |
|
|
|
.droneModelKey(metadata.getDroneModelKey().getDevice()) |
|
|
|
.build(); |
|
|
|
|
|
|
|
int id = waylineFileService.saveWaylineFile(loginUser.getTenantId(), file); |
|
|
|
int id = waylineFileService.saveWaylineFile(workspaceId, file); |
|
|
|
|
|
|
|
return id <= 0 ? HttpResultResponse.error() : HttpResultResponse.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据 wayline 文件 id 收藏 wayline 文件。 |
|
|
|
* Favorite the wayline file according to the wayline file id. |
|
|
|
* @param ids wayline file id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HttpResultResponse batchFavoritesWayline( @NotNull @Size(min = 1) List<String> ids, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
public HttpResultResponse batchFavoritesWayline(String workspaceId, @NotNull @Size(min = 1) List<String> ids, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
boolean isMark = waylineFileService.markFavorite(loginUser.getTenantId(), ids, true); |
|
|
|
boolean isMark = waylineFileService.markFavorite(workspaceId, ids, true); |
|
|
|
|
|
|
|
return isMark ? HttpResultResponse.success() : HttpResultResponse.error(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据 wayline 文件 id 删除该 wayline 文件的收藏夹。 |
|
|
|
* Delete the favorites of this wayline file based on the wayline file id. |
|
|
|
* @param ids wayline file id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HttpResultResponse batchUnfavoritesWayline(@NotNull @Size(min = 1) List<String> ids, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
boolean isMark = waylineFileService.markFavorite(loginUser.getTenantId(), ids, false); |
|
|
|
public HttpResultResponse batchUnfavoritesWayline(String workspaceId,@NotNull @Size(min = 1) List<String> ids, HttpServletRequest req, HttpServletResponse rsp) { |
|
|
|
boolean isMark = waylineFileService.markFavorite(workspaceId, ids, false); |
|
|
|
|
|
|
|
return isMark ? HttpResultResponse.success() : HttpResultResponse.error(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入 kmz wayline 文件。 |
|
|
|
* Import kmz wayline files. |
|
|
|
* @return |
|
|
|
*/ |
|
|
|