diff --git a/src/api/course-attachment.ts b/src/api/course-attachment.ts new file mode 100644 index 0000000..dae980a --- /dev/null +++ b/src/api/course-attachment.ts @@ -0,0 +1,22 @@ +import client from "./internal/httpClient"; + +export function updateCourseAttachment( + courseId: number, + id: number, + chapterId: number, + name: string, + type: string, + rid: number +) { + return client.put(`/backend/v1/course/${courseId}/attachment/create-batch`, { + chapter_id: chapterId, + name, + type, + sort: 0, + rid, + }); +} + +export function destroyAttachment(courseId: number, id: number) { + return client.destroy(`/backend/v1/course/${courseId}/attachment/${id}`); +} diff --git a/src/api/course.ts b/src/api/course.ts index bb93ea1..87dedc4 100644 --- a/src/api/course.ts +++ b/src/api/course.ts @@ -35,7 +35,8 @@ export function storeCourse( depIds: number[], categoryIds: number[], chapters: number[], - hours: number[] + hours: number[], + attachments: any[] ) { return client.post("/backend/v1/course/create", { title: title, @@ -47,6 +48,7 @@ export function storeCourse( category_ids: categoryIds, chapters: chapters, hours: hours, + attachments: attachments, }); } diff --git a/src/api/index.ts b/src/api/index.ts index ad717e8..733df58 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -6,6 +6,7 @@ export * as courseCategory from "./course-category"; export * as courseChapter from "./course-chapter"; export * as course from "./course"; export * as courseHour from "./course-hour"; +export * as courseAttachment from "./course-attachment"; export * as department from "./department"; export * as resourceCategory from "./resource-category"; export * as resource from "./resource"; diff --git a/src/pages/course/compenents/create.tsx b/src/pages/course/compenents/create.tsx index 23cd599..1d82990 100644 --- a/src/pages/course/compenents/create.tsx +++ b/src/pages/course/compenents/create.tsx @@ -224,7 +224,8 @@ export const CourseCreate: React.FC = ({ dep_ids, values.category_ids, chapters, - treeData + treeData, + [] ) .then((res: any) => { message.success("保存成功!");