| | |
| | | package com.dji.sample.droneairport.controller; |
| | | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.droneairport.model.param.AddDeviceParam; |
| | | import com.dji.sample.droneairport.model.param.RegistParam; |
| | | import com.dji.sample.droneairport.dao.DeviceExpanSionMapper; |
| | | import com.dji.sample.droneairport.model.param.ReturnTaskParam; |
| | | import com.dji.sample.droneairport.service.RegistService; |
| | | import com.dji.sample.manage.service.impl.DeviceRedisServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; |
| | | |
| | | @RequestMapping("/droneAirport") |
| | | @RestController |
| | | public class RegistController { |
| | | @Autowired |
| | | private RegistService registService; |
| | | @Autowired |
| | | private DeviceExpanSionMapper expanSionDao; |
| | | |
| | | @PostMapping("/RegistService") |
| | | public ResponseResult resgitePort(@RequestBody RegistParam param) { |
| | | return ResponseResult.success(registService.registPort(param)); |
| | | @Autowired |
| | | private DeviceRedisServiceImpl deviceRedisService; |
| | | |
| | | // @PostMapping("/RegistService") |
| | | // public ResponseResult resgitePort(@RequestBody RegistDto param) { |
| | | // return ResponseResult.success(registService.registPort(param)); |
| | | // } |
| | | @PostMapping("/authorization") |
| | | public ResponseResult checkDeviceOnline(@RequestBody String body, HttpServletRequest request) throws Exception { |
| | | String headerValue = request.getHeader("x-lc-secret"); |
| | | return registService.authorization(body, headerValue); |
| | | |
| | | } |
| | | |
| | | @PostMapping("/addDevice") |
| | | public ResponseResult registeDrone(@RequestBody AddDeviceParam param) { |
| | | return ResponseResult.success(registService.addDrone(param)); |
| | | @PostMapping("/addDevice/{workspace_id}") |
| | | public ResponseResult registeDrone(@PathVariable(name = "workspace_id") String workspaceId) { |
| | | return ResponseResult.success(registService.addDrone(workspaceId)); |
| | | } |
| | | @PostMapping("/test") |
| | | public ResponseResult test(@RequestBody AddDeviceParam param) { |
| | | return ResponseResult.success(param); |
| | | } |
| | | @GetMapping("/getDroneStatus") |
| | | public ResponseResult droneStatus(@RequestParam String deviceid){ |
| | | |
| | | @GetMapping("/getDroneStatus/{deviceid}") |
| | | public ResponseResult droneStatus(@PathVariable(name = "deviceid") String deviceid, HttpServletResponse response) throws Exception { |
| | | return ResponseResult.success(registService.getDroneState(deviceid)); |
| | | } |
| | | |
| | | @PostMapping("/AddTask") |
| | | public ResponseResult AddTask(HttpServletRequest request, @RequestBody String body) throws Exception { |
| | | String headerValue = request.getHeader("x-lc-secret"); |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | ReturnTaskParam param = registService.AddTask(body, headerValue, creator); |
| | | return ResponseResult.success(200, "无人机机场任务添加成功", param.getTraceId(), param.getJobId()); |
| | | } |
| | | |
| | | @GetMapping("/cancelTask/{taskId}") |
| | | public ResponseResult cancelTask(@PathVariable(name = "taskId") String taskId) { |
| | | return ResponseResult.success(registService.cancelTask(taskId)); |
| | | } |
| | | |
| | | @PostMapping("/updateTask") |
| | | public ResponseResult updateTask(HttpServletRequest request, @RequestBody String body) throws Exception { |
| | | String headerValue = request.getHeader("x-lc-secret"); |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | ReturnTaskParam param = registService.updateTask(body, headerValue, creator); |
| | | return ResponseResult.success(200, "无人机机场任务添加成功", param.getTraceId(), param.getJobId()); |
| | | } |
| | | @PostMapping("/queryTaskStatus") |
| | | public ResponseResult queryTaskStatus(HttpServletRequest request, @RequestParam String taskid) throws Exception { |
| | | return ResponseResult.success(registService.queryTaskStatus(taskid)); |
| | | } |
| | | @GetMapping("/getResult/{taskId}") |
| | | public ResponseResult getResult(@PathVariable(name = "taskId") String taskId) { |
| | | return ResponseResult.success(registService.findDbFilesByTaskId(taskId)); |
| | | } |
| | | |
| | | } |