fix: update home page background image and remove unnecessary redirect code chore: update pnpm lock file with new dependencies for auto-animate and svg spinners delete: remove unused images from public directory refactor: modify course and user types for better clarity and structure feat: implement course API with CRUD operations and teacher team management feat: create user authentication page with login functionality and validation feat: add login state management with Pinia for user session handling style: create reusable UI components for cards and tabs chore: implement HTTP utility for API requests with error handling
155 lines
3.1 KiB
TypeScript
155 lines
3.1 KiB
TypeScript
import type { ICourse, ICourseChapter, ICourseResource } from "~/types";
|
|
import type { IResponse } from ".";
|
|
|
|
export interface ICourseTeamMember {
|
|
id: number;
|
|
teacherId: number;
|
|
courseId: number;
|
|
teacher: ITeacher;
|
|
createTime: Date;
|
|
updateTime: Date;
|
|
createBy: Date;
|
|
updateBy: number;
|
|
remark: string | null;
|
|
}
|
|
|
|
export interface ITeacher {
|
|
id: number;
|
|
userName: string;
|
|
employeeId: string;
|
|
schoolId: number;
|
|
collegeId: number;
|
|
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 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 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 createCourseResource = async (params: ICourseResource) => {
|
|
return await http<IResponse>(`/system/resource`, {
|
|
method: "POST",
|
|
body: params,
|
|
});
|
|
};
|
|
|
|
export const deleteCourseResource = async (resourceId: number) => {
|
|
return await http<IResponse>(`/system/resource/${resourceId}`, {
|
|
method: "DELETE",
|
|
});
|
|
};
|
|
|
|
export const getTeacherTeamByCourse = async (courseId: number) => {
|
|
return await http<
|
|
IResponse<{
|
|
data: ICourseTeamMember[];
|
|
}>
|
|
>(`/system/teacherteam/course/${courseId}`, {
|
|
method: "GET",
|
|
});
|
|
};
|