package com.yuchen.saas.park.service.controller.video;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.integration.feign.api.feign.CameraClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 刘通
 * @date 2020/12/22 1:31
 */
@RestController
@AllArgsConstructor
@RequestMapping("/camera")
@Api(value = "摄像头接口", tags = "摄像头接口")
public class CameraController {

    @Resource
    private CameraClient cameraClient;

    /**
     * 获取所有监控点信息及其视频流url
     * @return
     */
    @PostMapping("/getPreviewUrl")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "获取所有监控点信息及其视频流url", notes = "获取所有监控点信息及其视频流url")
    public R<List<Map<String, Object>>> getPreviewUrl() {
        return cameraClient.getPreviewUrl();
    }

    /**
     * 获取
     * @return
     */
    @PostMapping("/getFaceGroup")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "get", notes = "none")
    public R<List<Map<String, Object>>> getFaceGroup(@RequestBody Map<String, Object> body) {
        return cameraClient.getFaceGroup(body);
    }

    @PostMapping("/testCamera")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "get", notes = "none")
    public void testCamera(@RequestBody Map<String, Object> body) {
        System.out.println("body:"+body);
    }

    /**
     * 统计监控点在线状态
     * @return
     *  onlineY 在线数量
     *  onlineN 离线数量
     *  cameraCount 总数
     */
/*
    @GetMapping("/getCountOnlineCamera")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "统计监控点在线状态", notes = "统计监控点在线状态")
    public Map<String, Object> getCountOnlineCamera() {
        return cameraService.getCountOnlineCamera();
    }
*/

    /**
     * 通过监控点唯一标识获取流
     * @param cameraIndexCode
     * @return
     */
    @GetMapping("/getPreviewUrlByCode")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "通过监控点唯一标识获取流", notes = "通过监控点唯一标识获取流")
    public R<Map<String, Object>> getPreviewUrlByCode(@RequestParam String cameraIndexCode,@RequestParam(required = false) String streamType) {
        return R.data(cameraClient.getPreviewUrlByCode(cameraIndexCode,streamType));
    }
    /**
     * 统计监控点在线状态 提供给其他服务调用
     * @return
     *  onlineY 在线数量
     *  onlineN 离线数量
     *  cameraCount 总数
     */
    /*@GetMapping("/getCountOnlineCameraApi")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "统计监控点在线状态 提供给其他服务调用", notes = "统计监控点在线状态 提供给其他服务调用")
    public R<Map<String, Object>> getCountOnlineCameraApi() {
        return R.data(cameraService.getCountOnlineCamera());
    }*/
}
