import axiosInstance from "@/apis/axios.config";
//提交的后端路径
const ENGAGE_PREFIX = "/api/class"

const classApis = {
    getClassOfCourse:(courseId: number) => {
        return axiosInstance.get(ENGAGE_PREFIX+"/select",{
            params:{
                courseId
            }
        })
    },
    createClassOfCourse:(courseId:number,className:string,classTime:string,teacherId:number) => {
        return axiosInstance.post(ENGAGE_PREFIX+"/create",{
            courseId,
            className,
            classTime,
            teacherId
        })
    },
    deleteClass:(classId:number) => {
        return axiosInstance.delete(ENGAGE_PREFIX+"/delete",{
            params:{
                classId
            }
        })
    },
    getStudentsOfClass:(classId:number) => {
        return axiosInstance.get(ENGAGE_PREFIX+`/${classId}`)
    },
    addStudentOfClasss:(classId:number,officialNumber:number) => {
        return axiosInstance.post(ENGAGE_PREFIX+`/${classId}/students`,{},{
            params:{
                officialNumber
            }
        })
    },
    importStudentsOfClass:(classId:number,file:File) => {
        const formData = new FormData();
        formData.append("file", file);
        return axiosInstance.post(ENGAGE_PREFIX+`/${classId}/students/batch`, formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    },
    deleteStudentOfClass:(classId:number,officialNumbers) => {
        return axiosInstance.delete(ENGAGE_PREFIX+`/${classId}/students/batch`,{
            headers:{
                'Content-Type': 'application/json'
            },
            data: officialNumbers
        })
    },
    getClassStatesOfCourse:(classId:number,assignmentId:number) => {
        return axiosInstance.get(`/api/assignment/class/${classId}/status`,{
            params:{
                assignmentId
            }
        })
    },
    getHomeworkOfStudent:(courseId:number,studentId:number) => {
        return axiosInstance.get(`/api/course/student/assignments`,{
            params:{
                studentId,
                courseId
            }
        })
    },
    getClassByClassId:(classId:number) => {
        return axiosInstance.get(`/api/class/find/${classId}`)
    },
    getClassNameOfStudent:(courseId:number,studentId:number) => {
        return axiosInstance.get(ENGAGE_PREFIX+`/student/${studentId}/course/${courseId}`)
    }
}


export default classApis