import fetch from '@/utils/fetch'
// 分类查询
export const getCourseClassfiyApi = () => {
  return fetch({ url: 'online-course/classify', method: 'get' })
}
/**
 * 添加分类
 *
 */
export const addCourseClassfiyApi = (data) => {
  return fetch({ url: 'online-course/classify', method: 'post', data })
}
/**
 * 【改】 - 编辑分类
 * @param {number} id
 * @param {string} name
 * @returns
 */
export const editorCourseClassfiyApi = (data) => {
  return fetch({ url: 'online-course/classify/' + data.id, method: 'patch', data })
}

export const deleteCourseClassfiyApi = (data) => {
  return fetch({ url: 'online-course/classify/delete', method: 'post', data })
}
/**
 * 获取课程列表
 */
export const getCourseListApi = (data) => {
  return fetch({ url: `online-course/course?page=${data.page}&pageSize=${data.pageSize}&classify=${data.classify}`, method: 'get' })
}

/**
 * 修改课程状态
 */
export const setCourseStatusApi = (data) => {
  return fetch({ url: `online-course/course_status/${data.id}?status=${data.status}`, method: 'get' })
}
/**
 * 查询课程列表
 */
export const searchCourseListApi = (data) => {
  return fetch({ url: `online-course/course_search/?page=${data.page}&pageSize=${data.pageSize}&value=${data.value}&classify=${data.classify}`, method: 'get' })
}

/**
 * 删除课程——可批量
 */
export const deleteCourseApi = (data) => {
  return fetch({ url: 'online-course/batch_delete', method: 'post', data })
}

/**
 * 添加课程
 */
export const addCourseApi = (data) => {
  return fetch({ url: 'online-course', method: 'post', data })
}

/**
 * 获取课程详情
 */
export const getCourseInfoApi = (id) => {
  return fetch({ url: `online-course/course/${id}`, method: 'get' })
}

/**
 * 添加课程
 */
export const editorCourseApi = (id, data) => {
  return fetch({ url: `online-course/course/${id}`, method: 'patch', data })
}
