import request from '@/utils/request'

// 查询摄像机列表
export function listCameras(query) {
    return request({
        url: '/subsystem/video/cameras/list',
        method: 'get',
        params: query
    })
}

// 查询摄像机详细
export function getCamera(cameraId) {
    return request({
        url: '/subsystem/video/cameras/' + cameraId,
        method: 'get'
    })
}

// 新增摄像机
export function addCamera(data) {
    return request({
        url: '/subsystem/video/cameras',
        method: 'post',
        data: data
    })
}

// 修改摄像机
export function updateCamera(data) {
    return request({
        url: '/subsystem/video/cameras',
        method: 'put',
        data: data
    })
}

// 删除摄像机
export function delCamera(cameraId) {
    return request({
        url: '/subsystem/video/cameras/' + cameraId,
        method: 'delete'
    })
}

// 导出摄像机
export function exportCamera(query) {
    return request({
        url: '/subsystem/video/cameras/export',
        method: 'post',
        params: query
    })
}

// 获取摄像机视频流
export function getCameraStream(cameraCode) {
    return request({
        url: '/subsystem/video/stream/' + cameraCode,
        method: 'get'
    })
}

// 云台控制
export function ptzControl(data) {
    return request({
        url: '/subsystem/video/ptz/control',
        method: 'post',
        data: data
    })
}

// 录像控制
export function recordingControl(data) {
    return request({
        url: '/subsystem/video/recording/control',
        method: 'post',
        data: data
    })
}

// 抓拍
export function takeCameraSnapshot(cameraCode) {
    return request({
        url: '/subsystem/video/snapshot/' + cameraCode,
        method: 'post'
    })
}

// 查询录像文件列表
export function listRecordingFiles(query) {
    return request({
        url: '/subsystem/video/recordings/list',
        method: 'get',
        params: query
    })
}

// 播放录像
export function playRecording(recordingId) {
    return request({
        url: '/subsystem/video/recordings/play/' + recordingId,
        method: 'get'
    })
}

// 下载录像
export function downloadRecording(recordingId) {
    return request({
        url: '/subsystem/video/recordings/download/' + recordingId,
        method: 'get',
        responseType: 'blob'
    })
}

// 查询联动规则列表
export function listLinkageRules(query) {
    return request({
        url: '/subsystem/video/linkage/list',
        method: 'get',
        params: query
    })
}

// 查询联动规则详细
export function getLinkageRule(ruleId) {
    return request({
        url: '/subsystem/video/linkage/' + ruleId,
        method: 'get'
    })
}

// 新增联动规则
export function addLinkageRule(data) {
    return request({
        url: '/subsystem/video/linkage',
        method: 'post',
        data: data
    })
}

// 修改联动规则
export function updateLinkageRule(data) {
    return request({
        url: '/subsystem/video/linkage',
        method: 'put',
        data: data
    })
}

// 删除联动规则
export function deleteLinkageRule(ruleId) {
    return request({
        url: '/subsystem/video/linkage/' + ruleId,
        method: 'delete'
    })
}

// 启用/禁用联动规则
export function toggleLinkageRule(ruleId, data) {
    return request({
        url: '/subsystem/video/linkage/toggle/' + ruleId,
        method: 'put',
        data: data
    })
}

// 查询联动执行记录
export function listLinkageRecords(query) {
    return request({
        url: '/subsystem/video/linkage/records/list',
        method: 'get',
        params: query
    })
}

// 查询预置位列表
export function listPresets(cameraCode) {
    return request({
        url: '/subsystem/video/presets/' + cameraCode,
        method: 'get'
    })
}

// 设置预置位
export function setPreset(data) {
    return request({
        url: '/subsystem/video/presets',
        method: 'post',
        data: data
    })
}

// 删除预置位
export function deletePreset(presetId) {
    return request({
        url: '/subsystem/video/presets/' + presetId,
        method: 'delete'
    })
}

// 查询摄像机状态统计
export function getCameraStatistics() {
    return request({
        url: '/subsystem/video/statistics',
        method: 'get'
    })
}

// 摄像机健康检测
export function checkCameraHealth(cameraCode) {
    return request({
        url: '/subsystem/video/health/check/' + cameraCode,
        method: 'post'
    })
}

// 批量摄像机健康检测
export function batchCheckCameraHealth(cameraCodes) {
    return request({
        url: '/subsystem/video/health/batch-check',
        method: 'post',
        data: { cameraCodes: cameraCodes }
    })
}

// 获取摄像机配置
export function getCameraConfig(cameraCode) {
    return request({
        url: '/subsystem/video/config/' + cameraCode,
        method: 'get'
    })
}

// 更新摄像机配置
export function updateCameraConfig(data) {
    return request({
        url: '/subsystem/video/config',
        method: 'put',
        data: data
    })
}