import request from '@/utils/request'

// 查询课堂视频列表
export function listUserVideo(query) {
  return request({
    url: '/course/userVideo/list',
    method: 'get',
    params: query
  })
}

// 查询课堂视频详细
export function getUserVideo(videoId) {
  return request({
    url: '/course/userVideo/' + videoId,
    method: 'get'
  })
}

export function getUserVideoItem(videoId) {
  return request({
    url: '/course/userVideo/getVideoDetails',
    method: 'get',
    params:{
      videoId:videoId
    }
  })
}

// 新增课堂视频
export function addUserVideo(data) {
  return request({
    url: '/course/userVideo/addVideo',
    method: 'post',
    data: data
  })
}

// 修改课堂视频
export function updateUserVideo(data) {
  return request({
    url: '/course/userVideo',
    method: 'put',
    data: data
  })
}

// 删除课堂视频
export function delUserVideo(videoId) {
  return request({
    url: '/course/userVideo/' + videoId,
    method: 'delete'
  })
}

// 导出课堂视频
export function exportUserVideo(query) {
  return request({
    url: '/course/userVideo/export',
    method: 'get',
    params: query
  })
}


export function getVideoListByCourseId(query) {
  return request({
    url: '/course/userVideo/getVideoListByCourseId',
    method: 'get',
    params: query
  })
}

export function auditUserVideo(data) {
  return request({
    url: '/course/userVideo/auditVideo',
    method: 'post',
    data: data
  })
}

export function putOn(videoIds) {
  return request({
    url: '/course/userVideo/putOn/' + videoIds,
    method: 'post'
  })
}
export function pullOff(videoIds) {
  return request({
    url: '/course/userVideo/pullOff/' + videoIds,
    method: 'post'
  })
}

export function getThumbnail(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/course/userVideo/getThumbnail',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}


//火山云视频上传
export function uploadUserVideo(file,uploadId) {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('uploadId', uploadId)
  return request({
    url: '/course/userVideo/uploadUserVideo',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// 查询火山云视频上传进度
export function getUploadProgress(uploadId) {
  return request({
    url: '/course/userVideo/uploadProgress',
    method: 'get',
    params: { uploadId }
  });
}

export function HsyAssumeRoleService() {
  return request({
    url: '/course/userVideo/HsyAssumeRoleService',
    method: 'get',
  });
}


