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
  })
}

// 查询课节精选留言（历史上传）
export function listFeaturedComments(courseId, videoId) {
  return request({
    url: '/course/userCourseComment/featuredList',
    method: 'get',
    params: { courseId, videoId }
  })
}

// 下载精选留言导入模板
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)
  formData.append('courseId', courseId)
  formData.append('videoId', videoId)
  return request({
    url: '/course/userCourseComment/importData',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}