import { usePost, stringify, useGet } from "@/.cool";
import type { FileList, GetPage } from '../types/index'

export interface SubjectCourseResult {
    id?: string
    subjectId?: string
    catalogId?: string
    mainTitle?: string
    assistantTitle?: string
    iconPath?: string
    sortNum?: string
    remark?: string
    updateUserId?: string
    updateUserName?: string
    createdUserId?: string
    createdUserName?: string
    createdTime?: string
    updateTime?: string
    delFlag?: boolean
    trialPlay?: boolean
    feeType?: number
    gameHtmlPath?: string
    platFormLock?: boolean
    studyUnitLock?: boolean
    videoPath?: string
    detailItem?: any
    practiceList?: any[]
    ossIconPath?: string
    testItem?: any
    diaryItem?: any
    payFlag?: boolean
    courseUserProgress?: any
    sbFilePath?: string
    fileList?: FileList[]
}

export function getSubjectCoursePage(parameter: any) {
    return useGet(`/subject/course/page`, parameter) as Promise<GetPage<SubjectCourseResult>>
}
export function getSubjectCoursePageNoLogin(parameter: any) {
    return useGet(`/subject/course/no/login/page`, parameter) as Promise<GetPage<SubjectCourseResult>>
}
// export function addSubjectCourse(parameter: SubjectCourseResult) {
//     return usePost<any>(`/subject/course`, parameter)
// }
// export function updateSubjectCourse(parameter: SubjectCourseResult) {
//     return usePut<any>(`/subject/course/${parameter.id}`, parameter)
// }
export function fetchSubjectCourse(parameter: any) {
    return useGet(`/subject/course/${parameter.id}`) as Promise<SubjectCourseResult>
}
export function fetchSubjectCourseApp(parameter: any) {
    return useGet(`/subject/course/app/query/${parameter.id}`) as Promise<SubjectCourseResult>
}
export function querySubjectCourse(parameter: any) {
    return useGet(`/subject/course`, parameter) as Promise<SubjectCourseResult[]>
}
// export function deleteSubjectCourses(parameter: string[]) {
//     return useDelete<any>(`/subject/course`, parameter)
// }

// export function exportSubjectCourse(parameter: any) {
//     return useGet<any>(`/subject/course/export`, parameter, {
//         responseType: 'blob',
//         headers: {
//             'Content-Type': 'application/json;charset=UTF-8',
//         },
//     })
// }
export function updateSubjectProgress(parameter: any) {
    return usePost(`/subject/progress/update/progress`, parameter)
}
export function queryNextSubjectCourse(parameter: any) {
    return useGet(`/subject/course/query/next/by/${parameter.id}`) as Promise<string>
}