PlayEdu-backend/src/api/course.ts
2023-03-15 17:40:11 +08:00

77 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import client from "./internal/httpClient";
export function courseList(
page: number,
size: number,
sortField: string,
sortAlgo: string,
title: string,
depIds: string,
categoryIds: string
) {
return client.get("/backend/v1/course/index", {
page: page,
size: size,
sort_field: sortField,
sort_algo: sortAlgo,
title: title,
dep_ids: depIds,
category_ids: categoryIds,
});
}
export function createCourse() {
return client.get("/backend/v1/course/create", {});
}
// depIds => 部门id数组请用英文逗号连接
// categoryIds => 所属分类数组,请用英文逗号连接
export function storeCourse(
title: string,
thumb: string,
isShow: number,
depIds: number[],
categoryIds: number[],
chapters: number[],
hours: number[]
) {
return client.post("/backend/v1/course/create", {
title: title,
thumb: thumb,
is_show: isShow,
dep_ids: depIds,
category_ids: categoryIds,
chapters: chapters,
hours: hours,
});
}
export function course(id: number) {
return client.get(`/backend/v1/course/${id}`, {});
}
export function updateCourse(
id: number,
title: string,
thumb: string,
isShow: number,
depIds: number[],
categoryIds: number[],
chapters: number[],
hours: number[]
) {
return client.put(`/backend/v1/course/${id}`, {
title: title,
thumb: thumb,
is_show: isShow,
dep_ids: depIds,
category_ids: categoryIds,
chapters: chapters,
hours: hours,
});
}
export function destroyCourse(id: number) {
return client.destroy(`/backend/v1/course/${id}`);
}