import request from '@/utils/request'

// 查询资料库文件列表
export function listDatabase(query) {
  return request({
    url: '/train/database/list',
    method: 'get',
    params: query
  })
}

// 查询资料库文件详细
export function getDatabase(id) {
  return request({
    url: '/train/database/' + id,
    method: 'get'
  })
}

// 新增资料库文件
export function addDatabase(data) {
  return request({
    url: '/train/database',
    method: 'post',
    data: data
  })
}

// 修改资料库文件
export function updateDatabase(data) {
  return request({
    url: '/train/database',
    method: 'put',
    data: data
  })
}

// 删除资料库文件
export function delDatabase(id) {
  return request({
    url: '/train/database/' + id,
    method: 'delete'
  })
}

// 删除路径和文件
export function delDirectoryAndData(id) {
  return request({
    url: '/train/database/delDirectoryAndData/' + id,
    method: 'delete'
  })
}

// 查询资料库文件树
export function getDirectoryTree() {
  return request({
    url: '/train/database/directory/tree',
    method: 'get'
  })
}

// 创建文件夹
export function createDirectory(data) {
  return request({
    url: '/train/database/directory',
    method: 'post',
    data: data
  })
}

// 设置文件可见范围
export function visibleRange(data) {
  return request({
    url: '/train/database/visibleRange',
    method: 'put',
    data: data
  })
}

// 获取文件类型
export function getDatabaseType() {
  return request({
    url: '/train/database/fileTypes',
    method: 'get'
  })
}

// 试题分页
export function questionPage(query) {
  return request({
    url: '/train/question/page',
    method: 'get',
    params: query
  })
}

// 试题详情
export function getQuestion(id) {
  return request({
    url: '/train/question/' + id,
    method: 'get'
  })
}

// 删除试题
export function delQuestion(id) {
  return request({
    url: '/train/question/' + id,
    method: 'delete'
  })
}

// 编辑试题
export function editQuestion(data) {
  return request({
    url: '/train/question',
    method: 'put',
    data: data
  })
}

// 批量更新试题
export function editQuestionBatch(data) {
  return request({
    url: '/train/question/batch',
    method: 'put',
    data: data
  })
}

// 切换状态handleQuestionToggleStatus
export function toggleQuestionStatus(id) {
  return request({
    url: '/train/question/changeStatus/' + id,
    method: 'put'
  })
}

