import request from '@/utils/request'
import { praseStrEmpty } from '@/utils/ruoyi'

// 查询用户列表
export function listUser(query) {
  return request({
    url: 'pc/teachingVideo/info/list',
    method: 'get',
    params: {
      status: 0,
      ...query,
    },
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: 'pc/teachingVideo/info/' + userId,
    method: 'get',
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: 'pc/teachingVideo/info',
    method: 'post',
    data: data,
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: 'pc/teachingVideo/info',
    method: 'put',
    data: data,
  })
}

// 删除用户
export function delVideo(userId) {
  return request({
    url: 'pc/teachingVideo/info/' + userId,
    method: 'put',
  })
}

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

export function changeUserStatus(id, shelfStatus) {
  if (shelfStatus != 0) {
    return request({
      url: 'pc/teachingVideo/info/offShelf/' + id,
      method: 'put',
    })
  } else {
    return request({
      url: 'pc/teachingVideo/info/putShelf/' + id,
      method: 'put',
    })
  }
}

/**下架短视频 */
export function offShelf(ids) {
  return request({
    url: 'pc/teachingVideo/info/offShelf/' + ids,
    method: 'put',
  })
}

/**上架短视频 */
export function putShelf(ids) {
  return request({
    url: 'pc/teachingVideo/info/putShelf/' + ids,
    method: 'put',
  })
}
