152 lines
3.4 KiB
TypeScript
152 lines
3.4 KiB
TypeScript
// api/modules/course.ts
|
|
import { createRequestClient } from '../request'
|
|
import { SERVICE_MAP } from '../config'
|
|
import type {
|
|
ICourseCategoryResponse,
|
|
IUserLateCourseListResponse,
|
|
IMarketCourseListResponse,
|
|
ICourseMedicalLabelsResponse
|
|
} from '@/types/course'
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
|
|
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
|
|
|
/**
|
|
* 课程分类及分类下课程相关API
|
|
*/
|
|
export const courseSubjectClassificationApi = {
|
|
/**
|
|
* 医学
|
|
* 获取课程分类树
|
|
* @returns 分类数据
|
|
*/
|
|
getCourseMedicalTree() {
|
|
const userStore = useUserStore()
|
|
return client.request<ICourseCategoryResponse>({
|
|
url: userStore.token ? 'medical/home/getCourseMedicalTree' : '/visitor/getCourseMedicalTree',
|
|
method: 'POST',
|
|
data: {}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 心理学
|
|
* 获取课程分类树
|
|
* @returns 分类数据
|
|
*/
|
|
getCourseSoulTree() {
|
|
return client.request<ICourseCategoryResponse>({
|
|
url: 'psyche/home/getPsycheLabels',
|
|
method: 'POST',
|
|
data: { id: 0 }
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 国学
|
|
* 获取课程分类树
|
|
* @returns 分类数据
|
|
*/
|
|
getCourseSociologyTree() {
|
|
return client.request<ICourseCategoryResponse>({
|
|
url: 'sociology/home/getSociologyLabels',
|
|
method: 'POST',
|
|
data: { id: 0 }
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 医学
|
|
* 获取分类标签列表
|
|
* @returns 分类数据
|
|
*/
|
|
getCourseMedicalLabels(id: number) {
|
|
return client.request<ICourseCategoryResponse>({
|
|
url: 'medical/home/getMedicalLabels',
|
|
method: 'POST',
|
|
data: { id }
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 医学
|
|
* 获取分类下的列表页子级标签
|
|
* @returns 分类数据
|
|
*/
|
|
getCourseMedicalChildLabels(id: number) {
|
|
return client.request<ICourseCategoryResponse>({
|
|
url: 'medical/home/getChildCourseMedicalTree',
|
|
method: 'POST',
|
|
data: { id }
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 医学
|
|
* 获取分类下的课程列表
|
|
* @param data 分类ID、页码、每页数量
|
|
* @returns 课程列表
|
|
*/
|
|
getMedicalCourseList(data: {
|
|
id: number, // 分类ID
|
|
page: number, // 页码
|
|
limit: number // 每页数量
|
|
}) {
|
|
return client.request<IMarketCourseListResponse>({
|
|
url: 'medical/home/getMedicalCourseList',
|
|
method: 'POST',
|
|
data
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 心理学
|
|
* 获取分类下的列表页子级标签
|
|
* @returns 分类数据
|
|
*/
|
|
getCourseSoulChildLabels(id: number) {
|
|
return client.request<ICourseCategoryResponse>({
|
|
url: 'psyche/home/getChildCoursePsycheTree',
|
|
method: 'POST',
|
|
data: { id }
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 心理学
|
|
* 获取分类下的课程列表
|
|
* @param data 分类ID、页码、每页数量
|
|
* @returns 课程列表
|
|
*/
|
|
getSoulCourseList(data: {
|
|
id: number, // 分类ID
|
|
page: number, // 页码
|
|
limit: number // 每页数量
|
|
}) {
|
|
return client.request<IMarketCourseListResponse>({
|
|
url: 'psyche/home/getPsycheCourseList',
|
|
method: 'POST',
|
|
data
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 国学
|
|
* 获取分类下的课程列表
|
|
* @param data 分类ID、页码、每页数量
|
|
* @returns 课程列表
|
|
*/
|
|
getSociologyCourseList(data: {
|
|
id: number, // 分类ID
|
|
page: number, // 页码
|
|
limit: number // 每页数量
|
|
}) {
|
|
return client.request<IMarketCourseListResponse>({
|
|
url: 'sociology/course/getSociologyCourseList',
|
|
method: 'POST',
|
|
data
|
|
})
|
|
},
|
|
}
|