import request from '@/utils/request'
// 视频课程相关接口

// 查询视频大类
export function videoType() {
  return request({
    url: '/front/videoCourse/subjects',
    method: 'get',
  })
}
// 查询科目
export function videoSubjects(query) {
  return request({
    url: '/front/videoCourse/courses',
    method: 'get',
    params: query
  })
}

// 查询年级
export function videoGrades(query) {
  return request({
    url: '/front/videoCourse/grades',
    method: 'get',
    params: query
  })
}

// 查询版本
export function videoVersions(query) {
  return request({
    url: '/front/videoCourse/versions',
    method: 'get',
    params: query
  })
}
// 视频包列表 
export function packList(query) {
  return request({
    url: '/front/videoCourse/pack/list',
    method: 'get',
    params: query
  })
}

// 视频列表 
export function videoList(query) {
  return request({
    url: '/front/videoCourse/video/list',
    method: 'get',
    params: query
  })
}
// 章节树 
export function getChapterTreeList(query) {
  return request({
    url: '/common/chapter/getChapterTreeList',
    method: 'get',
    params: query
  })
}

// 视频详情 
export function videoInfo(query) {
  return request({
    url: '/front/videoCourse/video/info/tree',
    method: 'get',
    params: query
  })
}

// 视频点播
export function getVideoPlayAuth(query) {
  return request({
    url: '/common/vod/getVideoPlayAuth',
    method: 'get',
    params: query
  })
}

// /common/vod/getVideoPlayInfo
export function getVideoPlayInfo(videoId) {
  return request({
    url: '/common/vod/getVideoPlayInfo',
    method: 'get',
    params: {
      videoId
    }
  })
}

// /prod-api/front/videoCourse/saveWatchRecord
export function saveWatchRecord(sectionId, duration, percent, aliType) {
  if (aliType == 'undefined' || typeof aliType == 'undefined') aliType = '' // 容错处理
	return request({
		url: '/front/videoCourse/saveWatchRecord',
		method: 'post',
		params: {
			sectionId,
			duration: Math.floor(duration),
			percent: percent.toFixed(3),
      type: aliType
		}
	})
}