package com.cmvr.web.controller.api;

import com.alibaba.fastjson2.JSON;
import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.edge.client.model.EdgeCommonVO;
import com.cmvr.edge.client.service.EdgeCameraService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "边缘--相机")
@RestController
@RequestMapping("/api/edge/camera")
@RequiredArgsConstructor
public class EdgeCameraController extends BaseController {

    private final EdgeCameraService edgeCameraService;

    @ApiOperation("获取相机状态")
    @GetMapping("/status")
    public AjaxResult status(EdgeCommonVO edgeCommonVO) {
        return success(JSON.toJSONString(edgeCameraService.status(edgeCommonVO)));
    }

    @ApiOperation("开启相机")
    @GetMapping("/start")
    public AjaxResult start(EdgeCommonVO edgeCommonVO) {
        return success(edgeCameraService.start(edgeCommonVO));
    }

    @ApiOperation("关闭相机")
    @GetMapping("/stop")
    public AjaxResult stop(EdgeCommonVO edgeCommonVO) {
        return success(edgeCameraService.stop(edgeCommonVO));
    }

    @ApiOperation("获取图片")
    @GetMapping("/getRGBImage")
    public AjaxResult getRGBImage(EdgeCommonVO edgeCommonVO) {
        return success(edgeCameraService.getRGBImage(edgeCommonVO));
    }

    @ApiOperation("开始录制视频")
    @GetMapping("/startRecording")
    public AjaxResult startRecording(EdgeCommonVO edgeCommonVO) {
        return success(edgeCameraService.startRecording(edgeCommonVO));
    }

    @ApiOperation("停止录制视频")
    @GetMapping("/stopRecording")
    public AjaxResult stopRecording(EdgeCommonVO edgeCommonVO) {
        return success(edgeCameraService.stopRecording(edgeCommonVO));
    }

    @ApiOperation("获取图片和视频")
    @GetMapping("/getRGBDImages")
    public AjaxResult getRGBDImages(EdgeCommonVO edgeCommonVO) {
        return success(edgeCameraService.getRGBDImages(edgeCommonVO));
    }
}
