import request from '@/utils/request'

class ShortVideoApi {
  /** 查询短视频列表 */
  getList(query) {
    return request({
      url: 'pc/teachingDsp/dsp/list',
      method: 'get',
      params: {
        status: 0,
        ...query,
      },
    })
  }

  /** 查询短视频详情 */
  getVideoInfo(Id) {
    return request({
      url: 'pc/teachingDsp/dsp/' + Id,
      method: 'get',
    })
  }

  /** 新增短视频 */
  addVideo(data) {
    return request({
      url: 'pc/teachingDsp/dsp',
      method: 'post',
      data: data,
    })
  }

  /** 修改短视频信息 */
  updateVideo(data) {
    return request({
      url: 'pc/teachingDsp/dsp',
      method: 'put',
      data: data,
    })
  }

  /** 删除短视频 */
  delVideo(ids) {
    return request({
      url: 'pc/teachingDsp/dsp/' + ids,
      method: 'put',
    })
  }

  /** 上传视频封面 */
  uploadCover(data, fn) {
    return request({
      url: 'pc/teachingDsp/dsp/coverUp',
      method: 'put',
      headers: {
        'content-type': 'multipart/form-data',
      },
      data,
      onUploadProgress: fn,
      timeout: 0,
    })
  }

  /** 修改上架状态 */
  changeUserStatus(id, shelfStatus) {
    if (shelfStatus != 0) {
      return request({
        url: 'pc/teachingDsp/dsp/offShelf/' + id,
        method: 'put',
      })
    } else {
      return request({
        url: 'pc/teachingDsp/dsp/putShelf/' + id,
        method: 'put',
      })
    }
  }

  /**下架短视频 */
  offShelf(ids) {
    return request({
      url: 'pc/teachingDsp/dsp/offShelf/' + ids,
      method: 'put',
    })
  }

  /**上架短视频 */
  putShelf(ids) {
    return request({
      url: 'pc/teachingDsp/dsp/putShelf/' + ids,
      method: 'put',
    })
  }
}

export default new ShortVideoApi()
