import request from '@/utils/request'

/**
 * 查询报告列表（模拟接口）
 * 若真实接口存在，替换 url 即可
 */
export function listReport(query) {
    return request({
        url: '/system/report/list',
        method: 'get',
        params: query
    })
}

/**
 * 发起大屏讲解（创建协同会话）
 */
export function createCoSession(data) {
    return request({
        url: '/communication/api/coSession/create',
        method: 'post',
        data: data
    })
}

/**
 * 结束协同会话
 */
export function endCoSession(data) {
    return request({
        url: '/communication/api/coSession/end',
        method: 'post',
        data: data
    })
}

/**
 * 切换控制权（顾问调用）
 */
export function transferControl(data) {
    return request({
        url: '/communication/api/coSession/control/transfer',
        method: 'post',
        data: data
    })
}

/**
 * 加入协同会话（顾问调用）
 */
export function joinCoSession(data) {
    return request({
        url: '/communication/api/coSession/join',
        method: 'post',
        data: data
    })
}

// ==================== 录制相关接口 ====================

/**
 * 开始录制
 * @param {Object} data - { bizType, bizId }
 */
export function startRecording(data) {
    return request({
        url: '/communication/api/recordingTask/start',
        method: 'post',
        data: data
    })
}

/**
 * 停止录制并上传视频
 * @param {string} taskId - 录制任务ID
 * @param {File} file - 视频文件
 */
export function stopRecording(taskId, file) {
    const formData = new FormData()
    formData.append('taskId', taskId)
    formData.append('file', file)
    return request({
        url: '/communication/api/recordingTask/stop',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

/**
 * 查询录制信息
 * @param {string} taskId - 录制任务ID
 */
export function queryRecording(taskId) {
    return request({
        url: `/communication/api/recordingTask/query/${taskId}`,
        method: 'get'
    })
}

/**
 * 获取生效的脱敏规则列表
 * @param {string} resourceType - 资源类型，如 'report'
 * @param {string} resourceId - 资源ID，如 'RPT-DEMO'
 */
export function getDesensitizationRules(resourceType, resourceId) {
    return request({
        url: '/communication/api/desensitization/enabled',
        method: 'get',
        params: {
            resourceType: resourceType,
            resourceBizId: resourceId
        }
    })
}