package com.tuoheng.admin.controller;

import com.tuoheng.admin.dto.ReversalFlightDto;
import com.tuoheng.admin.service.third.airport.AirportService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 机场前端控制器
 *
 * @author wanjing
 * @team tuoheng
 * @date 2022-11-23
 */
@Slf4j
@RestController
@RequestMapping("/airport")
public class AirPortController {

    @Autowired
    private AirportService airportService;

    /**
     * 获取巡检机场
     */
    @GetMapping("/list")
    public JsonResult getList() {
        return airportService.getAirportList();
    }
    /**
     * 获取巡检线路
     *
     * @param droneId 机场列表里面的droneId
     * @return
     */
    @GetMapping("/line/list/{droneId}")
    public JsonResult getAirLineList(@PathVariable("droneId") Integer droneId) {
        return airportService.getAirLineList(droneId);
    }
    /**
     * 获取机场详细信息
     * @param airportId
     * @return
     */
    @GetMapping("/getAirportDetail/{airportId}")
    public JsonResult getAirportDetail(@PathVariable("airportId") Integer airportId) {
        log.info("Index getAirportDetail start... param:{}", airportId.toString());
        return airportService.getAirportDetail(airportId);
    }

    /**
     * 根据无人机id获取机场内外监控视频
     * @param droneId
     * @return
     */
    @GetMapping("/getAirportVideo/{droneId}")
    public JsonResult getAirportVideo(@PathVariable("droneId") Integer droneId){
        log.info("进入获取无人机内外视频画面:airportId={}",droneId);
        return airportService.getAirportVideo(droneId);
    }


    /**
     * 无人机返仓
     * @param dto
     * @return
     */
    @PostMapping("/reversalFlight")
    public JsonResult reversalFlight(@RequestBody ReversalFlightDto dto){
        log.info("进入无人机返航接口:dto={}",dto);
        return airportService.reversalFlight(dto);
    }

}
