sean.zhou
2023-02-24 a7aaeabc7873a0eafb4a7ecad7f65b018b7a9bc9
src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java
@@ -10,7 +10,9 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.sql.SQLException;
import java.util.Set;
import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM;
@@ -35,12 +37,12 @@
     * @throws SQLException
     */
    @PostMapping("/{workspace_id}/flight-tasks")
    public ResponseResult createJob(HttpServletRequest request, @RequestBody CreateJobParam param,
    public ResponseResult createJob(HttpServletRequest request, @Valid @RequestBody CreateJobParam param,
                                    @PathVariable(name = "workspace_id") String workspaceId) throws SQLException {
        CustomClaim customClaim = (CustomClaim)request.getAttribute(TOKEN_CLAIM);
        customClaim.setWorkspaceId(workspaceId);
        boolean isCreate = waylineJobService.createJob(param, customClaim);
        return isCreate ? ResponseResult.success() : ResponseResult.error();
        return waylineJobService.publishFlightTask(param, customClaim);
    }
    /**
@@ -59,16 +61,29 @@
    }
    /**
     * Issue wayline mission to the dock for execution.
     * @param jobId
     * Send the command to cancel the jobs.
     * @param jobIds
     * @param workspaceId
     * @return
     * @throws SQLException
     */
    @PostMapping("/{workspace_id}/jobs/{job_id}")
    public ResponseResult publishJob(@PathVariable(name = "job_id") String jobId,
    @DeleteMapping("/{workspace_id}/jobs")
    public ResponseResult publishCancelJob(@RequestParam(name = "job_id") Set<String> jobIds,
                                     @PathVariable(name = "workspace_id") String workspaceId) throws SQLException {
        waylineJobService.publishFlightTask(workspaceId, jobId);
        waylineJobService.cancelFlightTask(workspaceId, jobIds);
        return ResponseResult.success();
    }
    /**
     * Set the media files for this job to upload immediately.
     * @param workspaceId
     * @param jobId
     * @return
     */
    @PostMapping("/{workspace_id}/jobs/{job_id}/media-highest")
    public ResponseResult uploadMediaHighestPriority(@PathVariable(name = "workspace_id") String workspaceId,
                                             @PathVariable(name = "job_id") String jobId) {
        waylineJobService.uploadMediaHighestPriority(workspaceId, jobId);
        return ResponseResult.success();
    }
}