294 lines
5.9 KiB
TypeScript
294 lines
5.9 KiB
TypeScript
import type { IResponse } from '.'
|
|
import type {
|
|
ICourse,
|
|
ICourseChapter,
|
|
ICreateResource,
|
|
IResource,
|
|
} from '~/types'
|
|
|
|
export type IPerson<T> = {
|
|
id: number
|
|
courseId: number
|
|
createTime: Date
|
|
updateTime: Date
|
|
createBy: number
|
|
updateBy: number
|
|
remark: string | null
|
|
} & (T extends ITeacher
|
|
? { teacher: ITeacher, teacherId: number }
|
|
: T extends IStudent
|
|
? { student: IStudent, studentId: number }
|
|
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
{})
|
|
|
|
export interface ITeacher {
|
|
id: number
|
|
userName: string
|
|
employeeId: string
|
|
schoolId: number
|
|
collegeId: number
|
|
schoolName: string
|
|
collegeName: string
|
|
sex: number
|
|
email: string
|
|
phonenumber: string
|
|
avatar: string
|
|
status: number
|
|
delFlag: number
|
|
loginIp: string
|
|
loginDate: Date
|
|
createBy: number
|
|
createTime: Date
|
|
updateBy: number
|
|
updateTime: Date
|
|
remark: string | null
|
|
}
|
|
|
|
export interface IStudent {
|
|
id: number
|
|
userName: string
|
|
studentId: string
|
|
schoolId: number
|
|
collegeId: number
|
|
schoolName: string
|
|
collegeName: string
|
|
sex: number
|
|
email: string
|
|
phonenumber: string
|
|
avatar: null | string
|
|
status: number
|
|
delFlag: null
|
|
loginIp: null
|
|
loginDate: null
|
|
createBy: null
|
|
createTime: null
|
|
updateBy: null
|
|
updateTime: null
|
|
remark: null
|
|
}
|
|
|
|
export interface ICourseClass {
|
|
id: number
|
|
courseId: number
|
|
classId: number
|
|
className: string
|
|
createBy: number
|
|
createTime: Date
|
|
updateBy: number
|
|
updateTime: Date | null
|
|
remark: string | null
|
|
notes?: string | null
|
|
}
|
|
|
|
export const listCourses = async () => {
|
|
return await http<
|
|
IResponse<{
|
|
rows: ICourse[]
|
|
}>
|
|
>('/system/manage/list', {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const listUserCourses = async (userId: number) => {
|
|
return await http<
|
|
IResponse<{
|
|
rows: ICourse[]
|
|
}>
|
|
>(`/system/manage/leader/${userId}`, {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getCourseDetail = async (courseId: string) => {
|
|
return await http<
|
|
IResponse<{
|
|
data: ICourse
|
|
}>
|
|
>(`/system/manage/${courseId}`, {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const createCourse = async (
|
|
params: Pick<
|
|
ICourse,
|
|
| 'courseName'
|
|
| 'profile'
|
|
| 'schoolName'
|
|
| 'teacherName'
|
|
| 'semester'
|
|
| 'previewUrl'
|
|
>,
|
|
) => {
|
|
return await http<IResponse>(`/system/manage`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteCourse = async (courseId: number) => {
|
|
return await http<IResponse>(`/system/manage/${courseId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const getCourseChatpers = async (courseId: number) => {
|
|
return await http<
|
|
IResponse<{
|
|
total: number
|
|
rows: ICourseChapter[]
|
|
}>
|
|
>(`/system/chapter/details/${courseId}`, {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const createCourseChatper = async (params: {
|
|
courseId: number
|
|
title: string
|
|
}) => {
|
|
return await http<IResponse>(`/system/chapter`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteCourseChatper = async (chapterId: number) => {
|
|
return await http<IResponse>(`/system/chapter/${chapterId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const editCourseChapter = async (chapter: ICourseChapter) => {
|
|
return await http<IResponse>(`/system/chapter`, {
|
|
method: 'PUT',
|
|
body: chapter,
|
|
})
|
|
}
|
|
|
|
export const createCourseSection = async (params: {
|
|
chapterId: number
|
|
title: string
|
|
}) => {
|
|
return await http<IResponse>(`/system/section`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteCourseSection = async (sectionId: number) => {
|
|
return await http<IResponse>(`/system/section/${sectionId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const createResource = async (params: ICreateResource) => {
|
|
return await http<IResponse & { resourceId: number }>(`/system/resource`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteResource = async (resourceId: number) => {
|
|
return await http<IResponse>(`/system/resource/${resourceId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const editResource = async (resource: IResource) => {
|
|
return await http<IResponse>(`/system/resource`, {
|
|
method: 'PUT',
|
|
body: resource,
|
|
})
|
|
}
|
|
|
|
export const addResourceToSection = async (params: {
|
|
sectionId: number
|
|
resourceId: number
|
|
}) => {
|
|
return await http<IResponse>(`/system/sectionResource`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const addTeacherToCourse = async (params: {
|
|
courseId: number
|
|
teacherId: number
|
|
}) => {
|
|
return await http<IResponse>(`/system/teacherteam`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteTeacherTeamRecord = async (recordId: number) => {
|
|
return await http<IResponse>(`/system/teacherteam/${recordId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const getTeacherTeamByCourse = async (courseId: number) => {
|
|
return await http<
|
|
IResponse<{
|
|
data: IPerson<ITeacher>[]
|
|
}>
|
|
>(`/system/teacherteam/course/${courseId}`, {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const createClass = async (params: {
|
|
className: string
|
|
notes: string
|
|
courseId: number
|
|
}) => {
|
|
return await http<IResponse>(`/system/course/class`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteClass = async (classId: number) => {
|
|
return await http<IResponse>(`/system/course/class/${classId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const getClassListByCourse = async (courseId: number) => {
|
|
return await http<
|
|
IResponse<{
|
|
data: ICourseClass[]
|
|
}>
|
|
>(`/system/course/class/${courseId}`, {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getStudentListByClass = async (classId: number) => {
|
|
return await http<
|
|
IResponse<{
|
|
data: IPerson<IStudent>[]
|
|
}>
|
|
>(`/system/student/class/${classId}`, {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const addStudentToClass = async (params: {
|
|
classId: number
|
|
studentId: number
|
|
}) => {
|
|
return await http<IResponse>(`/system/student`, {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const deleteStudentClassRecord = async (recordId: number) => {
|
|
return await http<IResponse>(`/system/student/${recordId}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|