wangmengmeng
2024-12-24 24432a361d5c6bd6f3d8c008693e9f1155d62517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.dji.sdk.cloudapi.map.api;
 
import com.dji.sdk.cloudapi.map.CreateMapElementRequest;
import com.dji.sdk.cloudapi.map.CreateMapElementResponse;
import com.dji.sdk.cloudapi.map.GetMapElementsResponse;
import com.dji.sdk.cloudapi.map.UpdateMapElementRequest;
import com.dji.sdk.common.HttpResultResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
 
/**
 * @author sean
 * @version 0.2
 * @date 2021/11/29
 */
@Tag(name = "map interface")
public interface IHttpMapService {
 
    String PREFIX = "map/api/v1";
 
    /**
     * In the first connection, pilot will send out this http request to get the group element list.
     * Also, if pilot receives a group refresh instruction from WebSocket,
     * it needs the same interface to request the group element list.
     * @param workspaceId
     * @param groupId
     * @param isDistributed
     * @param req
     * @param rsp
     * @return
     */
    @Operation(summary = "get map elements", description = "In the first connection, pilot will send out this http " +
            "request to get the group element list. Also, if pilot receives a group refresh instruction from " +
            "WebSocket, it needs the same interface to request the group element list.",
            parameters = {
                    @Parameter(name = "workspace_id", description = "workspace id", schema = @Schema(format = "uuid")),
                    @Parameter(name = "group_id", description = "element group id. The same element group can contain " +
                            "multiple map elements, which is equivalent to grouping map elements. " +
                            "When initiating the request, if the group id parameter is not included, " +
                            "the server needs to return all map elements. If the group id is specified, " +
                            "it only needs to return the set of elements in the specified element group", schema = @Schema(format = "uuid")),
                    @Parameter(name = "is_distributed", description = "Whether the element group is distributed.")
            })
    @GetMapping(PREFIX + "/workspaces/{workspace_id}/element-groups")
    HttpResultResponse<List<GetMapElementsResponse>> getMapElements(
            @PathVariable(name = "workspace_id") String workspaceId,
            @RequestParam(name = "group_id", required = false) String groupId,
            @RequestParam(name = "is_distributed", required = false) Boolean isDistributed,
            HttpServletRequest req, HttpServletResponse rsp);
 
    /**
     * When user draws a point, line or polygon on the PILOT/Web side.
     * @param workspaceId
     * @param groupId
     * @param elementCreate
     * @param req
     * @param rsp
     * @return
     */
    @Operation(summary = "create map element", description = "When user draws a point, line or polygon on the PILOT/Web side.",
            parameters = {
                    @Parameter(name = "workspace_id", description = "workspace id", schema = @Schema(format = "uuid")),
                    @Parameter(name = "group_id", description = "element group id. The same element group can contain " +
                            "multiple map elements, which is equivalent to grouping map elements. " +
                            "When initiating the request, if the group id parameter is not included, " +
                            "the server needs to return all map elements. If the group id is specified, " +
                            "it only needs to return the set of elements in the specified element group", schema = @Schema(format = "uuid"))
            })
    @PostMapping(PREFIX + "/workspaces/{workspace_id}/element-groups/{group_id}/elements")
    HttpResultResponse<CreateMapElementResponse> createMapElement(
            @PathVariable(name = "workspace_id") String workspaceId,
            @PathVariable(name = "group_id") String groupId,
            @Valid @RequestBody CreateMapElementRequest elementCreate,
            HttpServletRequest req, HttpServletResponse rsp);
 
 
    /**
     * When user edits a point, line or polygon on the PILOT/Web side.
     * @param workspaceId
     * @param elementId
     * @param elementUpdate
     * @param req
     * @param rsp
     * @return
     */
    @Operation(summary = "update map element", description = "When user edits a point, line or polygon on the PILOT/Web side.",
            parameters = {
                    @Parameter(name = "workspace_id", description = "workspace id", schema = @Schema(format = "uuid")),
                    @Parameter(name = "element_id", description = "element id", schema = @Schema(format = "uuid"))
            })
    @PutMapping(PREFIX + "/workspaces/{workspace_id}/elements/{element_id}")
    HttpResultResponse updateMapElement(
            @PathVariable(name = "workspace_id") String workspaceId,
            @PathVariable(name = "element_id") String elementId,
            @Valid @RequestBody UpdateMapElementRequest elementUpdate,
            HttpServletRequest req, HttpServletResponse rsp);
 
 
    /**
     * When user delete a point, line or polygon on the PILOT/Web side.
     * @param workspaceId
     * @param elementId
     * @return
     */
    @Operation(summary = "delete map element", description = "When user delete a point, line or polygon on the PILOT/Web side.",
            parameters = {
                    @Parameter(name = "workspace_id", description = "workspace id", schema = @Schema(format = "uuid")),
                    @Parameter(name = "element_id", description = "element id", schema = @Schema(format = "uuid"))
            })
    @DeleteMapping(PREFIX + "/workspaces/{workspace_id}/elements/{element_id}")
    HttpResultResponse deleteMapElement(
            @PathVariable(name = "workspace_id") String workspaceId,
            @PathVariable(name = "element_id") String elementId,
            HttpServletRequest req, HttpServletResponse rsp);
 
}