web-学习管理、upload组件修改
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { api } from '@/apis';
|
||||
import type { ResultDomain, Resource, ResourceSearchParams, PageParam, ResourceVO } from '@/types';
|
||||
import type { ResultDomain, Resource, ResourceSearchParams, PageParam, ResourceVO, UserCollection } from '@/types';
|
||||
|
||||
/**
|
||||
* 资源API服务
|
||||
@@ -137,12 +137,12 @@ export const resourceApi = {
|
||||
},
|
||||
|
||||
/**
|
||||
* 增加收藏次数
|
||||
* 收藏次数增减
|
||||
* @param resourceID 资源ID
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async incrementCollectCount(resourceID: string): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.post<Resource>(`/news/resources/resource/${resourceID}/collect`);
|
||||
async resourceCollect(collect: UserCollection): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.post<Resource>(`/news/resources/resource/collect`, collect);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
@@ -5,19 +5,33 @@
|
||||
*/
|
||||
|
||||
import { api } from '@/apis/index';
|
||||
import type { Course, CourseChapter, ResultDomain } from '@/types';
|
||||
import type { Course, CourseChapter, ResultDomain,CourseVO,PageRequest, PageParam } from '@/types';
|
||||
|
||||
/**
|
||||
* 课程API服务
|
||||
*/
|
||||
export const courseApi = {
|
||||
prefixCourse: '/study/courses',
|
||||
/**
|
||||
* 获取课程列表
|
||||
* @param filter 过滤条件
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async getCourseList(filter?: Partial<Course>): Promise<ResultDomain<Course>> {
|
||||
const response = await api.get<Course>('/study/course/list', filter);
|
||||
async getCourseList(filter?: Course): Promise<ResultDomain<Course>> {
|
||||
const response = await api.get<Course>(`${this.prefixCourse}/list`, filter);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取课程分页列表
|
||||
* @param PageRequest 分页请求
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async getCoursePage(pageParam: PageParam, filter?: Course): Promise<ResultDomain<Course>> {
|
||||
const response = await api.post<Course>(`${this.prefixCourse}/page`, {
|
||||
pageParam,
|
||||
filter
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -26,8 +40,8 @@ export const courseApi = {
|
||||
* @param courseID 课程ID
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async getCourseById(courseID: string): Promise<ResultDomain<Course>> {
|
||||
const response = await api.get<Course>(`/study/course/${courseID}`);
|
||||
async getCourseById(courseID: string): Promise<ResultDomain<CourseVO>> {
|
||||
const response = await api.get<CourseVO>(`${this.prefixCourse}/${courseID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -36,8 +50,8 @@ export const courseApi = {
|
||||
* @param course 课程数据
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async createCourse(course: Course): Promise<ResultDomain<Course>> {
|
||||
const response = await api.post<Course>('/study/course/create', course);
|
||||
async createCourse(course: CourseVO): Promise<ResultDomain<CourseVO>> {
|
||||
const response = await api.post<CourseVO>(`${this.prefixCourse}/course`, course);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -47,7 +61,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async updateCourse(course: Course): Promise<ResultDomain<Course>> {
|
||||
const response = await api.put<Course>('/study/course/update', course);
|
||||
const response = await api.put<Course>(`${this.prefixCourse}/course`, course);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -57,7 +71,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteCourse(courseID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>(`/study/course/${courseID}`);
|
||||
const response = await api.delete<boolean>(`${this.prefixCourse}/${courseID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -68,7 +82,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async updateCourseStatus(courseID: string, status: number): Promise<ResultDomain<Course>> {
|
||||
const response = await api.put<Course>(`/study/course/${courseID}/status`, null, {
|
||||
const response = await api.put<Course>(`${this.prefixCourse}/${courseID}/status`, null, {
|
||||
params: { status }
|
||||
});
|
||||
return response.data;
|
||||
@@ -80,7 +94,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async incrementViewCount(courseID: string): Promise<ResultDomain<Course>> {
|
||||
const response = await api.post<Course>(`/study/course/${courseID}/view`);
|
||||
const response = await api.post<Course>(`${this.prefixCourse}/${courseID}/view`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -90,7 +104,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<Course>>
|
||||
*/
|
||||
async incrementLearnCount(courseID: string): Promise<ResultDomain<Course>> {
|
||||
const response = await api.post<Course>(`/study/course/${courseID}/learn`);
|
||||
const response = await api.post<Course>(`${this.prefixCourse}/${courseID}/learn`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -100,7 +114,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<CourseChapter>>
|
||||
*/
|
||||
async getCourseChapters(courseID: string): Promise<ResultDomain<CourseChapter>> {
|
||||
const response = await api.get<CourseChapter>(`/study/course/${courseID}/chapters`);
|
||||
const response = await api.get<CourseChapter>(`${this.prefixCourse}/${courseID}/chapters`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -110,7 +124,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<CourseChapter>>
|
||||
*/
|
||||
async getChapterById(chapterID: string): Promise<ResultDomain<CourseChapter>> {
|
||||
const response = await api.get<CourseChapter>(`/study/course/chapter/${chapterID}`);
|
||||
const response = await api.get<CourseChapter>(`${this.prefixCourse}/chapter/${chapterID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -120,7 +134,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<CourseChapter>>
|
||||
*/
|
||||
async createChapter(chapter: CourseChapter): Promise<ResultDomain<CourseChapter>> {
|
||||
const response = await api.post<CourseChapter>('/study/course/chapter/create', chapter);
|
||||
const response = await api.post<CourseChapter>(`${this.prefixCourse}/chapter/create`, chapter);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -130,7 +144,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<CourseChapter>>
|
||||
*/
|
||||
async updateChapter(chapter: CourseChapter): Promise<ResultDomain<CourseChapter>> {
|
||||
const response = await api.put<CourseChapter>('/study/course/chapter/update', chapter);
|
||||
const response = await api.put<CourseChapter>(`${this.prefixCourse}/chapter/update`, chapter);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -140,7 +154,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteChapter(chapterID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>(`/study/course/chapter/${chapterID}`);
|
||||
const response = await api.delete<boolean>(`${this.prefixCourse}/chapter/${chapterID}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -151,7 +165,7 @@ export const courseApi = {
|
||||
* @returns Promise<ResultDomain<CourseChapter>>
|
||||
*/
|
||||
async updateChapterOrder(chapterID: string, orderNum: number): Promise<ResultDomain<CourseChapter>> {
|
||||
const response = await api.put<CourseChapter>(`/study/course/chapter/${chapterID}/order`, null, {
|
||||
const response = await api.put<CourseChapter>(`${this.prefixCourse}/chapter/${chapterID}/order`, null, {
|
||||
params: { orderNum }
|
||||
});
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user