package com.multictrl.modules.business.q20.controller;

import com.multictrl.common.annotation.ApiOrder;
import com.multictrl.common.utils.Result;
import com.multictrl.modules.business.q20.service.Q20DeviceService;
import com.multictrl.modules.business.q20.vo.Q20DeviceStatusVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Q20飞机管理接口
 *
 * @author 938693313@qq.com
 * @since 1.0.0 2026/5/20
 */
@RestController
@RequestMapping("business/q20")
@Tag(name = "Q20飞机管理")
@ApiOrder(10)
@RequiredArgsConstructor
public class Q20Controller {

    private final Q20DeviceService q20DeviceService;

    @GetMapping("/online/{deviceSn}")
    @Operation(summary = "查询飞机在线状态，在线时同时返回最新OSD数据")
    @RequiresPermissions("bus:q20:online")
    public Result<Q20DeviceStatusVO> getOnlineStatus(@PathVariable String deviceSn) {
        return new Result<Q20DeviceStatusVO>().ok(q20DeviceService.getOnlineStatus(deviceSn));
    }

    @PostMapping("/onlineBatch")
    @Operation(summary = "批量查询飞机在线状态")
    @RequiresPermissions("bus:q20:online")
    public Result<List<Q20DeviceStatusVO>> getOnlineStatusBatch(@RequestBody List<String> deviceSnList) {
        return new Result<List<Q20DeviceStatusVO>>().ok(q20DeviceService.getOnlineStatusBatch(deviceSnList));
    }
}
