package com.sptg.video.cloud.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.video.cloud.api.dto.VCDeviceDto;
import com.sptg.video.cloud.api.entity.VCDevice;
import com.sptg.video.cloud.api.feigns.fallback.VCDeviceFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * @author zwx
 * @create 2020/10/16 11:56
 */
@FeignClient(value = "smart-house-video-cloud", fallbackFactory = VCDeviceFeignFallbackFactory.class)
public interface VCDeviceFeign {

    /**
     * 功能描述: 分页查询设备信息
     * @param pageBean 设备业务对象（含分页及查询条件）
     * @return ResultBean<Page<Device>>
     *
     *
     */
    @PostMapping(value = "/vcDevice/pagingQuery")
    ResultBean<Page<VCDevice>> pagingQuery(@RequestBody PageBean<VCDevice, VCDeviceDto> pageBean);

    /**
     * 功能描述:根据Id查找设备
     * @param id 必填
     * @return Device
     *
     *
     */
    @GetMapping(value = "/vcDevice/findDeviceById/{id}")
    VCDevice findDeviceById(@PathVariable(value = "id")Long id);

    /**
     * 功能描述:根据设备号查找设备
     * @param deviceNum 必填
     * @return Device
     *
     *
     */
    @GetMapping(value = "/vcDevice/findDeviceByNum/{deviceNum}")
    VCDevice findDeviceByNum(@PathVariable(value = "deviceNum") String deviceNum);

    /**
     * 同步设备列表数据
     * @param deviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/sync/list")
    ResultBean<String> syncDeviceList(@RequestBody VCDeviceDto deviceDto);

    /**
     * 获取设备播放地址
     * @param deviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/getDevUrl")
    ResultBean<String> deviceGetDevUrl(@RequestBody VCDeviceDto deviceDto);

    /**
     * 设备视频推流
     * @param deviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/pusher")
    ResultBean<String> devicePusher(@RequestBody VCDeviceDto deviceDto);


    /**
     * 检测mediaServer中流是否存在
     * @param vcDeviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/mediaServer/streamOnline")
    ResultBean<String> mediaServerStreamOnline(@RequestBody VCDeviceDto vcDeviceDto);

    /**
     * 通过fork FFmpeg进程的方式拉流代理，支持任意协议
     * @param vcDeviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/mediaServer/addFFmpegSource")
    ResultBean<String> msAddFFmpegSource(@RequestBody VCDeviceDto vcDeviceDto);

    /**
     * 关闭ffmpeg拉流代理
     * @param vcDeviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/mediaServer/delFFmpegSource")
    ResultBean<String> msDelFFmpegSource(@RequestBody VCDeviceDto vcDeviceDto);

    /**
     * 设备推流状态查询
     * @param deviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/pusher/status")
    ResultBean<String> devicePusherStatus(@RequestBody VCDeviceDto deviceDto);

    /**
     * 设备视频推流停止
     * @param deviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/pusher/delete")
    ResultBean<String> devicePusherDelete(@RequestBody VCDeviceDto deviceDto);

    /**
     * 获取设备http-flv播放地址
     * @param deviceDto
     * @return
     */
    @PostMapping(value = "/vcDevice/getDevHttpFlvUrl")
    ResultBean<String> deviceGetHttpFlvUrl(@RequestBody VCDeviceDto deviceDto);

    @PostMapping(value = "/vcDevice/getDevUrlList")
    public ResultBean<Boolean> syncDeviceDevUrlList(@RequestBody VCDeviceDto vcDeviceDto);

    /**
     * 获取设备列表
     * @return
     */
    @GetMapping(value = "/vcDevice/getList")
    ResultBean<List<VCDevice>> getList();

    /**
     * 批量更新设备
     * @return
     */
    @PostMapping(value = "/vcDevice/updateBatch")
    ResultBean<String> updateBatch(@RequestBody List<VCDevice> vcDeviceList);

    /**
     * 更新设备
     * @return
     */
    @PostMapping(value = "/vcDevice/update")
    ResultBean<String> update(@RequestBody VCDevice vcDevice);
}
