import request from '@/utils/request'

// 查询课堂评论列表
export function listUserCourseComment(query) {
  return request({
    url: '/course/userCourseComment/list',
    method: 'get',
    params: query
  })
}

// 查询课堂评论详细
export function getUserCourseComment(commentId) {
  return request({
    url: '/course/userCourseComment/' + commentId,
    method: 'get'
  })
}

// 新增课堂评论
export function addUserCourseComment(data) {
  return request({
    url: '/course/userCourseComment',
    method: 'post',
    data: data
  })
}

// 修改课堂评论
export function updateUserCourseComment(data) {
  return request({
    url: '/course/userCourseComment',
    method: 'put',
    data: data
  })
}

// 删除课堂评论
export function delUserCourseComment(commentId) {
  return request({
    url: '/course/userCourseComment/' + commentId,
    method: 'delete'
  })
}

// 导出课堂评论
export function exportUserCourseComment(query) {
  return request({
    url: '/course/userCourseComment/export',
    method: 'get',
    params: query
  })
}

// 下载精选留言Word导入模板
export function downloadCommentImportTemplate() {
  return request({
    url: '/course/userCourseComment/importTemplate',
    method: 'get',
    responseType: 'blob'
  })
}

// 导入精选留言
export function importComments(courseId, videoId, file) {
  const formData = new FormData()
  formData.append('file', file)
  if (videoId != null) {
    formData.append('videoId', videoId)
  }
  return request({
    url: '/course/userCourseComment/importComments/' + courseId,
    method: 'post',
    data: formData,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// 查询精选留言历史列表
export function listFeaturedComments(courseId, videoId, query) {
  return request({
    url: '/course/userCourseComment/featuredComments/' + courseId,
    method: 'get',
    params: { videoId: videoId || undefined, ...query }
  })
}

// 查询指定小节下的用户留言（排除精选留言）
export function listSectionUserComments(query) {
  return request({
    url: '/course/userCourseComment/sectionUserComments',
    method: 'get',
    params: query
  })
}

// 修改用户留言可见范围：visibleAll 0自己可见 1全部人可见
export function updateCommentVisibleAll(data) {
  return request({
    url: '/course/userCourseComment/updateVisibleAll',
    method: 'put',
    data: data
  })
}