package com.ard.tianyu.controller;
|
|
import com.ard.common.core.domain.AjaxResult;
|
import com.ard.tianyu.service.control.UavControlService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
|
|
@Api(tags = "无人机控制权接口")
|
@RestController
|
@RequestMapping("/uav/control")
|
public class UavControlController {
|
@Resource
|
private UavControlService uavControlService;
|
|
/**
|
* 申请控制权(请求通过 WebSocket 发送给当前控制者)
|
*/
|
@ApiOperation("申请控制权")
|
@PostMapping("/request")
|
public AjaxResult requestControl(@RequestParam String boxSn, @RequestParam String type) {
|
return AjaxResult.success(uavControlService.requestControl(boxSn, type));
|
}
|
|
/**
|
* 处理控制请求(当前控制者同意/拒绝)
|
*/
|
@ApiOperation("处理控制请求")
|
@PostMapping("/handle")
|
public AjaxResult handleControlRequest(
|
@RequestParam String boxSn,
|
@RequestParam String type,
|
@RequestParam boolean approve) {
|
return AjaxResult.success(uavControlService.handleControlResponse(boxSn, approve, type));
|
}
|
|
/**
|
* 释放控制权
|
*/
|
@ApiOperation("释放控制权")
|
@PostMapping("/release")
|
public AjaxResult releaseControl(@RequestParam String boxSn, @RequestParam String type) {
|
return AjaxResult.success(uavControlService.releaseControl(boxSn, type));
|
}
|
|
/**
|
* 获取当前控制者
|
*/
|
@ApiOperation("获取当前控制者")
|
@GetMapping("/current")
|
public AjaxResult getCurrentController(@RequestParam String boxSn, @RequestParam String type) {
|
return AjaxResult.success(uavControlService.getCurrentController(boxSn, type));
|
}
|
}
|