- 前端 course.ts: /courses → /admin/courses (匹配Java后端路径) - 路由守卫: 修复token存在但role缺失时的无限循环404问题 - AdminCourseController: 新增审核相关接口 (submit/withdraw/approve/reject/unpublish/republish/direct-publish) - AdminCourseController: 课程列表支持status过滤,显示所有状态课程 - CourseService/Impl: 新增提交审核、审批、拒绝等方法 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
212 lines
5.1 KiB
TypeScript
212 lines
5.1 KiB
TypeScript
import { http } from './index';
|
||
|
||
export interface CourseQueryParams {
|
||
page?: number;
|
||
pageSize?: number;
|
||
grade?: string;
|
||
status?: string;
|
||
keyword?: string;
|
||
}
|
||
|
||
export interface Course {
|
||
id: number;
|
||
name: string;
|
||
description?: string;
|
||
pictureBookName?: string;
|
||
grades: string[];
|
||
status: string;
|
||
version: string;
|
||
usageCount: number;
|
||
teacherCount: number;
|
||
avgRating: number;
|
||
createdAt: Date;
|
||
updatedAt: Date;
|
||
submittedAt?: Date;
|
||
reviewedAt?: Date;
|
||
reviewComment?: string;
|
||
// 新增字段
|
||
themeId?: number;
|
||
theme?: { id: number; name: string };
|
||
coreContent?: string;
|
||
coverImagePath?: string;
|
||
domainTags?: string[];
|
||
gradeTags?: string[];
|
||
duration?: number;
|
||
// 课程介绍字段
|
||
introSummary?: string;
|
||
introHighlights?: string;
|
||
introGoals?: string;
|
||
introSchedule?: string;
|
||
introKeyPoints?: string;
|
||
introMethods?: string;
|
||
introEvaluation?: string;
|
||
introNotes?: string;
|
||
// 排课计划参考
|
||
scheduleRefData?: string;
|
||
// 环创建设
|
||
environmentConstruction?: string;
|
||
// 关联课程
|
||
courseLessons?: CourseLesson[];
|
||
}
|
||
|
||
export interface CourseLesson {
|
||
id: number;
|
||
courseId: number;
|
||
lessonType: string;
|
||
name: string;
|
||
description?: string;
|
||
duration: number;
|
||
videoPath?: string;
|
||
videoName?: string;
|
||
pptPath?: string;
|
||
pptName?: string;
|
||
pdfPath?: string;
|
||
pdfName?: string;
|
||
objectives?: string;
|
||
preparation?: string;
|
||
extension?: string;
|
||
reflection?: string;
|
||
assessmentData?: string;
|
||
useTemplate: boolean;
|
||
sortOrder: number;
|
||
steps?: LessonStep[];
|
||
}
|
||
|
||
export interface LessonStep {
|
||
id: number;
|
||
lessonId: number;
|
||
name: string;
|
||
content?: string;
|
||
duration: number;
|
||
objective?: string;
|
||
resourceIds?: string;
|
||
sortOrder: number;
|
||
}
|
||
|
||
export interface ValidationResult {
|
||
valid: boolean;
|
||
errors: ValidationError[];
|
||
warnings: ValidationWarning[];
|
||
}
|
||
|
||
export interface ValidationError {
|
||
field: string;
|
||
message: string;
|
||
code: string;
|
||
}
|
||
|
||
export interface ValidationWarning {
|
||
field: string;
|
||
message: string;
|
||
code: string;
|
||
}
|
||
|
||
// 获取课程包列表
|
||
export function getCourses(params: CourseQueryParams): Promise<{
|
||
items: Course[];
|
||
total: number;
|
||
page: number;
|
||
pageSize: number;
|
||
}> {
|
||
return http.get('/admin/courses', { params });
|
||
}
|
||
|
||
// 获取审核列表
|
||
export function getReviewList(params: CourseQueryParams): Promise<{
|
||
items: Course[];
|
||
total: number;
|
||
page: number;
|
||
pageSize: number;
|
||
}> {
|
||
return http.get('/admin/courses/review', { params });
|
||
}
|
||
|
||
// 获取课程包详情
|
||
export function getCourse(id: number): Promise<any> {
|
||
return http.get(`/admin/courses/${id}`);
|
||
}
|
||
|
||
// 创建课程包
|
||
export function createCourse(data: any): Promise<any> {
|
||
return http.post('/admin/courses', data);
|
||
}
|
||
|
||
// 更新课程包
|
||
export function updateCourse(id: number, data: any): Promise<any> {
|
||
return http.put(`/admin/courses/${id}`, data);
|
||
}
|
||
|
||
// 删除课程包
|
||
export function deleteCourse(id: number): Promise<any> {
|
||
return http.delete(`/admin/courses/${id}`);
|
||
}
|
||
|
||
// 验证课程完整性
|
||
export function validateCourse(id: number): Promise<ValidationResult> {
|
||
return http.get(`/admin/courses/${id}/validate`);
|
||
}
|
||
|
||
// 提交审核
|
||
export function submitCourse(id: number, copyrightConfirmed: boolean): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/submit`, { copyrightConfirmed });
|
||
}
|
||
|
||
// 撤销审核
|
||
export function withdrawCourse(id: number): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/withdraw`);
|
||
}
|
||
|
||
// 审核通过
|
||
export function approveCourse(id: number, data: { checklist?: any; comment?: string }): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/approve`, data);
|
||
}
|
||
|
||
// 审核驳回
|
||
export function rejectCourse(id: number, data: { checklist?: any; comment: string }): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/reject`, data);
|
||
}
|
||
|
||
// 直接发布(超级管理员)
|
||
export function directPublishCourse(id: number, skipValidation?: boolean): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/direct-publish`, { skipValidation });
|
||
}
|
||
|
||
// 发布课程包(兼容旧API)
|
||
export function publishCourse(id: number): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/publish`);
|
||
}
|
||
|
||
// 下架课程包
|
||
export function unpublishCourse(id: number): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/unpublish`);
|
||
}
|
||
|
||
// 重新发布
|
||
export function republishCourse(id: number): Promise<any> {
|
||
return http.post(`/admin/courses/${id}/republish`);
|
||
}
|
||
|
||
// 获取课程包统计数据
|
||
export function getCourseStats(id: number): Promise<any> {
|
||
return http.get(`/admin/courses/${id}/stats`);
|
||
}
|
||
|
||
// 获取版本历史
|
||
export function getCourseVersions(id: number): Promise<any[]> {
|
||
return http.get(`/admin/courses/${id}/versions`);
|
||
}
|
||
|
||
// 课程状态映射
|
||
export const COURSE_STATUS_MAP: Record<string, { label: string; color: string }> = {
|
||
DRAFT: { label: '草稿', color: 'default' },
|
||
PENDING: { label: '审核中', color: 'processing' },
|
||
REJECTED: { label: '已驳回', color: 'error' },
|
||
PUBLISHED: { label: '已发布', color: 'success' },
|
||
ARCHIVED: { label: '已下架', color: 'warning' },
|
||
};
|
||
|
||
// 获取状态显示信息
|
||
export function getCourseStatusInfo(status: string) {
|
||
return COURSE_STATUS_MAP[status] || { label: status, color: 'default' };
|
||
}
|