package com.tuoheng.admin.controller.callback;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.request.inspection.ExecuteTaskStatusRequest;
import com.tuoheng.admin.request.inspection.InspectionRequest;
import com.tuoheng.admin.request.inspection.MissionStatusRequest;
import com.tuoheng.admin.service.inspection.IInspectionService;
import com.tuoheng.common.core.common.OperationEnum;
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.*;

import javax.validation.Valid;

/**
 * 机场平台回调前端控制器
 *
 * @author wanjing
 * @team tuoheng
 * @date 2022-12-23
 */
@Slf4j
@RestController
@RequestMapping("/airport/inspection")
public class AirPortCallbackController {

    @Autowired
    private IInspectionService iInspectionService;

    /**
     * 被硬件调用，执行任务后，回调执行状态
     */
    @PostMapping("/executeTaskStatus")
    public JsonResult updateExecuteTaskStatus(@RequestBody @Valid ExecuteTaskStatusRequest executeTaskStatusRequest) {
        log.info("被硬件调用，执行任务后，回调执行状态：{}", JSONObject.toJSONString(executeTaskStatusRequest));
        return iInspectionService.updateExecuteTaskStatus(executeTaskStatusRequest);
    }

    /**
     * 被硬件调用，存任务飞行开始/结束状态
     */
    @PutMapping("/status")
    public JsonResult updateStatus(@RequestBody @Valid MissionStatusRequest missionStatusRequest) {
        log.info("被硬件调用，存任务飞行开始/结束状态：{}", JSONObject.toJSONString(missionStatusRequest));
        return iInspectionService.updateStatus(missionStatusRequest);
    }

    /**
     * 被硬件调用，存飞行轨迹
     */
    @PostMapping("/track")
    public JsonResult track(@RequestBody @Valid InspectionRequest inspectionRequest) {
        log.info("被硬件调用，存飞行轨迹：{}", JSONObject.toJSONString(inspectionRequest));
        return iInspectionService.track(inspectionRequest);
    }

}
