59 lines
1.1 KiB
TypeScript
59 lines
1.1 KiB
TypeScript
|
|
import { http } from './index';
|
||
|
|
|
||
|
|
export interface Theme {
|
||
|
|
id: number;
|
||
|
|
name: string;
|
||
|
|
description?: string;
|
||
|
|
sortOrder: number;
|
||
|
|
status: string;
|
||
|
|
createdAt: string;
|
||
|
|
courses?: {
|
||
|
|
id: number;
|
||
|
|
name: string;
|
||
|
|
coverImagePath?: string;
|
||
|
|
}[];
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface CreateThemeData {
|
||
|
|
name: string;
|
||
|
|
description?: string;
|
||
|
|
sortOrder?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface UpdateThemeData {
|
||
|
|
name?: string;
|
||
|
|
description?: string;
|
||
|
|
sortOrder?: number;
|
||
|
|
status?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取主题列表
|
||
|
|
export function getThemeList() {
|
||
|
|
return http.get('/admin/themes');
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取主题详情
|
||
|
|
export function getThemeDetail(id: number) {
|
||
|
|
return http.get(`/admin/themes/${id}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 创建主题
|
||
|
|
export function createTheme(data: CreateThemeData) {
|
||
|
|
return http.post('/admin/themes', data);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 更新主题
|
||
|
|
export function updateTheme(id: number, data: UpdateThemeData) {
|
||
|
|
return http.put(`/admin/themes/${id}`, data);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 删除主题
|
||
|
|
export function deleteTheme(id: number) {
|
||
|
|
return http.delete(`/admin/themes/${id}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 重新排序主题
|
||
|
|
export function reorderThemes(ids: number[]) {
|
||
|
|
return http.put('/admin/themes/reorder', { ids });
|
||
|
|
}
|