import { httpAxios } from "@/api/ApiInstance"
import { type queryParamsType } from "@/queryParams/"

//根据id获取课程信息
export const getTeacherChapterKnowledgeMaterial = (id: string, fromType: queryParamsType["fromType"]) => {
  return httpAxios.axioseRquest({
    method: "post",
    url: "/edu-app/teacherChapterKnowledgeMaterial/detail",
    data: {
      id,
      fromType
    }
  })
}

// 老师端 保存信息
export const putTeacherChapterKnowledgeMaterial = (data: { id: string; dataJson: string }) => {
  return httpAxios.axioseRquest({
    method: "post",
    url: "/edu-app/teacherChapterKnowledgeMaterial/savePptJson",
    data
  })
}

// 平台端 保存信息
export const putChapterKnowledgeMaterialUpdate = (data: { id: string; dataJson: string }) => {
  return httpAxios.axioseRquest({
    method: "post",
    url: "/edu-app/chapterKnowledgeMaterial/update",
    data
  })
}

// 获取曲目信息
export const getMaterialQueryPage = (data: Record<string, any>, abortController: AbortController) => {
  return httpAxios.axioseRquest({
    signal: abortController.signal,
    method: "post",
    url: "/edu-app/material/queryPage",
    data
  })
}

// 获取乐器信息
export const getSubjectListApi = () => {
  return httpAxios.axioseRquest({
    method: "post",
    url: "/edu-app/subject/list",
    data: {
      delFlag: 0,
      page: 1,
      rows: 999
    }
  })
}
// 获取课件教材
export const getMusicTagTreeApi = () => {
  return httpAxios.axioseRquest({
    method: "get",
    url: "/edu-app/musicTag/tree"
  })
}

// 收藏课件 取消收藏
export const favoriteApi = (data: { favoriteFlag: 0 | 1; materialId: string; type: string }) => {
  return httpAxios.axioseRquest({
    method: "post",
    url: "/edu-app/material/favorite",
    data
  })
}
