import { getCreateAuth, updateAuth } from '@/api/base'
import httpRequest from '@/utils/axios'
import type {
  BookAuthorizeCreateItem,
  CaseAuthorizeCreateItem,
  ResourceDocumentCreateItem,
  ResourceVideoCreateItem,
  VideoAuthorizeCreateItem,
  VideoUploadAuthParams,
  VideoUploadRefreshParams,
} from './types'

// 获取课程列表
export function getCourseList() {
  return httpRequest.get('/api/lab/v1/teacher/course/list')
}

// 获取实验列表
export function getExperimentList(params: { course_id: string }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/experiments', { params })
}

// 创建案例原文
export function createCase(data: CaseAuthorizeCreateItem) {
  return httpRequest.post('/api/lab/v1/teacher/experiment-cases/create', data)
}

// 创建指导书
export function createBook(data: BookAuthorizeCreateItem) {
  return httpRequest.post('/api/lab/v1/teacher/book/create', data)
}

// 创建操作视频
export function createVideo(data: VideoAuthorizeCreateItem) {
  return httpRequest.post('/api/lab/v1/teacher/video/create', data)
}

// 获取上传视频凭证
export function getUploadVideoAuth(data: VideoUploadAuthParams) {
  return httpRequest.post('/api/lab/v1/teacher/video/auth-create', data)
}

// 刷新上传视频地址凭证
export function updateUploadVideoAuth(data: VideoUploadRefreshParams) {
  return httpRequest.post('/api/lab/v1/teacher/video/create-auth', data)
}

// 统一资源平台视频上传凭证
export function getResourceUploadVideoAuth(data: VideoUploadAuthParams) {
  return getCreateAuth(data)
}

// 统一资源平台刷新上传视频地址凭证
export function updateResourceUploadVideoAuth(data: VideoUploadRefreshParams) {
  return updateAuth(data)
}

// 创建统一资源平台视频
export function createResourceVideo(data: ResourceVideoCreateItem) {
  return httpRequest.post('/api/resource/v1/resource/video/create', data)
}

// 创建统一资源平台课件
export function createResourceCourseware(data: ResourceDocumentCreateItem) {
  return httpRequest.post('/api/resource/v1/resource/courseware/create', data)
}

// 创建统一资源平台教案
export function createResourceLessonPlan(data: ResourceDocumentCreateItem) {
  return httpRequest.post('/api/resource/v1/resource/lesson-plan/create', data)
}

// 创建统一资源平台其他资料
export function createResourceOther(data: ResourceDocumentCreateItem) {
  return httpRequest.post('/api/resource/v1/resource/other-information/create', data)
}
