sean.zhou
2022-11-18 56df98ce4952239fbf7d0e99dbeb0e5c71531d6f
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.List;
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,16 @@
    }
    /**
     * 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") List<String> jobIds,
                                     @PathVariable(name = "workspace_id") String workspaceId) throws SQLException {
        waylineJobService.publishFlightTask(workspaceId, jobId);
        waylineJobService.cancelFlightTask(workspaceId, jobIds);
        return ResponseResult.success();
    }
}