package com.yanzhu.jh.bigscreen.web.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
import com.yanzhu.jh.video.domain.SurProjectVideoConfig;
import com.yanzhu.jh.video.domain.SurProjectVideoPassage;
import com.yanzhu.jh.video.service.ISurProjectVideoConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 实时视频Conller
 */
@RestController
@RequestMapping("/bgscreen/video")
public class VideoController extends BaseController {


    @Autowired
    private ISurProjectVideoConfigService surProjectVideoConfigService;

    /**
     * 查询视频配置列表
     */
    @GetMapping("/listView")
    public AjaxResult listView(String deptId,String projectId)
    {
        SurProjectVideoConfig surProjectVideoConfig = new SurProjectVideoConfig();
        if(deptId!=null && !"0".equals(deptId)){
            surProjectVideoConfig.setProjectDeptId(deptId);
        }
        if(projectId!=null && !"0".equals(projectId)){
            surProjectVideoConfig.setProjectId(Convert.toLong(projectId));
        }
        List<SurProjectVideoConfig> list = surProjectVideoConfigService.selectSurProjectVideoConfigList(surProjectVideoConfig);
        return success(list);
    }

    /**
     * 修改视频通道状态
     */
    @GetMapping("/editPassageState")
    public AjaxResult editPassageState(Long id, String videoDvrNumber, String passageState)
    {
        SurProjectVideoPassage surProjectVideoPassage = new SurProjectVideoPassage();
        surProjectVideoPassage.setVideoId(id);
        surProjectVideoPassage.setVideoDvrNumber(videoDvrNumber);
        surProjectVideoPassage.setPassageState(passageState);
        surProjectVideoConfigService.editPassageState(surProjectVideoPassage);
        return success(surProjectVideoConfigService.updateSurProjectVideoConfigSignalState(videoDvrNumber));
    }

    /**
     * 获取视频配置详细信息
     */
    @GetMapping(value = "/getVideoPassage")
    public AjaxResult getVideoPassage(String videoDvrNumberd)
    {
        return success(surProjectVideoConfigService.getVideoPassage(videoDvrNumberd));
    }
}
